maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   Terminal Command to take picture? (https://talk.maemo.org/showthread.php?t=38149)

bocaJ 2009-12-23 07:28

Terminal Command to take picture?
 
For the first time in 22 years, I'm spending the holidays away from my family. My Mom put together an amazing gift package for me with with cards, candy, gifts, and a build-it-yourself Christmas Tree! I took some pictures of the whole set-up, but I want to get one with me in the picture too. I didn't see a shutter delay in the camera functions, so I was hoping someone could give me a terminal command to take a picture, and I could set it off via SSH.

Thanks in advance - this is a wonderful community.

That One Guy 2009-12-23 08:11

Re: Terminal Command to take picture?
 
Make a little video of you in front of the tree and then just capture one of more frames off the video on your computer?

eiffel 2009-12-23 18:51

Re: Terminal Command to take picture?
 
Just hold the phone at arm's length, with the lens pointing towards you, and take the photo. For further inspiration see What is self-photography?

Regards,
Roger

mysticrokks 2009-12-23 18:59

Re: Terminal Command to take picture?
 
ok what about asking a mate or just a random human to take the pic for you

dvergin 2009-12-23 19:09

Re: Terminal Command to take picture?
 
I'm also interested in the question in the title (for other purposes). How would we go about controlling the camera from the command line or (better) from a python script?

Certainly there must be docs somewhere for this but all my Googling can find is tons of pages on using the default camera app, not scripting for the camera hardware or any reference to a camera API..

schettj 2009-12-23 19:21

Re: Terminal Command to take picture?
 
Quote:

Originally Posted by eiffel (Post 439401)
Just hold the phone at arm's length, with the lens pointing towards you, and take the photo.

AKA "The Facebook Effect"

Everyone has one arm trailing out of frame now ;)

There is a gstreamer command string you can put together to take a snapshot, but you probably need to enable the dev repository to install gstreamer? I don't recall what I've installed on mine and what is stock.

ah... so as root

apt-get install gstreamer-tools

and then...

gst-launch v4l2camsrc device=/dev/video0 num-buffers=1 ! dspjpegenc ! filesink location=test.jpg

Grabs a 640x480 shot from the back camera. Or /dev/video1 for the front cam

(if it complains about dspjpegenc, try omx_jpegenc)

qole 2009-12-23 19:31

Re: Terminal Command to take picture?
 
Just a follow-up. To get the focus and white balance right, take a picture of the scene with the camera app first, then run your gstreamer script.

You also won't be able to use the flash, so make sure there's lots of light.

Instead of using ssh, I would suggest just adding a "sleep 10 s" to wait 10 seconds before taking the picture...

dvergin 2009-12-23 19:35

Re: Terminal Command to take picture?
 
Quote:

Originally Posted by schettj (Post 439436)
...you probably need to enable the dev repository to install gstreamer?...

Actually, it's now in Extras. :-) So apt-get should find it without the need to enable Devel or Testing.

Thanks for the command line help.

schettj 2009-12-23 19:45

Re: Terminal Command to take picture?
 
Ah... this works a LOT better, too:

gst-launch v4l2src ! ffmpegcolorspace ! pngenc ! filesink location=test.png

That'll get you the full-sized image in png format. Note that there is a delay after issuing the command of several seconds, which I can't seem to track down.

Indeed autofocus and flash are a bit tricky... you should be able to use the camerabin device, but its expecting to behave like the camera itself, so it doesn't play too well with gst-launch :(

qole 2009-12-23 20:34

Re: Terminal Command to take picture?
 
So: first rig up some kind of a tripod system. Then take a picture of the scene with the camera app, with the flash disabled. Finally, run a little script that waits 5 or 10 seconds then takes a picture, something like

Code:

sleep 5
gst-launch v4l2src ! ffmpegcolorspace ! pngenc ! filesink location=$1.png

Ideally, you should add a gstreamer command line at the end to play the shutter sound, so you know the photo has been taken...

bocaJ 2009-12-23 21:07

Re: Terminal Command to take picture?
 
thanks folks, ended up going with the facebook effect, but next time...

R-R 2009-12-23 21:39

Re: Terminal Command to take picture?
 
Quote:

Originally Posted by qole (Post 439497)
Code:

sleep 5 s
gst-launch v4l2src ! ffmpegcolorspace ! pngenc ! filesink location=$1.png

.

Funny how sleep 5 s doesn't work on a desktop i thought it was a mistake as it should just read "sleep 5" but works on the n900... weird version :-)

Ricardo 2009-12-24 20:42

Re: Terminal Command to take picture?
 
I think jpegenc is much faster - sometimes the image is captured in just 2s.

I wrote a small intervalometer for the N900 in Perl - you might take a look if you are interested.

j.s 2009-12-24 21:02

Re: Terminal Command to take picture?
 
Quote:

Originally Posted by R-R (Post 439561)
Funny how sleep 5 s doesn't work on a desktop i thought it was a mistake as it should just read "sleep 5" but works on the n900... weird version :-)

But sleep 5s (or sleep 1m), no space between number and units, does work in destop linux, but not on n900. I think the n900 ignores the second argument. Try sleep 1 m on the n900.

schettj 2009-12-24 22:26

Re: Terminal Command to take picture?
 
sleep is provided via busybox on the n900, so it's not the standard *nix sleep, it's the busybox version.

j.s 2009-12-24 22:54

Re: Terminal Command to take picture?
 
Quote:

Originally Posted by schettj (Post 440842)
sleep is provided via busybox on the n900, so it's not the standard *nix sleep, it's the busybox version.

My point was that the " s" in qole's examples
sleep 1 s
is superfluous at best. The n900 busybox sleep ignores it and it is gratuitously incompatible with standard sleep.

In addition, the busybox sleep for at least one 2008 distribution for the openmoko freerunner handles commands like
sleep 5s
sleep 1m
correctly.

rm53 2010-02-20 15:27

Re: Terminal Command to take picture?
 
Quote:

Originally Posted by qole (Post 439497)
So: first rig up some kind of a tripod system. Then take a picture of the scene with the camera app, with the flash disabled. Finally, run a little script that waits 5 or 10 seconds then takes a picture, something like

Code:

sleep 5
gst-launch v4l2src ! ffmpegcolorspace ! pngenc ! filesink location=$1.png

Ideally, you should add a gstreamer command line at the end to play the shutter sound, so you know the photo has been taken...

I tried this, but got error
erroneous pipeline: no element "pngenc"

what to do?

jozeph 2010-02-21 12:57

Re: Terminal Command to take picture?
 
Hello,

I'm developing an application that will require to take a picture from the front camera. I'm testing it using the gstreamer on video1, but the picture is completely black. I test my front camera using that Mirror application and it's working great.

How to take a legible picture from front camera using gstreamer? :D

jozeph 2010-02-22 16:01

Re: Terminal Command to take picture?
 
No suggestions about how to take a picture legible? My pictures using this command line is completely black....

stefanmohl 2010-02-22 19:02

Re: Terminal Command to take picture?
 
Just a tip: If anyone is getting:

ERROR: pipeline could not be constructed: no element 'v412src'.

(or 'v412camsrc')

you have mistyped an 'l' as a '1' (i.e. you wrote the number '1' when it should have been the small caps letter 'l')

The correct spelling is: v4l2src, where the character after '4' is the letter 'l'

lamle 2010-04-24 16:42

Re: Terminal Command to take picture?
 
Hi all,
Probably its not relevant but I am working on a project related to this. I have an application that allows users to take picture and upload it immediately. Using gstreamer works just fine but it does not have flash and one annoying thing is that before I can take picture, I have to open the lens cover and it automatically open the default software of N900, I have to close it and use my own. I wonder is there any way to disable that auto-open software and use flash in gstreamer??
Another alternative is that I can use the default software to take picture and listen to changes in 'camera' folder to get the taken picture to use in my application.
Any idea?

lamle 2010-04-26 20:45

Re: Terminal Command to take picture?
 
Actually that the default camera software automatically opens creates lots of troubles for user, he has to close it first and open the intended software again. Anyway to disable it temporary when we open a particular software??

justmemory 2014-12-18 07:44

Re: Terminal Command to take picture?
 
3 Attachment(s)
Hi Community!

I had some time to learn programming on my own; I like it, and I made a little script that I wanted to share. Please keep in mind, that I’m not a programmer at all, this is just my hobby.

I know that there are time lapse apps for n900, but I wanted to make my own, so I wrote a little script in python. Keep in mind, that this app represents my personal needs; but hey, you can modify the source code in any level, in any detail! :) I know that the code is probably not that beautiful, but this is my first bigger app with UI.

The program itself:
1. It has a capturing window where you can take pictures with the desired settings; and
2. a converter window, where you can make the time lapse movie. It is working with any jpg pictures in any directory, so if you copy that part of the code to another file, you can make a standalone converter app.

1. The capturing window:

On the left side you can specify the capturing, on the right side there is the viewfinder.
The buttons from left to right, top to bottom:
- “Select device”: you can specify whether you would like to use the front camera or the back camera.
- “Counter”: you can specify the number of picture you would like to be taken. If this is not set, the capturing goes “forever”. When capturing, it is also counting the number of pictures that were taken, eg. if 3 is set as max, then 3 / 1, 3 / 2, etc. If max reached, it stops.
- “Viewfinder”: you can turn the viewfinder on or off. IMPORTANT!!! if you would like to turn the viewfinder off, you have to click the button (it will say “Viewing stopped”), and then turn mplayer off in the terminal manually (press “q”). You can add an extra button to do this of course.
- “Automatic”: this captures the images within the predefined time intervals you specified with “Select framerate” button. If a maximum number was set with counter, then it stops when that number is reached; if not, then it goes “forever”. Of course you can stop it with hitting the button again; then it stops capturing.
The pictures are taken with the resolution of 640x480 (front camera) and 800x480 (back camera). You can edit this in the source code or make another button for it to be able to specify any other resolution. But keep in mind that taking pictures in higher resolutions is taking more time.
To make the viewing and capturing possible, the viewfinder is turning off when picture is taken, and then it turns on again.
First I added a countdown button to know when it is taking the pictures, but it is efficient only when the pictures are taken with another method, but for that method the viewfinder had to be off all the time, so I removed it.
Now the countdown button is not set, because I found that there is sometimes a +- 1 second difference to the time interval, maybe because of the tracker.
- “Select framerate”: you can specify the time interval (seconds) of picture-taking. Minimum is 4, maximum is 30 seconds, but you can extend it in the source code, or simply replace the picker button with entry widget.
Due to the capturing method you won’t be able to set the minimum lower, because the commands have to be executed (turn the viewfinder off, take the picture, and turn the viewfinder on) and this needs time…
There is the other capturing method I wrote first though; in that way you would be able to capture pictures in every 1, 2, or 3 seconds too, but in that way the viewfinder have to be off completely.
- “Manual”: you can capture pictures by hand, just click the button. The counting of taken pictures is working too.
- “Save as…”: you can specify the folder and the filename of the pictures. The pictures are saved in time format, so the specified filename will be showed before the time tag. Eg. If the filename is “test”, then the name of the saved file will be “test20141217_101543.jpg”
- “PyTimelapseMaker”: opens another window with the video maker.

2. Converter window:

The buttons from left to right, top to bottom:
- “Select folder”: you can specify the folder where the jpg files are. Keep in mind that all of the jpg files will be in the movie. If the folder doesn’t contain any jpg files, a message will be shown.
- “Save as”: you can specify folder and filename. The saved movie will be in avi format, no matter of the name you specify (eg. test.mp4). If you would like to use another format, you have to edit the source code (the converter command).
- “Select framerate”: you can specify the frame rate of the movie; 1 picture is the minimum, 30 pictures are the maximum (per second of course).
- “Select scale”: you can specify whether you would like to use 400x240 or 800x480. You can edit this too in the source code if you would like to extend it. But keep in mind that if the pictures are in low resolution, they won’t be better if you choose higher resolution…
- “Convert”: when everything is set, it creates the movie. There is no progress bar, the button will be “on” during the conversion. When its “light” turns off, the conversion is done.
- “Playback”: you can watch the last movie made. There is no option to select any movie, you have to use a player for that, but the last movie can be watched. If you would like to be able to choose any movie, you have to edit the source code and connect that option to the button.

As you can see, this is quite simple; I just wanted to have a user interface for the commands, so I wouldn’t have to write everything in the terminal every time.

To use the app, you have to install a mplayer that contains mencoder; so you have to compile one yourself, or use the one I’m using. Also you have to install gstreamer-tools to have gst-launch.

Please test it and feel free to tell me your impressions about it.

Cheers,
jm

nokiabot 2014-12-18 08:32

Re: Terminal Command to take picture?
 
Nice but why not a new thread insted as the avove post would get burried soon ?

justmemory 2014-12-18 08:38

Re: Terminal Command to take picture?
 
Quote:

Originally Posted by nokiabot (Post 1452647)
Nice but why not a new thread insted as the avove post would get burried soon ?

yes, I was thinking about a thread, but I was too shy... :D I thought this is not a big deal, not a real application or something, just a script...

EDIT: I was thinking and nokiabot was right so I opened a thread for this; and a little bit more perhaps. Please go there.

jellyroll 2014-12-25 15:08

Re: Terminal Command to take picture?
 
Quote:

Originally Posted by lamle (Post 626085)
Hi all,
Probably its not relevant but I am working on a project related to this. I have an application that allows users to take picture and upload it immediately. Using gstreamer works just fine but it does not have flash and one annoying thing is that before I can take picture, I have to open the lens cover and it automatically open the default software of N900, I have to close it and use my own. I wonder is there any way to disable that auto-open software and use flash in gstreamer??
Another alternative is that I can use the default software to take picture and listen to changes in 'camera' folder to get the taken picture to use in my application.
Any idea?

It's possible to disable 'auto-open software' or load a custom script by opening the lens cover.
Just take look at the wiki phone controle page or use the camera lens launcher plugin as an example.


All times are GMT. The time now is 11:13.

vBulletin® Version 3.8.8