Skip to content

advait-0/opencv

 
 

Repository files navigation

libcamera - OpenCV Integration

This branch is the WIP development branch for the libcamera integration into OpenCV

USAGE instructions

This guide assumes you currently have libcamera installed on your device but do not have opencv installed on your device.

  1. Clone this repository.
  2. Make sure you have libcamera installed on your device.
  3. Install all the dependencies required for bulding OpenCV.
  4. Checkout the branch libcamera-final using the command git checkout libcamera-final.
  5. Navigate to the cloned opencv directory and create a new build directory using mkdir build and then cd build.
  6. Set up OpenCV build with CMake, this is the configuration I am using
cmake -D CMAKE_BUILD_TYPE=RELEASE \
  -D CMAKE_INSTALL_PREFIX=/usr/local \
  -D INSTALL_C_EXAMPLES=ON \
  -D INSTALL_PYTHON_EXAMPLES=ON \
  -D WITH_LIBCAMERA=ON \
  -D OPENCV_GENERATE_PKGCONFIG=ON \
  -D BUILD_EXAMPLES=ON ..
  1. Use make or use make -j8 if your processor supports more parallel jobs for faster processing.
  2. To install use sudo make install
  3. After you are done with the installation to test the build with libcamera you can use this sample program
  4. To run the above file you can use g++ libcamera_test.cpp -o libcamera_test `pkg-config --cflags --libs opencv4` To quit the program press q

What works

  • Capturing frames from cameras sending MJPEG and YUYV frames
  • Setting some properties to configure your settings like:
    • cv::CAP_PROP_FRAME_WIDTH - Change the frame width
    • cv::CAP_PROP_FRAME_HEIGHT - Change the frame height
    • cv::CAP_PROP_MODE - Select the PixelFormat (0 - MJPEG, 1 - YUYV, default:MJPEG)
    • cv::CAP_PROP_FORMAT - Select the StreamRole (0 - Raw, 1 - StillCapture, 2 - VideoRecording, 3 - Viewfinder, default:VideoRecording)
  • Getting some data using cap.get
    • cv::CAP_PROP_FRAME_WIDTH - Get the current frame width
    • cv::CAP_PROP_FRAME_HEIGHT - Get the current frame height

What are the known issues

  • if (cap.read(frame)) has to be used to check without which crashes are observed.
  • NV12 support is yet to be tested.
  • Multiple camera support is being worked on, at the moment you can only use one camera at a time.
  • Please create new issues against this branch to notify me if you encounter an issue.

Contributing

Please read the contribution guidelines before starting work on a pull request. Feel free to fork and contribute your changes.

Summary of the guidelines: (These are OpenCV guidelines)

  • One pull request per issue;
  • Choose the right base branch;
  • Include tests and documentation;
  • Clean up "oops" commits before submitting;
  • Follow the coding style guide.

About

Open Source Computer Vision Library

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 87.0%
  • C 3.3%
  • Python 2.7%
  • CMake 2.2%
  • Java 1.7%
  • Objective-C++ 0.9%
  • Other 2.2%