Camera with Macro focus


10 posts
by starcraft04 » Wed Nov 13, 2013 7:42 pm
Hi all,

I need to have my raspberry to be able to take picture of text from 5 cm max. I tried the camera board 5M but the image is so blurry at 5 cm.

Do you know if there is any other camera available and supported on the raspberry pi?

Many thanks for the help,

John.
Posts: 20
Joined: Wed Mar 06, 2013 3:50 pm
by Zamzara » Wed Nov 13, 2013 7:59 pm
Posts: 9
Joined: Fri Nov 08, 2013 12:46 pm
by jbeale » Wed Nov 13, 2013 9:33 pm
Just put an external lens with focal length 5 cm in front of the camera. A small loupe might work for this, you probably want something like a 5x or 10x loupe.

You can buy cheap ("second" quality) plano-convex (PCX) lenses for $4 each from a place like http://www.surplusshed.com/lens.cfm
I have done this and it works, but be aware that your focal plane will not be exactly flat. In other words when you have good focus at the center of the image, the edges will be a little blurry, and vice-versa.

Another possibility is to (carefully) break the glue around the edge of the tiny lens on the camera and gently unscrew it so that it focuses closer: http://elinux.org/Rpi_Camera_Module#Adj ... Lens_Focus
If you unscrew the lens more than one full turn, it will come off (exposing the IR filter over the sensor, inviting dust trouble). About the closest you can get this way is about 6 cm.
User avatar
Posts: 2098
Joined: Tue Nov 22, 2011 11:51 pm
by starcraft04 » Wed Nov 13, 2013 10:47 pm
Many thanks for your help, I will give it a try.

John.
Posts: 20
Joined: Wed Mar 06, 2013 3:50 pm
by starcraft04 » Thu Nov 14, 2013 12:52 pm
jbeale wrote:Just put an external lens with focal length 5 cm in front of the camera. A small loupe might work for this, you probably want something like a 5x or 10x loupe.

You can buy cheap ("second" quality) plano-convex (PCX) lenses for $4 each from a place like http://www.surplusshed.com/lens.cfm
I have done this and it works, but be aware that your focal plane will not be exactly flat. In other words when you have good focus at the center of the image, the edges will be a little blurry, and vice-versa.

Another possibility is to (carefully) break the glue around the edge of the tiny lens on the camera and gently unscrew it so that it focuses closer: http://elinux.org/Rpi_Camera_Module#Adj ... Lens_Focus
If you unscrew the lens more than one full turn, it will come off (exposing the IR filter over the sensor, inviting dust trouble). About the closest you can get this way is about 6 cm.


Hi,

I have broken the glue as stated but I can't make it turn. Can someone explain me how to turn the lens so that I can achieve a macro focus. I tried to turn it but I was afraid the whole camera was going to come out of the board hence break. Is there a video or set of photo showing how to turn the lens to get to macro focus?

Many thanks,

John.
Posts: 20
Joined: Wed Mar 06, 2013 3:50 pm
by jbeale » Thu Nov 14, 2013 5:07 pm
The small black camera module is attached to the camera board only with a fairly weak adhesive, it seems like a small dot of silicone rubber. If it comes off you can stick it back on without anything necessarily being harmed. Some people prefer to remove the camera module from the PCB entirely to work on it (the tiny flex cable has a connector marked "SUNY" which comes out of the board- be careful as it seems fragile). There is no electrical connection direct to the board underneath the camera module, that's just glue. The electrical signals are only through the small yellow ribbon cable.

What I did was use one pair of pliers to hold the camera body (not the PCB) and use another set of fine needle-nose pliers to unscrew the lens, slowly, bit by bit. The threaded lens cell is plastic and you will have to grip it hard enough that the pliers will leave some dents. One person suggests pressing a rubber stopper against the top of the lens to turn it instead, avoiding the pliers marring the plastic (although it's just a cosmetic issue). I did not attempt that.
User avatar
Posts: 2098
Joined: Tue Nov 22, 2011 11:51 pm
by starcraft04 » Thu Nov 14, 2013 5:38 pm
Oh man you saved me. I managed to get it turn thanks to your advices and I now can take pictures with good quality very close (5 cm).

I have 2 more questions then I stop :)
- Is it possible to decrease a bit the quality of the picture to get smaller file size?
- The Raspberry Pi Camera Module is an Omnivision camera. Can I use other Omnivision camera like the 0.3 pixel one (OV 7670) connect it at the same place and use the same libraries, functions (raspistill) or will it not work? I say this because they have a lot of other cameras with auto focus, macro focus, ...

Many thanks,

John.
Posts: 20
Joined: Wed Mar 06, 2013 3:50 pm
by jbeale » Thu Nov 14, 2013 5:56 pm
starcraft04 wrote:- Is it possible to decrease a bit the quality of the picture to get smaller file size?
- The Raspberry Pi Camera Module is an Omnivision camera. Can I use other Omnivision camera like the 0.3 pixel one (OV 7670) connect it at the same place and use the same libraries, functions (raspistill) or will it not work?

Great you got it to work. If your lens is unscrewd to focus around 5 cm it is probably almost falling out- might want to secure it with a bit of glue or something. Just don't get that on the front of the lens of course :-)

Yes, you can adjust file size with the -q or --quality setting, it goes from 0 to 100. Type 'raspistill' with no options to see a help list.
Code: Select all
$ raspistill -q 50 -o test1.jpg
$ raspistill -q 25 -o test2.jpg
$ raspistill -q 5 -o test3.jpg
$ ls -al *.jpg
-rw-r--r-- 1 pi pi 1996313 Nov 14 09:54 test1.jpg
-rw-r--r-- 1 pi pi 1095808 Nov 14 09:55 test2.jpg
-rw-r--r-- 1 pi pi  137203 Nov 14 09:55 test3.jpg


as far as I know you cannot simply plug in any other module.
User avatar
Posts: 2098
Joined: Tue Nov 22, 2011 11:51 pm
by starcraft04 » Thu Nov 14, 2013 6:26 pm
Great.

Many thanks for all the help, project is going on now :).

Thanks and have a nice day,

John.
Posts: 20
Joined: Wed Mar 06, 2013 3:50 pm
by jbeale » Fri Nov 15, 2013 1:05 am
I decided to find out how far I could go without any additional lens. I put two matching dots on the lens and lens housing, to track where I was, and unscrewed the lens 2 full turns. Not all that turning probably had effect, at 2 turns it was loose, wobbly and ready to fall out. Anyway I glued it in place in that position and took a picture using raspistill at full frame. The horizontal field of view was just about 2 cm and I measure the focal distance as 25 mm from the front surface of the lens. And as you see, stuff in your desk drawer looks really dusty at this magnification. Also things get a little blurry at the corners of the frame. The full frame image is 2592 pixels across, so this is a scale of roughly 10 microns per pixel.

https://picasaweb.google.com/lh/photo/q ... directlink
Image

https://picasaweb.google.com/lh/photo/d ... directlink
Image
User avatar
Posts: 2098
Joined: Tue Nov 22, 2011 11:51 pm