Search code examples
c++linuxopencvraspberry-pigpio

Working on Raspberry Pi with OpenCV and BCM2835


I am currently working on Raspberry Pi and using the Raspberry Pi camera module. I plan to use OpenCV for image processing on the RPi and currently it seems not much of a problem. However, I am trying to use the BCM2835 library along with OpenCV and not able to integrate it. I tried to make changes in the Makefile and adding the bcm library and also adding path of the BCM library but nothing seems to work. Please help me to integrate both the libraries as I wish to drive the GPIOs after doing some image processing on the input video.

Thank you.


Solution

  • I finally found the answer to my own question. The bcm library which can be downloaded here: http://www.airspayce.com/mikem/bcm2835/

    are unziped and the following files are pasted in the current folder where we are working which contains the cpp files. bcm2835.h bcm2835.o bcm2835.c

    I added the bcm2835.c in the add_executable of CMakeLists.txt as follows: add_executable(camcv_vid2 bcm2835.c RaspiCamControl.c RaspiCLI.c RaspiPreview.c camcv_vid2.cpp)

    Add the bcm2835.h in the program: extern "C" { ..

    include "bcm2835.h"

    .. }

    Initialize the GPIO using bcm2835_init() in the main function and you are good to go. Use the GPIOs to your benefit. Overall, it is a combination of combining C and C++ files along with modifications in the CMakeLists.txt

    Enjoy!