How to control camera module from C++


10 posts
by dadosebo » Tue Jun 18, 2013 9:18 am
Hello all,
may somebody advise me, how to control CSI camera module through C++/C ?
Basically, I would like to take a picture or video when GPIO pin is changing status (foe ex. : from 1 to 0).
thanks a lot
david
Posts: 3
Joined: Tue Jun 18, 2013 9:07 am
by jamesh » Tue Jun 18, 2013 10:05 am
All the camera apps are available as source code, which is all in C. It's in the Raspberry Pi userland github repo.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 17112
Joined: Sat Jul 30, 2011 7:41 pm
by dadosebo » Wed Jun 19, 2013 2:29 pm
So, I must call os commands.
There is no library for camera control under C++, I'm right?
thanks
Posts: 3
Joined: Tue Jun 18, 2013 9:07 am
by jamesh » Wed Jun 19, 2013 3:13 pm
dadosebo wrote:So, I must call os commands.
There is no library for camera control under C++, I'm right?
thanks


Not really OS commands - there are a set of C functions available to run the camera - the code supplied shows how to do that. There is currently no specific library for the camera.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 17112
Joined: Sat Jul 30, 2011 7:41 pm
by dadosebo » Thu Jun 20, 2013 9:56 am
jamesh wrote:
dadosebo wrote:So, I must call os commands.
There is no library for camera control under C++, I'm right?
thanks


Not really OS commands - there are a set of C functions available to run the camera - the code supplied shows how to do that. There is currently no specific library for the camera.


Dear James,
first, thanks for support.
I found many objects to set-up camera, but any object to save video or picture to a file. Would you be so kind and put here some simple example how to make video under C++. Sorry for bothering you with begginers questions.
david
Posts: 3
Joined: Tue Jun 18, 2013 9:07 am
by jamesh » Thu Jun 20, 2013 10:08 am
dadosebo wrote:
jamesh wrote:
dadosebo wrote:So, I must call os commands.
There is no library for camera control under C++, I'm right?
thanks


Not really OS commands - there are a set of C functions available to run the camera - the code supplied shows how to do that. There is currently no specific library for the camera.


Dear James,
first, thanks for support.
I found many objects to set-up camera, but any object to save video or picture to a file. Would you be so kind and put here some simple example how to make video under C++. Sorry for bothering you with begginers questions.
david


The examples are the demo programs. They are about as simple as it gets. You can download them from github https://github.com/raspberrypi/userland.

The show how to run the camera and save the output.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 17112
Joined: Sat Jul 30, 2011 7:41 pm
by wibble82 » Sun Oct 27, 2013 8:22 am
Just added this to my blog:

http://robotblogging.blogspot.co.uk/201 ... i-for.html

It's a much simpler system for reading the camera in c++. Enjoy!
Posts: 66
Joined: Sun Jan 27, 2013 5:06 pm
by wibble82 » Sun Oct 27, 2013 6:50 pm
Might I also recommend this incredibly simple bit of code for saving images: http://lodev.org/lodepng/

Once you've got your raw data from the camera, lodepng provides just 1 function call to save it as a png. Not fast, but simple!
Posts: 66
Joined: Sun Jan 27, 2013 5:06 pm
by rmsalinas » Fri Nov 01, 2013 8:19 pm
Hi,

I have created a C++ library for controlling the camera. I think you might be insterested. Take a look at

http://www.uco.es/investiga/grupos/ava/node/40


Cheers
Posts: 12
Joined: Tue Sep 03, 2013 3:44 pm
by jamesh » Fri Nov 01, 2013 8:24 pm
wibble82 wrote:Might I also recommend this incredibly simple bit of code for saving images: http://lodev.org/lodepng/

Once you've got your raw data from the camera, lodepng provides just 1 function call to save it as a png. Not fast, but simple!


The standard raspistill can output PNG....(and BMP and GIF)
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 17112
Joined: Sat Jul 30, 2011 7:41 pm