2

With disastrous results expected, I configured Raspbian with no GUI (all memory to the system) with LAMP, Webmin, and Samba. It works very well albeit slower than my dual core LAMP, and Webmin shows Real memory 438.26 MB total, 78.43 MB used. It is stable too. It has been on for days snapping images with the camera, and I still get greeted with Login via putty. =)

I want to write a web app that allows me interactive control of the camera (Raspberry Pi Camera Module) through a web interface, but here is where I got stuck. I know PHP, but new to python, perl, etc. I looked at frameworks but I am new to them too, as well as CGI.

So I am looking for direction for sure. A path to follow. There seems to be a wide diversity available on this subject and I am not sure which path to follow. I absolutely do not mind learning a new language if needed, I just do not know where to start.

I suppose I could write it in PHP, researching all the ways to execute CLI from PHP and read the results, but I have seen on youtube and read here and other forums about so many other wonderful ways to interact with my Raspbian via code in a web interface.

I hope someone posts a link, suggest a framework, a language, that will open up some doors for me.

I sincerely thank you for your time!

Hop

EDIT: Camera I use is the Raspberry Pi Camera Module

  • How are you controlling the camera now? Through a command line utility? Does the camera also have an API for controlling it? If so, what languages does it support? – Doug Richardson Aug 25 '13 at 1:29
  • Yes, I am using raspistill. I am unaware of an API yet. – HopWorks Aug 25 '13 at 18:47
1

As Doug Richardson hints, what you ideally want to do is access the camera programmatically as opposed to making system() type calls controlling a CLI application. The advantage of this is it is more flexible: for example, if any interaction or feedback is required, controlling an external application requires pipes -- much less awkward would be a set of functions you could call from your own code, with parameters and different return types to do different things. This is what an application programming interface (API) is; very commonly on open source platforms like linux, if you have a CLI utility that does something, it is built using a library which contains the API, and you can use that same library to do the same things as the CLI tool, via the same function calls that the tool itself uses internally.

You don't mention much about the camera you are using. Is it connected via USB or MIPI/CSI? If the former, there will certainly be an API available in C and possibly python and perl as well. I believe since PHP developed primarily as a web programming language it lacks in this realm (but who knows?).

In the end what you are doing with the camera may be so simple that this is not all that necessary, but it is still worth looking into, or at least being aware of, since it is API's and protocols that govern the interaction of the various parts of the system (and as a programmer, it benefits you to know about them). It may also be that at this time the API is inaccessible to you -- e.g., if it is only in C, I think you have two choices, write an apache module (requires you learn C and the Apache C API), or port the library to python or php by writing a module for them (python and php modules can be written in C, meaning you've exported the C interface into another language; the same thing applies to perl, ruby, java, etc. -- if you have a C lib, it can be translated directly into any other language on the system via that language's C API), which requires you learn C and have a strong grasp of the other language. Depending on your time (read: it will take a lot) and interests, these may or may not be options for you.

1

If I wanted to make a web api controllable raspberry pi camera, I'd:

  1. Study the RaspiStill.c source code. Apparently it uses OpenMAX to control the camera.
  2. Install the nginx http server on my raspberry pi
  3. Write a FastCGI module in C
  4. Configure nginx to use the FastCGI module I just wrote.

The FastCGI module will handle the requests and then perform operations on the camera. I have a simple FastCGI example here, though it was written for OS X so you'll have to make a few changes before compiling it on linux.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.