silversword411
Posts: 2
Joined: Fri Jun 03, 2016 10:31 pm

Understanding the Pi Camera with a M12 lens/mount

Fri Jun 03, 2016 10:54 pm

I'm trying to build up a lexicon and understand how to calculate/adapt/choose lenses to work with the Pi Camera.

I'm starting with the standard Pi Camera: https://www.raspberrypi.org/products/camera-module/
or v2 camera: https://www.raspberrypi.org/products/camera-module-v2/
or Pi NoIR: https://www.raspberrypi.org/products/pi-noir-camera/
or Pi NoIR v2: https://www.raspberrypi.org/products/pi-noir-camera-v2/

And adding a standard M12 mount: http://www.amazon.com/Black-Plastic-Spa ... B016FBNYNM

How do I figure out what lens I need to have xyz. I'm looking for a good telephoto specifically, but I think it would be beneficial for everyone to have some reading material that will explain how all these work together:
- Sensor size (Pi is 1/4" right)
- Focal Length
- aperture
etc.

Thanks to the optical gurus out there :)
David

User avatar
jbeale
Posts: 4003
Joined: Tue Nov 22, 2011 11:51 pm

Re: Understanding the Pi Camera with a M12 lens/mount

Sat Jun 04, 2016 11:59 pm

First off, the mounting holes on both v1 and v2 RPi cameras are on 21 mm centers [1], so the 20 mm spacing of the M12 mount you link isn't a perfect fit. Depending on your mounting screw size, you may still be able to force it. Second, you have to manually cut or file down a notch in the M12 mount for the micro-flex cable that comes out of the camera module. That isn't too hard, but if you want, there is also a M12 mount specifically designed for the RPi cameras, with a notch already [2].

The v1 and v2 sensor sizes are the same, the so-called 1/4-inch format. On V1 the lens focal length is f=3.6mm with Angle of View: 54 x 41 degrees and on V2 it is f=3.0mm with Angle of View: 62.2 x 48.8 degrees [1]. Note the angle of view is quoted at full-frame; remember some video modes use a cropped subset of the full frame. This is a moderately wide angle lens. If you double the focal length, you'll get half the field of view. If you get a 8mm lens that's a moderate telephoto, and a 16mm lens is definitely telephoto. I've tried a number of cheap M12 lenses [3] that work "ok" but don't expect perfectly sharp images with the tiny 1.4 or 1.1 micron pixels these camera sensors use. Lower f-number lenses are "faster" (let in more light) but will have more shallow depth of field and more blurry overall. You will see f/1.4 or lower sold for use in low light, but I have not had good images with those; I would recommend f/2.0 or above if you want decent resolution.

The longest lens I've tried is a reversed 4x microscope objective, about f=27mm delivering 8 degrees horizontal field of view [4]. I made a 3D printed holder for it [5]. That lens is good enough to recognize faces from over 100 feet away. Attached image is a crop from 1640x1232 (full-frame) mp4 video from v2 camera, using that lens.
PiCam-PersonWalking-4xObj.jpg
person about 140 feet (43 m) away
PiCam-PersonWalking-4xObj.jpg (6.78 KiB) Viewed 58835 times
References:
----------------------
[1] http://elinux.org/Rpi_Camera_Module#Tec ... 1_board.29
[2] http://www.m12lenses.com/CNC-Machined-R ... 020rpm.htm
[3] http://www.m12lenses.com/M12-Mount-Mega ... s-s/21.htm
[4] viewtopic.php?f=43&t=148328
[5] http://www.thingiverse.com/thing:1565909

silversword411
Posts: 2
Joined: Fri Jun 03, 2016 10:31 pm

Re: Understanding the Pi Camera with a M12 lens/mount

Mon Jun 06, 2016 12:17 pm

Awesome info thanks.

Is there an equation that translates the mm to zoom factor/angle of view (other than doubling focal length halves field of view)?

F= makes sense. When I look at my DSLR's zoom lens (35-70 or 75-300), I can see how much zoom/angle I get just be playing with the zoom. But since my numbers on the DSLR is different than the Raspberry Pi lenses [3] I'm assuming the sensor size is part of the equation dictating what magnification/angle of view I'm going to get (understanding that fish eye lenses are going to add extra angle of view in the calculation but will introduce distortion).

For now, I'm trying to get a good face/license plate capture on the main roadway access to my residence but I'm hoping to gain information that will allow me to calculate results in advance for Raspberry Pi cameras of the future (v3, v4 etc :) )

Thanks!
David


User avatar
jbeale
Posts: 4003
Joined: Tue Nov 22, 2011 11:51 pm

Re: Understanding the Pi Camera with a M12 lens/mount

Mon Jun 06, 2016 2:02 pm

The RPi v2 camera sensor size is 3.67 x 2.76 mm (1/4" format). The horizontal dimension is almost 10x smaller than a traditional 35 mm film SLR or "full-frame" DSLR with a 36x24 mm image area.

So if you have a "full-frame" DSLR, the "crop factor" of a 1/4 sensor relative to that is about 10. So a 200 mm lens on a full-frame DSLR gives you very nearly the same horizontal field of view as a 20 mm lens on the Raspberry Pi sensor, and a 50mm SLR lens compares to a 5 mm lens on the RPi.

duanereilly
Posts: 1
Joined: Tue Mar 21, 2017 2:29 pm

Re: Understanding the Pi Camera with a M12 lens/mount

Tue Mar 21, 2017 3:01 pm

Thank you very much jbeale for posting this, ive made one myself and from rough tests with the clarity at distance is amazing,
That microscope objective you suggested fits perfectly snugly in the barrel.
heres some pics of it, no pics with it yet, when i get it mounted, ill come back and re-necro this thread with pics.
http://imgur.com/gallery/i0Plm
Once again, thanks heaps jbeale, learnt a tonne doing,

User avatar
jbeale
Posts: 4003
Joined: Tue Nov 22, 2011 11:51 pm

Re: Understanding the Pi Camera with a M12 lens/mount

Tue Mar 21, 2017 8:08 pm

Glad to help! If anyone else needs a long lens, I can recommend this f=25mm M12 lens http://www.ebay.com/itm/282167088666
I found it to have better image quality than the cheap microscope objective I used before, and the threads mean you can set focus more easily by turning it. This does mean that you will need a M12 lens mount, but there are apparently solutions for that: http://www.thingiverse.com/thing:1963856 (which looks right, but I haven't tried that one myself)

Chrobry
Posts: 6
Joined: Sun Apr 02, 2017 12:15 am

Re: Understanding the Pi Camera with a M12 lens/mount

Tue Apr 04, 2017 6:14 pm

The Raspberry lens mount appears to be a M6. Are M6 lens available or are these only sold by OEMs? Are the M12 lenses and mounts the smallest board mount available retail? I don't see other sizes on ebay.

User avatar
jbeale
Posts: 4003
Joined: Tue Nov 22, 2011 11:51 pm

Re: Understanding the Pi Camera with a M12 lens/mount

Tue Apr 04, 2017 6:44 pm

M12 lenses are by far the most common small "board camera" lens, you see them used in security cameras, dashcams etc. I'm not aware of any smaller interchangeable lens format.

M6, M7, etc. lenses are really only used for mobile phone type devices and there is little standardization on thread pitch, etc. Normally these are OEM-only and you buy your lens and your lens mount from the same vendor, otherwise it probably won't fit. As an example- the RPi v1 and v2 cameras both use a nominally M6 lens, but the threads are just slightly different and they don't interchange. You actually can force a v1 lens onto a v2 camera, but that is only because the plastic parts can be deformed.

Namwoong Kong
Posts: 1
Joined: Fri Jul 21, 2017 6:49 am

Re: Understanding the Pi Camera with a M12 lens/mount

Fri Jul 21, 2017 7:33 am

Your post has helped my project a lot. Thank you.
I have a question.
Is using a 4x microscope for use as a telephoto lens?
Does the M12 25mm lens you recommend on the post have the same function?
I want to use the raspberry camera to take precise pictures at close range.
I would like to use a raspberry camera to capture 3mm size objects clearly and clearly.
Please advise which lens to use.

sehwert
Posts: 2
Joined: Sat Aug 05, 2017 3:15 pm

Re: Understanding the Pi Camera with a M12 lens/mount

Sat Aug 05, 2017 3:21 pm

Hi there,

I am trying to built a little "photo box" to take images of mostly flat objects under the same conditions. The idead is to mount the V2 camera about 60cm max above the area that I want to cover (approx. 30 x 40 cm).

Can someone suggest what lens (M12) to use for such a device in order to get sharp images.

Thanks!

sehwert

closefan
Posts: 1
Joined: Sat Aug 12, 2017 5:49 pm

Re: Understanding the Pi Camera with a M12 lens/mount

Sat Aug 12, 2017 5:56 pm

David,

I am interested in the list you have compiled so far. I am interested in buying a pi v2 and a mount and lens. So far I have come across
http://www.m12lenses.com/CNC-Machined-R ... 023rpp.htm

This is a m12 mount specifically made for the pi v2 from this m12 lenses .com

I am unsure what lens to buy. I would like to make a selfie cam that you can hold about 6-12 inches from the face and still get the top of head down to mid chest. Not sure if the v2 can do that just fine since it may be a wide angle out of box.

Any info on that would be greatly appreciated.

ms_1987
Posts: 1
Joined: Wed Aug 16, 2017 1:25 am

Re: Understanding the Pi Camera with a M12 lens/mount

Wed Aug 16, 2017 1:42 am

Hi John,

Your post is very useful, many thanks!

I am working with the Pi V2 camera and I would like to change the actual focal lens with a 16-25 mm because I need longer focal in my work (I will be 100 m far away).

Could you suggest me some lens compatible with the M12 Mount for Raspberry Pi V2 Camera (https://www.thingiverse.com/thing:1963856/#comments)?

Many thanks

roboengr
Posts: 1
Joined: Wed Aug 23, 2017 5:35 pm

Re: Understanding the Pi Camera with a M12 lens/mount

Wed Aug 23, 2017 5:48 pm

Can anyone help me with this project/question

in this project I am wanting to read a license plate from about 80-100ft in one case. or see a face from 200 ft away. two separate scenarios or camera setups. I would like enough quality for identification. I really want the zoom function. I have pan tilt working good. I am also wanting night vision capability.

I have the RPI v2 camera board NOIR

Also, I have a 9-22mm 1/3" IR F1.4 CCTV Video Vari-focal Zoom Lens m12 mount

Len Type:Manual Iris Lens
Focal Length: 9 ~ 22mm
Imager Size: 1/3"
Mount Type: M12 x 0.5
Aperture Range: F / 1.4
M. O. D: 0.2m

Question: can I simply mount this on the RPI v2 camera board and it have a good picture? If not, can you explain what I can and cant do. I have tried it with issues such as a smaller circle unfocused with black. is this a focal distance to the sensor. do I need to remove the small factory lens. Is there any help you might provide.

The lenses suggested above will they do what I need as a fixed lens?

Thanks for your help in advance

User avatar
jbeale
Posts: 4003
Joined: Tue Nov 22, 2011 11:51 pm

Re: Understanding the Pi Camera with a M12 lens/mount

Mon Aug 28, 2017 12:03 am

If you retrofit your pi camera with a M12 lens mount, then yes a M12 lens should work on it. I have done this and it works. Don't expect the same image quality as with the stock pi lens though. If you need longer lenses you can do much better for slightly more money with an IP security camera. These generally use a 1/3 inch sensor that outperforms the pi camera, are already set up for M12 lenses, and will autoswitch between full color day mode and near-IR night mode. Dahua has some nice models, street prices starting around $65.

drich
Posts: 83
Joined: Tue Jul 28, 2015 7:36 pm
Location: Paris, France 🇫🇷

Re: Understanding the Pi Camera with a M12 lens/mount

Tue Sep 05, 2017 12:32 pm

Does anyone have good wide-angle (>110°) M12 lens ? The few ones I've tested have a very poor non-linear focusing, either center is focused and contour is blur, either the center is blurred and contour is focused

User avatar
jbeale
Posts: 4003
Joined: Tue Nov 22, 2011 11:51 pm

Re: Understanding the Pi Camera with a M12 lens/mount

Fri Sep 08, 2017 4:13 pm

I'm not aware of any that I would call "sharp". Here's a RPi-compatible lens that's pretty close to 180 degrees:
viewtopic.php?t=158545&p=1164934#p1039847

It is definitely not sharp across the field, but still usable for some things, and it's about as good as I've seen for the RPi 1/4-inch sensor size. The better wide-angle images I've seen are from larger-sensor cameras. There are pretty good examples from 1/3-inch sensor security camera / dashcam devices.

wkeeling
Posts: 173
Joined: Fri Aug 25, 2017 2:16 pm
Location: Houston Texas

Re: Understanding the Pi Camera with a M12 lens/mount

Wed Jan 31, 2018 7:43 pm

I am using the pi to live stream racing and in 720p mode the field of view angle is good for the car. So what lens would give me a similar angle of view at 1080p mode?

Thanks
Willie Keeling

Toysrfun
Posts: 8
Joined: Fri Oct 12, 2018 7:10 am

Re: Understanding the Pi Camera with a M12 lens/mount

Mon Oct 22, 2018 3:12 am

You can buy the cameras with preinstalled lenses on aliexpress to the original housing but you don’t get the pcb so you end up paying considerably more especially if you don’t want the wide angle offered.

User avatar
salsaman
Posts: 9
Joined: Wed Jun 03, 2015 9:16 pm

Re: Understanding the Pi Camera with a M12 lens/mount

Thu Mar 14, 2019 3:59 pm

closefan wrote:
Sat Aug 12, 2017 5:56 pm
...So far I have come across
http://www.m12lenses.com/CNC-Machined-R ... 023rpp.htm

This is a m12 mount specifically made for the pi v2 from this m12 lenses .com

Did you ever get this mount? Did it work?

I wonder if anybody has gotten an M12 lens mounted on a Pi cam V2 in a reliable way.

User avatar
HermannSW
Posts: 6093
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Understanding the Pi Camera with a M12 lens/mount

Fri Mar 15, 2019 7:29 am

salsaman wrote:
Thu Mar 14, 2019 3:59 pm
I wonder if anybody has gotten an M12 lens mounted on a Pi cam V2 in a reliable way.
I did add M12 mount myself to v1 camera (clone):
viewtopic.php?f=43&t=45887&p=1279957#p1279957

And to v2 camera:
viewtopic.php?f=43&t=45887&p=1279957#p1290678

It was not difficult although I had not done similar before.

You can buy imx219 Arducam cameras with lens, but they are more expensive than the official Raspberry v2 camera:
https://www.robotshop.com/en/catalogsea ... /?q=imx219

I did buy an Arducam ov5647 recently (that corresponds to a Raspberry v1 camera) with M12 lens mount for 20$ because of exposed ov5647 sensor pins that are not available on v1 camera:
viewtopic.php?f=43&t=235523
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
salsaman
Posts: 9
Joined: Wed Jun 03, 2015 9:16 pm

Re: Understanding the Pi Camera with a M12 lens/mount

Fri Mar 15, 2019 2:45 pm

Thanks @HermannSW, I should have dug deeper! The camera with M12 lens isn't available at the moment from robotshop but should be soon, I'll grab one of those ASAP. Thanks for the details in the other threads, very useful information.

barsznica
Posts: 20
Joined: Thu Apr 14, 2016 12:38 pm

Re: Understanding the Pi Camera with a M12 lens/mount

Tue Apr 07, 2020 9:42 am

Hi,
Would anyone recommend a RPi camera able to do 1080p30 with a horizontal FOV of about 90 degrees?

Return to “Camera board”