User avatar
Posts: 204
Joined: Mon Nov 10, 2014 7:39 pm
Location: Coquille OR
Contact: Website

Can one do serious work with this camera?

Thu Aug 13, 2015 9:11 pm

I ran into many serious obstacles trying to use the RPi camera.
Writeup for the MMAL library is hopeless, but somehow the v4l2 driver is based on MMAL (I think). But the v4l2 driver cannot give you a preview window with arbitrary location and size because it does not implement VIDIOC_CROPCAP, VIDIOC_G_CROP and VIDIOC_S_CROP. So you can't make a program using the v4l2 driver that shows you a preview while you still have realistic usability of the rest of your interface. And you can't make it by calling MMAL functions directly because you can't figure out how that works.
Is there any chance of getting progress on those issues in the near future?
A more general issue is the sensor-- it's tiny, and therefore not very sensitive. For scientific work one may want something much better, as has been pointed out in other posts. Are there any other sensors that can be connected to that bus?
That bus connection is fairly fragile and it requires the camera to be pretty close to the computer. This could be a problem in many applications.
USB cameras might overcome some of these limitations, although they suffer from not having access to the GPU the way the RPi camera does. Should the foundation back off promoting the RPi camera, and steer people toward USB or web connected solutions?

Posts: 6166
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Can one do serious work with this camera?

Thu Aug 13, 2015 9:29 pm

What do you expect? Cameras for industrial or even scientific use cost many hundred dollars, together with a good lens often more than 1000.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6091
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Can one do serious work with this camera?

Thu Aug 13, 2015 10:25 pm

Although I am all for more rugged connector, fancier sensors, better documentation and a pony; I can't agree with the overall conclusion of your post.

If you think the foundation or broadcom is to blame for not providing enough documentation, you are welcome to try out OpenMAX. OpenMAX is documented rather thoroughly and MMAL is just a simplified interface to OpenMAX. You have tools like raspivid and the v4l driver to cover the needs of 95% of raspberry pi users, but to go beyond that, you need to put in the work. Maybe that's why we have engineers... not everybody has the time or desire to do the more complicate things themselves.

I'm far from the sharpest tool in the shed, so if I can use MMAL to get something done, anyone can. We only skimmed through a tiny bit of programming in my uni course and I didn't play with it too much in my free time. I am very much a below average programmer (at least while I am in Cambridge). It takes time and effort, but not everything can be hidden behind a nice python library (although a huge thumbs up to Dave for picamera). You just need to take a step back and focus on the specific parts you're struggling with. I don't remember if it was you or somebody else, but they had trouble with MMAL because they didn't know about basic concepts, which weren't specific to MMAL; like buffers, pools and threads. Neither did I, so that was where I started. Luckily, there's lots of example code. If you can get through raspicam and understand how it works, then you're halfway there. If you're struggling after that, it's probably not MMAL that's causing problems.

Or maybe it's just a matter of breaking down the problem into smaller pieces. Take a very small piece of the puzzle and solve it. Keep going until you know how to put it all together. If you get stuck, post a short testcase and a description of what you expect to happen and what actually happens.

Conceptually, MMAL is quite simple. You have different blocks, you hook them up and out comes the thing you want. The trick is figuring out what you want, how to hook up the blocks and what the limitations are. The rest is juggling the data in the right way, which again, isn't MMAL specific.

Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7708
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Can one do serious work with this camera?

Fri Aug 14, 2015 1:54 pm

I'll accept that there are some omissions from the MMAL docs, but there are also a large number of examples, and the principles are pretty straight forward. As ShiftPlusOne says, feel free to use the fully documented OpenMaxIL implementation, and you'll soon find that documentation doesn't help if it is a dog of an API.

You want an arbitrary location for the overlay window on your screen via V4L2 - most of the hooks appear to be there but just not fully plumbed. ... era.c#L668 is where you should be looking - feel free to fix it up and create a pull request. (I think the stumbling point when others looked into this may have been trying to clip the region to keep it on the screen when you don't know what the screen resolution is. The GPU doesn't actually care, so it should be safe to just ignore that requirement, unless it causes a conformance test failure)
As it happens, I'm fairly certain that you're looking at the wrong IOCTLs too - VIDIOC_S_FMT looks more likely, as used by v4l2-ctl --set-fmt-overlay. AIUI VIDIOC_[CROPCAP|G_CROP|S_CROP] set up cropping of the captured image before display (ie digital zoom equivalent), not where it is displayed. Let's not let that get in the way of a good rant though.

Yes, it's a small sensor - you aren't going to get a DSLR for the price. Even so, many have got pretty incredible results with it though for things like star trails, and other astronomical uses.
If you're such a hot-shot programmer, then make use of viewtopic.php?f=43&t=109137 Just don't complain when you find out just how much image processing goes on within that little GPU, and that it gets really hard.
How many USB webcams can you buy that fulfill all your criteria and yet only cost £25? I suspect it is a very short list. And how many can do 108P30 H264 encoding, high frame rate modes, and provide you with fairly comprehensive access into the image processing pipe and settings? I suspect none.

So it doesn't quite fulfill your criteria - use something that does then. The Pi Camera works for a very large proportion of the Pi community and at a price that most can afford. My Pi can't run full scale weather predictions in the way that the Met Office can, so perhaps the Foundation ought to recommend IBM supercomputers and drop the Pi altogether. Shame I can't stretch to the £97million budget, and a couple of megawatts of power.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
Posts: 315
Joined: Mon Sep 23, 2013 1:28 pm
Location: Manchester, UK

Re: Can one do serious work with this camera?

Sun Aug 23, 2015 10:51 pm

I'd add my 2 cents, but 6by9's pointed out everything I possibly could and a whole load besides.

Okay, here's 1 cents worth: sure, the MMAL docs aren't perfect, but between them and the raspistill/raspivid source code I cobbled together the first version of picamera in a weekend. Preview positioning didn't take much longer (it's a while longer than that in the code history, but then I was figuring out plenty of other things in the meantime - documentation, test suites, packaging, etc. etc.).

To succinctly answer the question in your subject: yes, you can do serious work with the camera. I've had the privilege of working with a couple of university based teams on camera projects now; provided you understand it's got a 5Mp resolution limit, that video recording tops out at 1080p, etc. (in other words, provided you understand it's not a 900 quid DSLR) it'll most likely fulfil your criteria. It may require some effort on your part to do so, but that's hardly surprising given the price point.


Return to “Camera board”