Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for JAVA or OpenCV #96

Open
gasparramoa opened this issue Aug 6, 2024 · 0 comments
Open

Support for JAVA or OpenCV #96

gasparramoa opened this issue Aug 6, 2024 · 0 comments

Comments

@gasparramoa
Copy link

Hello,

First of all, thank you for the open-source library. This project is really something.

I used libcamera and picamera2 and was able to change properties such as the shutter speed (exposure) and analogue gain, which I really needed to solve my problem. I was able to work everything out with Python.

However, to incorporate everything with my application, I would need to have this camera support and control on JAVA. This can also be done through OpenCV, but I heard that there were a lot of problems (github1, github2, stack1, stack2, stack3 ) with that. I tried a lot of things, such as changing between OS versions (Bulleyes and Bookworm). There was even a Google summer code project that worked to fix this, but no solution was found.

In the end, for people who need to use opencv with libcamera, I followed this suggestion:

Until Libcamera is supported by OpenCV the only real solution is to use GStreamer which "comparatively" has quite a high CPU overhead. Example code to initialise VideoCapture;

import cv2
camera = "/base/soc/i2c0mux/i2c@1/imx219@10"
pipeline = "libcamerasrc camera-name=%s ! video/x-raw,width=640,height=480,framerate=10/1,format=RGBx ! videoconvert ! videoscale ! video/x-raw,width=640,height=480,format=BGR ! appsink" % (camera)
cap = cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER)

In my case, I am using camera module 3, and it even works with tuning files:

import cv2
camera = "/base/soc/i2c0mux/i2c@1/imx708@1a"
pipeline = f"libcamerasrc camera-name={camera} ! video/x-raw,width=640,height=480 ! videoconvert ! appsink"
tuning_file = "/home/tactonom/tuning-files/imx219_80d.json"
os.environ['LIBCAMERA_RPI_TUNING_FILE'] = tuning_file
cap = cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER)
ret,frame = cap.read()
(...) 

The problem is that with this solution, I cannot access AnalogueGain and Exposure, which is what makes these cameras interesting since you have so much control.

I want to ask the libcamera community if there is already any feasible solution for this problem.

Best,
Gaspar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant