14

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?

5
  • Why not look up the camera specs online?
    – Darth Vader
    Commented Apr 29, 2016 at 20:01
  • The device itself will be inaccessible and so I need to identify the model of the camera though ssh. Commented Apr 29, 2016 at 20:22
  • 2
    Take a picture and look at resolution/size? Should be significantly different.
    – Ghanima
    Commented Apr 29, 2016 at 20:26
  • Is there a cli command to see the dimensions of an image? If so then I could just pipe the output of raspistill into that info command. Commented Apr 29, 2016 at 20:41
  • get some inspiration here superuser.com/questions/275502/… and here unix.stackexchange.com/questions/75635/…
    – Ghanima
    Commented Apr 29, 2016 at 21:03

4 Answers 4

8

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
2
  • 1
    The actual question is apparently how can I get V412-ctl? With me it just says "no such file or directory". "Unable to locate package v412-ct" Without this information the answer is incomplete. Commented Mar 17, 2019 at 16:36
  • @AlbertvanderHorst - The key is that it is 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.
    – ArtHare
    Commented Mar 13, 2021 at 3:18
4

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)
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 MMAL_PARAMETER_CAMERA_INFO).

Update As EdMc2's answer neatly shows, I wound up calling this PiCamera.revision rather than model!

1
  • Thanks for the update! This post shows up first in a search for 'picamera get model' so I'm grateful for the breadcrumbs Commented Sep 25, 2018 at 18:45
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.