Respectech
Posts: 53
Joined: Sat Sep 29, 2012 12:27 am

Working Fisheye Lens?

Mon May 20, 2013 8:05 pm

I ordered a fisheye lens for cell phone cameras. I tried it with the front and rear cameras on my Motorola Electrify 2, and it worked great on both of them. On the front-facing camera, it was close to 180 degrees, but on the rear-facing camera it was more like 90 degrees (because the rear-facing camera is back-set from the glass). Both had very clear images.

However, when I try to use it with the Raspberry Pi Camera Module, it is very blurry. On top of that, it only covers 90 degrees even though I have the fisheye lens as close to the Module's lens as possible.

Would it be likely that it would work better if I removed the camera module's lens? Or should I screw in or out the camera module's lens? I'm hesitant to remove the lens if not necessary because I don't want to take the chance of getting dust on the sensor.

Has anyone gotten a fisheye lens to work with the camera module? If so, what brand and model?

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: Working Fisheye Lens?

Mon May 20, 2013 8:15 pm

I understand you have an add-on lens for a cell phone camera where the original lens stays on the sensor. That's like a pair of reading glasses (but then fisheye). If you put a lens like that in front of a sensor directly you don't get an image; you'll need a 'real' lens too.

User avatar
jbeale
Posts: 3438
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Working Fisheye Lens?

Mon May 20, 2013 8:45 pm

We believe the R-Pi camera is currently using a 1440x1080 crop of the full 2592 x 1944 pixel array when used in stills mode (not proven, but strongly suspected by several independent measures). That means you are likely seeing about 55% of the possible field of view both horizontally and vertically in you stills. If true, and if this is a software configuration error that can be fixed, you would be able to see an image with 1.8x wider field of view than you see now, with updated software. Again, yet to be proven.

As far as the image being fuzzy, I assume that is a limitation of the combined lenses you are using. If you are trying to make a close-up image, remember the R-Pi camera module is supplied with a fixed-focus lens set at infinity, anything closer than about 1 meter becomes blurry. If you scrape off the epoxy and unscrew the lens some distance you can set the focus point closer (and then of course, far objects become blurry). Your wide-angle accessory lens must be used in combination with an existing lens, and will not focus when used stand-alone. If you were willing to do a very hazardous surgery* on your camera, you might be able to substitute a completely different lens such as one of these: http://www.optics-online.com/dsl_quarter.asp
For example the $99 Sunex DSL218 lens offers a full 180 degree (horizontal) field of view with a 1/4" format sensor like the R-Pi's camera has. You would have to figure out how to mount it yourself, though. http://www.optics-online.com/OOL/DSL/DSL218.PDF

* two people have done this so far; both cameras initially worked afterwards, and then died due to mechanical contact to the extremely fragile, exposed wirebonds on the sensor chip.

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: Working Fisheye Lens?

Mon May 20, 2013 8:56 pm

jbeale wrote:We believe the R-Pi camera is currently using a 1440x1080 crop of the full 2592 x 1944 pixel array when used in stills mode (not proven, but strongly suspected by several independent measures). That means you are likely seeing about 55% of the possible field of view both horizontally and vertically.
My idea on this is that the 2592 pixels are downscaled to 1920 for video and the still function uses 1440 of these video pixels to get the standard still image. These are then upscaled to 2592 for the saved still image. that would mean the OP sees 75% of the possible field of view. If he would give the

Code: Select all

raspistill -hf -o image3456.jpg -w 3456
command he would get 100% of the possible width. Still guessing of course.

User avatar
jbeale
Posts: 3438
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Working Fisheye Lens?

Mon May 20, 2013 9:15 pm

If someone who has unscrewed the lens can measure the focal length of the lens directly, we could figure out from the observed angle of view of the camera, how much sensor width is actually being used.
One way would be to make your own simple projection camera, mounting the lens on a small tube of cardboard etc. with a piece of thin tracing paper in back and adjusting the lens distance until it is in focus. Then look at the image and see where the boundaries are matching the field of view as recorded by the camera. Then compare that to the known sensor size of 3.67 x 2.74 mm.

Quasim0ndo
Posts: 14
Joined: Fri May 17, 2013 1:43 pm

Re: Working Fisheye Lens?

Tue May 21, 2013 10:21 am

I've built me a body that allows to attach my Lensbaby accessories - works nicely:
Image

User avatar
recantha2
Posts: 277
Joined: Wed Nov 14, 2012 9:34 am
Location: Potton, Bedfordshire
Contact: Website

Re: Working Fisheye Lens?

Tue May 21, 2013 10:37 am

Hackilicious, Quas. :-D
--
Michael Horne - @recantha
Raspberry Pi blog - http://www.recantha.co.uk/blog

Cambridge Raspberry Jam
Website: http://camjam.me
Facebook: https://www.facebook.com/cambridgeraspberryjam
Follow the Cambridge Raspberry Jam on Twitter - @cambridgejam

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 22715
Joined: Sat Jul 30, 2011 7:41 pm

Re: Working Fisheye Lens?

Tue May 21, 2013 10:51 am

poing wrote:
jbeale wrote:We believe the R-Pi camera is currently using a 1440x1080 crop of the full 2592 x 1944 pixel array when used in stills mode (not proven, but strongly suspected by several independent measures). That means you are likely seeing about 55% of the possible field of view both horizontally and vertically.
My idea on this is that the 2592 pixels are downscaled to 1920 for video and the still function uses 1440 of these video pixels to get the standard still image. These are then upscaled to 2592 for the saved still image. that would mean the OP sees 75% of the possible field of view. If he would give the

Code: Select all

raspistill -hf -o image3456.jpg -w 3456
command he would get 100% of the possible width. Still guessing of course.
That's not how it works. We define camera modes in the driver - there are two currently defined - a full res mode and a 1080p mode.

The camera component in OpenMAX provides 3 ports as output - a preview port, a capture port and a video port.

Preview should be using the 1080p mode, as should video as this mode is the on;y one capable of 30fps, but capture should use the full mode (max 15 fps but not possible to acheive that in the Raspi as too fast). It may be that the capture port is inadvertently using the 1080p mode and scaling it up to match the user requested resolution.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: Working Fisheye Lens?

Tue May 21, 2013 12:03 pm

jamesh wrote:
poing wrote:
jbeale wrote:We believe the R-Pi camera is currently using a 1440x1080 crop of the full 2592 x 1944 pixel array when used in stills mode (not proven, but strongly suspected by several independent measures). That means you are likely seeing about 55% of the possible field of view both horizontally and vertically.
My idea on this is that the 2592 pixels are downscaled to 1920 for video and the still function uses 1440 of these video pixels to get the standard still image. These are then upscaled to 2592 for the saved still image. that would mean the OP sees 75% of the possible field of view. If he would give the

Code: Select all

raspistill -hf -o image3456.jpg -w 3456
command he would get 100% of the possible width. Still guessing of course.
That's not how it works. We define camera modes in the driver - there are two currently defined - a full res mode and a 1080p mode.

The camera component in OpenMAX provides 3 ports as output - a preview port, a capture port and a video port.

Preview should be using the 1080p mode, as should video as this mode is the on;y one capable of 30fps, but capture should use the full mode (max 15 fps but not possible to acheive that in the Raspi as too fast). It may be that the capture port is inadvertently using the 1080p mode and scaling it up to match the user requested resolution.
Thanks for the clarification although that comes down to what I meant, only the 1080p is derived directly from the camera. Still it must use the whole width of the sensor for 1080p and because 1920 x 2 > 2592 you can't use every other pixel but you must use down scaling?

BTW I took the same image as I did earlier with the PiCamera but now with my 5MP Samsung Nexus S camera and the results are very much the same in terms of detail, although the Samsung has a wider field of view. Very curious what the full resolution still will look like with new firmware and even more when a proper lens is mounted.

User avatar
jbeale
Posts: 3438
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Working Fisheye Lens?

Tue May 21, 2013 2:30 pm

Still it must use the whole width of the sensor for 1080p
I don't think we can take that as a given; I am aware of some devices with still and video modes, where the horizontal field of view changes between modes. At any rate, I suspect any rescaling would happen on the external control device (GPU in this case), not internal to the camera module. So that should be known to, and under control of the GPU firmware.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 22715
Joined: Sat Jul 30, 2011 7:41 pm

Re: Working Fisheye Lens?

Tue May 21, 2013 2:36 pm

jbeale wrote:
Still it must use the whole width of the sensor for 1080p
I don't think we can take that as a given; I am aware of some devices with still and video modes, where the horizontal field of view changes between modes. At any rate, I suspect any rescaling would happen on the external control device (GPU in this case), not internal to the camera module. So that should be known to, and under control of the GPU firmware.
Correct. You cannot assume that its using the whole of the sensor when you are not in full frame mode. We may need to crop in any aspect to get the numbers to work out. Not by much usually though.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: Working Fisheye Lens?

Tue May 21, 2013 2:51 pm

OK, I have no clue about the workings of these devices, but my Samsung phone (similar 5MP sensor) gives the same field of view with stills and video. If one of the modes of the PiCamera does not use the whole sensor width the field of view must change.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 22715
Joined: Sat Jul 30, 2011 7:41 pm

Re: Working Fisheye Lens?

Tue May 21, 2013 3:01 pm

poing wrote:OK, I have no clue about the workings of these devices, but my Samsung phone (similar 5MP sensor) gives the same field of view with stills and video. If one of the modes of the PiCamera does not use the whole sensor width the field of view must change.
Correct. It will depend on the sensor and its resolution. I'm trying to find time to find out what's going on in the driver wrt this stills capture.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 22715
Joined: Sat Jul 30, 2011 7:41 pm

Re: Working Fisheye Lens?

Tue May 21, 2013 3:22 pm

OK, think I have capture using the full sensor now (wasn't me - found someone who knew what they were talking about who spotted a missing flag in the camera modes), but there is a big mismatch between the preview and the capture (since the preview is using 1080p mode which heavily crops the sensor). I'll talk to the aforementioned expert experts to see what we can do.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

User avatar
leol
Posts: 147
Joined: Fri Jan 13, 2012 4:27 pm
Location: Haute-Vienne, France

Re: Working Fisheye Lens?

Tue May 21, 2013 3:56 pm

Great stuff James. Very grateful for your hard work.

Leo
Last edited by leol on Tue May 21, 2013 4:13 pm, edited 1 time in total.

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: Working Fisheye Lens?

Tue May 21, 2013 3:58 pm

leol wrote:Great stuff James. Very grateful for you hard work.

Leo
+1

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Working Fisheye Lens?

Tue May 21, 2013 4:20 pm

Respectech wrote: Has anyone gotten a fisheye lens to work with the camera module? If so, what brand and model?
To answer your question, I haven't seen any mention yet of proper fisheye adaptors. Only one person I've seen so far has mentioned an actual wide angle:

http://www.raspberrypi.org/phpBB3/viewt ... 75#p351175

No idea if the quality's any good though. I suspect the problem with yours (blurriness) is caused by being unable to get the right lens spacing, or maybe the acceptance angle at the raspi's lens isn't wide enough. In theory you should not need to remove or move the raspi's lens for it to work.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 22715
Joined: Sat Jul 30, 2011 7:41 pm

Re: Working Fisheye Lens?

Tue May 21, 2013 4:25 pm

jamesh wrote:OK, think I have capture using the full sensor now (wasn't me - found someone who knew what they were talking about who spotted a missing flag in the camera modes), but there is a big mismatch between the preview and the capture (since the preview is using 1080p mode which heavily crops the sensor). I'll talk to the aforementioned expert experts to see what we can do.
We do have some work to do here. The 1080p mode uses a 1920x1080 window in the middle of the sensor, so loses a lot top/bottom/left/right. This gives pixel resolution, but looses some FOV. It also means the preview doesn't match the capture. So I need to generate a new camera mode that uses the whole sensor. BUT that cannot run at 30fps, so I need to 2x2 bin the sensor data to get 1296x972, then that will be scaled up to the required preview for capture resolution.

All good clean fun. Currently trying to figure out the timing registers for the sensor.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

User avatar
jbeale
Posts: 3438
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Working Fisheye Lens?

Tue May 21, 2013 4:46 pm

jamesh wrote:We do have some work to do here. The 1080p mode uses a 1920x1080 window in the middle of the sensor, so loses a lot top/bottom/left/right. This gives pixel resolution, but looses some FOV. It also means the preview doesn't match the capture. So I need to generate a new camera mode that uses the whole sensor. BUT that cannot run at 30fps, so I need to 2x2 bin the sensor data to get 1296x972, then that will be scaled up to the required preview for capture resolution.
All good clean fun. Currently trying to figure out the timing registers for the sensor.
Great to read of this progress. I look forward to seeing the sensor in its full-resolution glory- we are all rooting for you JamesH!

I will attempt to avoid enquiring about the possibility of recording full-sensor 4:3 video with 2x2 binned 1296x972 resolution. For a short while at least :-).

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 22715
Joined: Sat Jul 30, 2011 7:41 pm

Re: Working Fisheye Lens?

Tue May 21, 2013 5:00 pm

jbeale wrote:
jamesh wrote:We do have some work to do here. The 1080p mode uses a 1920x1080 window in the middle of the sensor, so loses a lot top/bottom/left/right. This gives pixel resolution, but looses some FOV. It also means the preview doesn't match the capture. So I need to generate a new camera mode that uses the whole sensor. BUT that cannot run at 30fps, so I need to 2x2 bin the sensor data to get 1296x972, then that will be scaled up to the required preview for capture resolution.
All good clean fun. Currently trying to figure out the timing registers for the sensor.
Great to read of this progress. I look forward to seeing the sensor in its full-resolution glory- we are all rooting for you JamesH!

I will attempt to avoid enquiring about the possibility of recording full-sensor 4:3 video with 2x2 binned 1296x972 resolution. For a short while at least :-).
I'd need to check but I think if you specifically requested that resolution it would pick the closest mode, which would be the one I can't quite get working right now...!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Working Fisheye Lens?

Tue May 21, 2013 7:35 pm

Quasim0ndo wrote:I've built me a body that allows to attach my Lensbaby accessories - works nicely:
Looks good!

My phone camera lenses arrived today and my lens mount doesn't look quite so good!

Image

User avatar
recantha2
Posts: 277
Joined: Wed Nov 14, 2012 9:34 am
Location: Potton, Bedfordshire
Contact: Website

Re: Working Fisheye Lens?

Tue May 21, 2013 7:42 pm

@LeoWhite Now THAT'S a lens mount. LOL
--
Michael Horne - @recantha
Raspberry Pi blog - http://www.recantha.co.uk/blog

Cambridge Raspberry Jam
Website: http://camjam.me
Facebook: https://www.facebook.com/cambridgeraspberryjam
Follow the Cambridge Raspberry Jam on Twitter - @cambridgejam

LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Working Fisheye Lens?

Tue May 21, 2013 8:00 pm

recantha2 wrote:@LeoWhite Now THAT'S a lens mount. LOL
and its driven by the Raspberry Pi itself!

Couldn't get it into exactly the position I wanted as I was running out of room on the window sill. Might need to investigate getting a longer cable too.

Using the wide angled lens adaptor at the moment, certainly gives a larger view but the image is not as bright/crisp, which is pretty much to be expected!

Leo

Quasim0ndo
Posts: 14
Joined: Fri May 17, 2013 1:43 pm

Re: Working Fisheye Lens?

Tue May 21, 2013 9:58 pm

LeoWhite wrote:
My phone camera lenses arrived today and my lens mount doesn't look quite so good!
Ah sweet! Well, robot arm beats laser for sure.

LeoWhite
Posts: 131
Joined: Mon Apr 08, 2013 9:20 am
Contact: Website

Re: Working Fisheye Lens?

Wed May 22, 2013 7:41 am

Quasim0ndo wrote:
LeoWhite wrote:
My phone camera lenses arrived today and my lens mount doesn't look quite so good!
Ah sweet! Well, robot arm beats laser for sure.
Hmm, robot arms with lasers maybe? :)

Return to “Camera board”