Raspberry Camera API

From Rsewiki
Revision as of 16:44, 28 January 2021 by Jca (Talk | contribs)

Jump to: navigation, search

Back to Robobot

Raspicam

To be used from C++ direct or through openCV.

A rather short raspberry pi camera API is available from https://www.uco.es/investiga/grupos/ava/node/40.

And can be downloaded from https://sourceforge.net/projects/raspicam/files/,

or get the file from sourceforge with no GUI, with:

cd ~/Downloads
wget --no-check-certificate -O raspicam-0.1.9.zip https://downloads.sourceforge.net/project/raspicam/raspicam-0.1.9.zip?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fraspicam%2F%3Fsource%3Dtyp_redirect&ts=1486483484&use_mirror=netix

Once fetched and available on the raspberry, then Unpack and install:

unzip raspicam-0.1.9.zip
cd raspicam-0.1.9
mkdir build
cd build
cmake ..
make -j3
sudo make install
sudo ldconfig

The library is installed in /usr/local, and therefore to make cmake find it the path needs to be added to startup configuration, in file ~/.bashrc

cd
nano ~/.bashrc
add at the end:
export CMAKE_PREFIX_PATH=/usr/local/lib
source ~/.bashrc   # to implement export

Test with openCV

raspicam_cv_test

That takes 100 images and saves 3.

Camera streamer

To download the project you will need a source control system called git. It may not be installed on a fresh image. I know it’s not on the lite image. So you may need to install it.

sudo apt-get install git

Now that you have git installed, use it to clone a copy of the mjpg-streamer to your Pi.

git clone https://github.com/jacksonliam/mjpg-streamer.git

After the cloned copy of the mjpeg-stream has been coppied to the raspberry-pi, follow these steps.

cd mjpg-streamer/
cd mjpg-streamer-experimental/
sudo apt-get install cmake
# sudo apt-get install python-imaging
# sudo apt-get install libjpeg-dev
make CMAKE_BUILD_TYPE=Debug
sudo make install

Make a script to start the streamer

cd
nano start-stream.sh

copy this into the file (uncomment only one line - the others are examples for other resolutions)

#!/bin/bash
#mjpg_streamer -i "input_raspicam.so -y 1600 -x 1200 -fps 5 -rot 90" -o output_http.so
mjpg_streamer -i "input_raspicam.so -y 972 -x 1296 -fps 3 -rot=0" -o output_http.so
#mjpg_streamer -i "input_raspicam.so -y 600 -x 800 -fps 3 -rot=0" -o output_http.so
#mjpg_streamer -i "input_raspicam.so -y 640 -x 480 -fps 5" -o output_http.so

Change the file to be executable

chmod +x start-stream.sh
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox