I need to know how to remotely detect whether an 8mp or a 5mp camera module is connected to the rpi for implementation in an embedded project.
Any help?
I need to know how to remotely detect whether an 8mp or a 5mp camera module is connected to the rpi for implementation in an embedded project.
Any help?
None of the above.
Take advantage of the v4l driver (modprobe bcm2835-v4l2
), and either use the v4l2-ctl
command from the CLI, or, if you want to get fancy, use the v4l2 libraries from python or C:
# v4l2-ctl --list-formats
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'YU12'
Name : Planar YUV 4:2:0
(much more output)
# v4l2-ctl --list-framesizes=YU12
ioctl: VIDIOC_ENUM_FRAMESIZES
Size: Stepwise 16x16 - 2592x1944 with step 2/2
v4l2-ctl
, not v412-ctl
. That's a lowercase L after the 4, not a 1. It appears to have come preinstalled on a totally-stock raspbian for a pi zero I just opened.
None of the above worked for me. With Raspbian Stretch (June 2018 Version, Kernel 4.14), Python 3.5 and picamera 1.13 I used:
import picamera
with picamera.PiCamera() as cam:
print(cam.revision)
If you're happy coding C, have a look at the relevant lines in raspistill which uses the new MMAL_PARAMETER_CAMERA_INFO
to look up the type of camera attached.
If you're not so happy with C, you'll need to wait a week or so while I finish off picamera 1.11 which will have a new PiCamera.model
parameter you can query for the same information (this will return a string containing the sensor name as returned by MMAL_PARAMETER_CAMERA_INFO
).
Update
As EdMc2's answer neatly shows, I wound up calling this PiCamera.revision
rather than model!
EdMc2's answer worked for me--but cam.revision only display camera sensor name. So I did find maximum resolution like this:
import picamera
with picamera.PiCamera() as cam:
print(cam.MAX_RESOLUTION)
You can save the file (for example, picamera.py) and execute it like this:
python3 picamera.py
My result is 2592x1944
which is 5MP camera.