M12 lens adapter for camera module


46 posts   Page 1 of 2   1, 2
by rkinch » Sun Jun 02, 2013 7:31 am
Here is my adapter to use standard M12 board camera lenses with the Raspberry Pi camera module.
Remove the stock lens and attach this adapter to use an M12 lens.

http://www.truetex.com/raspberry_pi_m12_lens_adapter.pdf
Image
Last edited by rkinch on Thu Jun 13, 2013 7:43 am, edited 1 time in total.
User avatar
Posts: 68
Joined: Sun Jun 02, 2013 7:19 am
Location: Palm Beach County, Florida USA
by sharix » Sun Jun 02, 2013 12:06 pm
How much does it cost? Maybe sell it on ebay?
Posts: 177
Joined: Thu Feb 16, 2012 11:29 am
Location: Slovenia
by rkinch » Wed Jun 12, 2013 9:12 pm
Please order samples here:

http://www.truetex.com/order-rp12.htm
User avatar
Posts: 68
Joined: Sun Jun 02, 2013 7:19 am
Location: Palm Beach County, Florida USA
by dan3008 » Wed Jun 12, 2013 9:37 pm
Is there any chance you'll be selling the board and attachment pre-assembled?
I'm not quite confident enough to do it myself lol (that is to say, I dont think I've got a steady enough hand to remove the stock lens without braking something lol
dan3008 wrote:Pays your money, takes your choice
Posts: 950
Joined: Wed Aug 15, 2012 1:05 pm
by jbeale » Wed Jun 12, 2013 9:45 pm
Congrats, I am glad to see this option is available! I gather the M12 lens holder is indexed to two holes on the camera PCB, rather than the existing lens mount? I am wondering about using very short focal length M12 lenses with a back-focal distance small enough (few mm) that it would require removing the existing M6 lens housing from the sensor chip.
User avatar
Posts: 2121
Joined: Tue Nov 22, 2011 11:51 pm
by rleyden » Wed Jun 12, 2013 10:44 pm
Very nice adapter and $85 is quite reasonable for such for high quality machined aluminum.
However, I was hoping for something closer in price and materials to the camera and lenses (Ebay, made in China quality).

I used to have access to 3D printers through my work and have made camera adapters for my telescope. This part would simple and cheap were it not for the threads. No 3D printer that I'm aware of can directly print threads that fine. I thought that adding a metal insert might work but M12 x .5 nuts don't seem available. Tapping the plastic 3D printed part should be OK, if you pick the right material and are careful. It works best if you tap the threads immediately after removing the part from the machine.

Shapeways has a marketplace for such small parts but I don't know how they would handle tapping the threads.
User avatar
Posts: 59
Joined: Thu Jun 14, 2012 2:17 am
by jbeale » Thu Jun 13, 2013 1:29 am
Could you mate a 3D printed part with one of these? http://www.m12lenses.com/M12-Lens-Holders-s/61.htm
One of the "low profile" ones might work, or even just the M12 lock ring.
Obviously it would not be of the precision, alignment, durability etc. of a machined metal part.
User avatar
Posts: 2121
Joined: Tue Nov 22, 2011 11:51 pm
by rkinch » Thu Jun 13, 2013 5:03 am
dan3008 wrote:Is there any chance you'll be selling the board and attachment pre-assembled?

Yes, I can sell assemblies with a new camera module. For the moment I only have two extra camera modules on hand, and I hear they're not going to be available for another month or more.

The riskiest part of the installation is disassembling and removing the stock lens, which is indeed delicate. But if you're comfortable with that, then assembling the M12 adapter itself is trivial.

jbeale wrote:I gather the M12 lens holder is indexed to two holes on the camera PCB, rather than the existing lens mount?

Yes, correct.

jbeale wrote:I am wondering about using very short focal length M12 lenses with a back-focal distance small enough (few mm) that it would require removing the existing M6 lens housing from the sensor chip.

I optimized the adapter to fit the widest range of lens characteristics possible. I carefully analyzed the clearance available on the Raspi stock lens receptacle versus a list of mating thread engagements and back focal distances (bfd) on 49 different M12 lenses ranging in focal length from f=1.7mm to f=50mm. Engagement and bfd are not standardized so the lenses vary a lot in that regard. A common bfd is 6mm or 8mm, but some are as short as 3.3mm. The flange distance (that is, the length from the last thread toward the object, back to the focal plane) which governs the length of thread engagement also varies.

The minimum bfd the Raspi can take without whittling down the stock M6 receptacle is about 3.5mm, so the M12 lens must have a longer bfd for infinity focus. You can whittle down another 2.8mm at most before you hit the filter aperture, so the lower bfd limit is only 0.7mm if you're willing to whittle. The M12 adapter accepts M12 lenses directly with maximum bfd of 11.4mm, or anything longer if you use stock M12 extender tube(s). Minimum flange distance is 11.4mm, but this covers just about all lenses. So the practical range of M12 lenses is nearly universal.

rleyden wrote:This part would simple and cheap were it not for the threads. No 3D printer that I'm aware of can directly print threads that fine.

Get an M12x0.5 tap here: http://www.use-enco.com/CGI/INSRIT?PMAKA=319-5883 Or make your own tap by grinding flutes onto a (cheap throwaway but metal) lens. You'll want a tapping guide to get the threads started straight, but if you're printing 3D I suppose you can just print yourself one of those as well, while you're at it.
User avatar
Posts: 68
Joined: Sun Jun 02, 2013 7:19 am
Location: Palm Beach County, Florida USA
by rleyden » Thu Jun 13, 2013 8:20 pm
Could you mate a 3D printed part with one of these? http://www.m12lenses.com/M12-Lens-Holders-s/61.htm

jbeale-
Wow! Great link. I had no idea such a variety of lens holders were so readily available. Yes, using one those holders could be combined with a 3D printer part. If I were to go that route, I would need to order the holder first to get exact dimensions. However, I'm guessing a simple rectangular adapter plate might work, two holes to match the camera PCB and two holes to match the purchased lens holder. But, you may be way ahead of me. I noticed your reminder that the camera is only held in place by double sided tape. Perhaps you have an idea to make things even simpler. Could one re-position the plastic camera onto a plate that has holes for the new housing?

Get an M12x0.5 tap here: http://www.use-enco.com/CGI/INSRIT?PMAKA=319-5883 Or make your own tap by grinding flutes onto a (cheap throwaway but metal) lens.

rkinch- Thanks, good tips. Amazon has a tap that costs twice as much
User avatar
Posts: 59
Joined: Thu Jun 14, 2012 2:17 am
by rkinch » Thu Jun 13, 2013 9:31 pm
rleyden wrote:Could one re-position the plastic camera onto a plate that has holes for the new housing?

Several things about this prospective improvisation worth noting:

(1) The M12 inside thread minor diameter minimum is (happy accident!) just barely larger than the diagonal of the 8mm-sided square stock lens housing, so it will always clear it and fit over it. However you will have to nibble a bit of material off one side of the stock M12 holder to clear the flexible cable/connector (and possibly the SMD LEDs) on one side. This assumes there is height clearance inside the M12 receptacle of 5mm.

(2) The inside height clearance of the stock lens receptacle may interfere, as stock M12 lens holders typically have only enough inside height clearance to clear a thin camera chip or SOC, not to clear a relatively tall housing. The RPi stock lens receptacle is almost 5mm tall off the board and requires that much clearance. Of the few specimens of M12 stock receptacles I happen to have on hand, some provide this and some don't. But then if you're lifting the new receptacle with an adapter block, you'll be raising it so you can add more clearance. Maybe just snip off the vertical sides completely and use the top only with an improvised adapter. But if you're improvising to that degree you might as well improvise the whole receptacle and thread it.

(3) Why did the RPi designers choose a 21mm board hole spacing (unhappy accident?) when stock M12 lens holders come in 20mm and 22mm?
User avatar
Posts: 68
Joined: Sun Jun 02, 2013 7:19 am
Location: Palm Beach County, Florida USA
by jbeale » Thu Jun 13, 2013 9:41 pm
The camera module is on a very short leash, that tiny flex cable is not very long. You can't get rid of the existing camera PCB board (to any great distance anyway) so I think an adaptor plate as you mentioned is the most likely design.
User avatar
Posts: 2121
Joined: Tue Nov 22, 2011 11:51 pm
by mmiller » Thu Jun 13, 2013 11:09 pm
rleyden wrote:<snip>
However, I was hoping for something closer in price and materials to the camera and lenses (Ebay, made in China quality). </snip>


Here's the poor man's version costing less than £5
http://raspberrytorte.com/?p=54
http://wiki.raspberrytorte.com/index.ph ... odifcation
    Slowly spreading the joy the RaspberryPi way!
    http://raspberrytorte.com/ http://wiki.raspberrytorte.com https://github.com/raspberrytorte
User avatar
Posts: 22
Joined: Wed Nov 16, 2011 8:38 pm
by jbeale » Fri Jun 14, 2013 1:01 am
Wow mmiller, that's a great writeup! The full disassembly of the camera module is too scary for me at this point, with those fragile sensor wirebonds exposed, but I am curious what results you have had with your new M12 lens. I saw the pic of a bookshelf, have you posted any other example images anywhere?

In addition to color issues, removing the IR filter also causes the image to be blurry, because most lenses focus IR slightly differently than visible light (chromatic abberation). Some lenses are better than others (some state they are IR-corrected). In case of interest, many of the M12 lenses I have seen have IR filters included in the assembly, sometimes as an option. Using an external filter does make it easier to change in and out, though.
User avatar
Posts: 2121
Joined: Tue Nov 22, 2011 11:51 pm
by rleyden » Fri Jun 14, 2013 2:01 am
Here's the poor man's version costing less than £5

Truly inspirational. You should include the baling wire in your parts list :D . However, so many of my projects are wired together that I buy wire in bulk.
User avatar
Posts: 59
Joined: Thu Jun 14, 2012 2:17 am
by rkinch » Fri Jun 14, 2013 2:55 am

Nicely improvised, but why risk the destructive disassembly of the housing? All you need is to unscrew the lens. The M12 receptacle fits over the stock lens receptable. And this retains the IR filter, which you need.
User avatar
Posts: 68
Joined: Sun Jun 02, 2013 7:19 am
Location: Palm Beach County, Florida USA
by rkinch » Fri Jun 14, 2013 6:10 am
Here's a $6 (delivered!) solid cast zinc M12 board camera case I received from China today:

_.jpg
_.jpg (59.51 KiB) Viewed 16956 times


The Raspicam almost fits directly (if you moved the sticky-mount for the chip to center it on the board it would fit) or you could hacksaw/file/drill it to make a metal M12 receptacle you mount with screws and spacers.

Found at http://www.ebay.com/itm/150916166068
User avatar
Posts: 68
Joined: Sun Jun 02, 2013 7:19 am
Location: Palm Beach County, Florida USA
by htbwmedia » Fri Jun 14, 2013 7:40 am
Seeing the name M12 caught my attention as the Mobotix camera is one of the other reasons for my interest in pi. For those not familiar with Mobotix, they are a German ip camera (Kamerra) manufacturer who I have absolutely fallen in love with. So much so that my security alarm company, www.keepsafesystems.ca no longer installs the typical made in china cameras which have been a thorn in my side since giving up my "real job" and starting KeepSafe about 15 years ago. Aside from being rock solid in their architecture, Mobotix camera's are running on a Linux firmware. As is their free webcam software.

Check out the lenses at http://www.mobotix.com/eng_US/Products/ ... es-Sensors
KeepSafe is authorized to sell and install Mobotix camera's but does not do web sales. For that you can go to my side gig, www.alarmparts.ca
Yes, I I do need to focus :)

Cheers

Heinz
Cast your vote if you feel Eben Upton and the Raspberry Pi Foundation deserve a Nobel Prize for their work in creating an affordable education tool

http://www.loxone.org/eben%20upton%20raspberry%20pi%20nobel%20prize%20nomination%20vote
Posts: 22
Joined: Wed Jun 05, 2013 2:39 am
Location: Canada
by rkinch » Fri Jun 14, 2013 8:45 am
htbwmedia wrote:Seeing the name M12 caught my attention ...

I suspect you've confused the M12x0.5 threaded lenses we're discussing here with something else in your trade called "M12" that is unrelated.
User avatar
Posts: 68
Joined: Sun Jun 02, 2013 7:19 am
Location: Palm Beach County, Florida USA
by mmiller » Fri Jun 14, 2013 11:23 pm
rkinch wrote:

Nicely improvised, but why risk the destructive disassembly of the housing? All you need is to unscrew the lens. The M12 receptacle fits over the stock lens receptable. And this retains the IR filter, which you need.


I totally agree, removing the lens in the module is far less distructive, but I have some of the lenses I have are very fast and I didn't want to encounter vignetting on the casing.
Additionally, I wanted to remove the IR filter in order to fit a visible blocking filter and experiment with the 650-1000nm waveband.
Currently I do this with a modified lens cap, I also have a lens cap with a NIR blocking filter fitted.
    Slowly spreading the joy the RaspberryPi way!
    http://raspberrytorte.com/ http://wiki.raspberrytorte.com https://github.com/raspberrytorte
User avatar
Posts: 22
Joined: Wed Nov 16, 2011 8:38 pm
by mmiller » Sat Jun 15, 2013 12:04 am
jbeale wrote:have you posted any other example images anywhere?
.


I'm pleased with the results so far. High optical zoom / narrow field of view is easy to achieve (of course that comes are a price / reduction in depth of focus).
The following images are taken from the same place at roughly the same time and show the optical zoom with this lens (http://www.amazon.co.uk/dp/B006Z5C30E/).
http://wiki.raspberrytorte.com/index.ph ... 02test.jpg
http://wiki.raspberrytorte.com/index.ph ... 01test.jpg

Issues to date. with the NIR filter removed I observed some increased background / whiteout in high light conditions. This may be a stray light / scatter or white balance.

Your concerns regarding the arrays sensitivity to damage is valid.
Once exposed the device is a magnet for dust and the surface is extremely delicate (can you see where I tested that with a screwdriver tip!
Unscrewing the lens and retaining the module housing and NIR filter is a good compromise if you don't intend to fit your own wide angle lens.
    Slowly spreading the joy the RaspberryPi way!
    http://raspberrytorte.com/ http://wiki.raspberrytorte.com https://github.com/raspberrytorte
User avatar
Posts: 22
Joined: Wed Nov 16, 2011 8:38 pm
by rkinch » Sat Jun 15, 2013 4:11 am
mmiller wrote:... some of the lenses I have are very fast and I didn't want to encounter vignetting on the casing.

That typically won't happen because digital camera lenses should be designed with very different front vs back focal lengths, because digital sensors limit incoming ray angles. Even very short focal length M12 lenses have a small exit aperture that won't be stopped by the leaving the stock M6 receptacle in place. Consider how you can have a f=2.2mm lens with a 4.8mm back focal distance, like the Edmund 55569:(http://www.edmundoptics.com/imaging/imaging-lenses/micro-video-lenses/infinite-conjugate-micro-video-imaging-lenses/55569)
User avatar
Posts: 68
Joined: Sun Jun 02, 2013 7:19 am
Location: Palm Beach County, Florida USA
by mmiller » Sat Jun 15, 2013 9:32 am
rkinch wrote:Consider how you can have a f=2.2mm lens with a 4.8mm back focal distance

I've got some more lenses and camera modules on order so I'll give this a shot.
    Slowly spreading the joy the RaspberryPi way!
    http://raspberrytorte.com/ http://wiki.raspberrytorte.com https://github.com/raspberrytorte
User avatar
Posts: 22
Joined: Wed Nov 16, 2011 8:38 pm
by mmiller » Sat Jun 22, 2013 11:51 pm
Following the earlier advise in this thread, the wiki article has been updated to include the much simpler mod that retains the original near IR blocking filter.

This results in the following
Image

Which allows for very easy exchange of lenses to adjust field of view. This is my latest 16mm F1.2 lens.
Image
    Slowly spreading the joy the RaspberryPi way!
    http://raspberrytorte.com/ http://wiki.raspberrytorte.com https://github.com/raspberrytorte
User avatar
Posts: 22
Joined: Wed Nov 16, 2011 8:38 pm
by jbeale » Sun Jun 23, 2013 5:45 am
Thanks for the update! I'd be curious to see a sample image from that lens, as well. At that f-stop and focal length, I am guessing there is a lot less depth of field than with the stock lens.
User avatar
Posts: 2121
Joined: Tue Nov 22, 2011 11:51 pm
by mmiller » Sun Jun 23, 2013 10:10 am
you are correct, depth of field is pushed out substantially.
I used http://www.dofmaster.com/dofjs.html to assess this before buying the lens.
Image
I'm using this for a project scanning number plates on passing cars entering my street so i'm operating at longer range (>30m ) and its more light that i want.

I'm still trying to perfect the focusing method but here's a couple of examples.
A snap taken at night (about 2am) with -night enabled whilst testing sixbacons GUI.http://www.raspberrypi.org/phpBB3/viewtopic.php?p=374577#p374577
Image
http://wiki.raspberrytorte.com/images/thumb/5/5a/TestImageNight.jpg/1280px-TestImageNight.jpg
and another taken a few minutes ago.
Image
http://wiki.raspberrytorte.com/images/thumb/5/56/ImageSnapshotEFL16mmF1.2.jpg/1280px-ImageSnapshotEFL16mmF1.2.jpg
There are clear area of the image that are out of focus, some of which shouldn't be, I'll work iwhats wrong later.
    Slowly spreading the joy the RaspberryPi way!
    http://raspberrytorte.com/ http://wiki.raspberrytorte.com https://github.com/raspberrytorte
User avatar
Posts: 22
Joined: Wed Nov 16, 2011 8:38 pm