Is there a way to open either of the cameras with opencv? I have the phone turned off now, but I am pretty sure it had devices video0-video3. I tried them all in the following code, and was met was a basic error that it couldn’t open the v4l2 device, and couldn’t generate the window, or just that it can’t generate the window.
This is python.
import cv2
print(cv2.__version__)
cam=cv2.VideoCapture(0)
while True:
_, frame=cam.read()
cv2.imshow('cam',frame)
if cv2.waitKey(1)==ord('q'):
break
cam.release()
cv2.destroyAllWindows()
On almost any system with python, opencv, and a camera at video 0, this should open a window called “cam” and display video from camera 0. Any advice to get it working on the pinephone would be appreciated.
and then using OpenCV. At least the ffmpeg CLI accepts the video input if the camera is set up that way, but most applications still do not recognize the camera even with that.
Thanks, I gave that a try and I added an option in opencv to force ffmpeg as the video api.
It didn’t seem to work when running the script from the terminal. I appreciate it though.
A while back I was using a gstreamer pipeline I found online, to make the pi camera work on the jetson nano. I am looking at some literature to see if I can figure out out to make it something like that work here.
It would be great to have GStreamer working with the camera, because it would also make many applications work, but I do not think nvarguscamerasrc is going to work, that is not the model used on the PinePhone (and anyway, GStreamer needs to auto-detect the camera for applications to work with it).
I was just messing around with this a little bit, and come to find out that the opencv builds from PyPI aren’t built with gstreamer support.
I have built pip wheels on python 3.9.9 for opencv-python, and it’s required numpy. It took overnight to build, so I want to upload them in case someone wants to play around with it.
If it’s inappropriate to post external links, mods feel free to remove.
I have been out of town for work and haven’t touched this device for weeks. I built those wheels the night before I left and haven’t tried anything other than seeing that they were built successfully with gstreamer support. If they updated to python 3.10 those wheels probably won’t install anyway. I will probably take a look at it later in the week.