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.
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It only takes a minute to sign up.Sign up to join this community
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
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
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:
My result is
2592x1944 which is 5MP camera.