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

New version of Raspistill

Fri Oct 11, 2013 4:07 pm

Hello all,

I just pushed a new version of raspistill to my github. https://github.com/JamesH65/userland/tr ... pture_loop

You may need the latest firmware as well.

This changes the way the capture loop is run, moving the test that decides when to take the next capture out in to its own function. Makes it easier to add new options (I've added some stubbed out ones already - GPIO and signal). At the same time I re-added the option to have a keypress take the next image, and added a timelapse option - when you enter 0 as the parameter to -tl, it takes pictures as fast as it can (minus a 30ms delay for exposure to work).

Can anyone who builds the camera app regularly give it a go to make sure it's all working? The docs have also been updated.

I've already put in a PR to have it moved to the Raspi repo, but would also like some extra testing.

Can you put any bug reports as comments here since the code hasn't made it to Raspi userland yet.

Enjoy.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

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

Re: New version of Raspistill

Fri Oct 11, 2013 5:07 pm

I'd like to try this but I'm clumsy with github, what is the exact command I need to get the latest branch? I tried git clone https://github.com/JamesH65/userland.git and compiled/installed the result with the 'buildme' script, but got raspistill Camera App v1.3.2 and I think I'm looking for version 1.3.3.

Maybe what I want is just

Code: Select all

wget https://github.com/JamesH65/userland/archive/new_capture_loop.zip
EDIT: Yes, getting the .zip file and compiling works for me. I tried

Code: Select all

raspistill -k -o test%02d.jpg
and this works as expected (quits after the first "ENTER" key occurs after the default 5-sec timeout.) very nice!
Last edited by jbeale on Fri Oct 11, 2013 5:40 pm, edited 1 time in total.

ethanol100
Posts: 587
Joined: Wed Oct 02, 2013 12:28 pm

Re: New version of Raspistill

Fri Oct 11, 2013 5:40 pm

Hi,
you can change your local branch to the remote branch with

Code: Select all

git clone https://github.com/JamesH65/userland
cd userland
git fetch origin
git checkout -b  new_capture_loop origin/new_capture_loop

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

Re: New version of Raspistill

Fri Oct 11, 2013 5:51 pm

ethanol100 wrote:

Code: Select all

git clone https://github.com/JamesH65/userland
cd userland
git fetch origin
git checkout -b  new_capture_loop origin/new_capture_loop
Thanks ethanol100, that works too (and it's a lot faster just recompiling the code that changed!). The new code works for me and the -tl 0 looks good and is very useful, thanks for that! The option to trigger from a GPIO input or Unix signal will be great as well.

PiGraham
Posts: 3671
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: New version of Raspistill

Fri Oct 11, 2013 7:28 pm

Thanks ethanol100.
I have compiled it and it seemed to run on a quick test. -k option, functioned as described below.
Mindful of James' remark about latest firmware I updated.
I did a rpi-update, built it again.
The -k option works, but cycles twice. With %d in the output filename I get two different image files, one for each press of Enter.

Code: Select all

raspistill -tl 0 -t 60000 -o tl%d.jpg
Gives me a black preview.
After a minute I have 89 black jpg files.

Running a similar command again:

Code: Select all

raspistill -tl 1000 -t 60000 -o tl%d.jpg
I get an error:

Code: Select all

mmal: Unable to write buffer to file - aborting
df shows rootfs full
There are only 9 jpg files in the directory (I deleted the 89).

Hmm. Did I cock-up with the upgrade?

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

Re: New version of Raspistill

Fri Oct 11, 2013 7:43 pm

PiGraham wrote:Thanks ethanol100.
I have compiled it and it seemed to run on a quick test. -k option, functioned as described below.
Mindful of James' remark about latest firmware I updated.
I did a rpi-update, built it again.
The -k option works, but cycles twice. With %d in the output filename I get two different image files, one for each press of Enter.

Code: Select all

raspistill -tl 0 -t 60000 -o tl%d.jpg
Gives me a black preview.
After a minute I have 89 black jpg files.

Running a similar command again:

Code: Select all

raspistill -tl 1000 -t 60000 -o tl%d.jpg
I get an error:

Code: Select all

mmal: Unable to write buffer to file - aborting
df shows rootfs full
There are only 9 jpg files in the directory (I deleted the 89).

Hmm. Did I cock-up with the upgrade?
That a bit weird. Not sure that's anything to do with the changes to raspistill.

I have been wondering about black frames with -tl 0. I didn't see any, but I think I might need to have a longer delay for the first image only, to give the system time to stabilise and get exposure right. At the moment there is a 30ms delay between images added so exposure gets some time to work, that may not be enough for the first frame, or perhaps even captures later on if scene changes brightness dramatically.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

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

Re: New version of Raspistill

Fri Oct 11, 2013 8:11 pm

Code: Select all

    raspistill -tl 0 -t 60000 -o tl%d.jpg
This command worked OK for me. I got 54 jpeg files (tl1.jpg through tl54.jpg) and none of them were black, they were all images as expected. However during that minute it was not a uniform frame rate, it ran faster than 1 fps for a while and then paused, a few times, so the preview image update and the interval between recorded shots was uneven. (maybe waiting for the SD card I/O to catch up?).

EDIT:
Wait, I see a problem. The *second* time I ran the command, both the preview and every image was 100% black. The first run left something un-reset so the camera no longer works. Running a non-timelapse invocation of raspistill was able to reset the camera.

I tried a shorter time and lower resolution and got 10 frames over 6 seconds (plus a short pause at the end). All these images came out ok.

Code: Select all

[email protected]:~/pics/test6$ time raspistill -t 5000 -tl 0 -w 1024 -h 768 -o L%d.jpg

real    0m6.757s
user    0m0.010s
sys     0m0.160s
[email protected]:~/pics/test6$ ll
total 3728
-rw-r--r-- 1 pi pi 370327 Oct 11 13:18 L10.jpg
-rw-r--r-- 1 pi pi 403359 Oct 11 13:18 L1.jpg
-rw-r--r-- 1 pi pi 398392 Oct 11 13:18 L2.jpg
-rw-r--r-- 1 pi pi 399354 Oct 11 13:18 L3.jpg
-rw-r--r-- 1 pi pi 373962 Oct 11 13:18 L4.jpg
-rw-r--r-- 1 pi pi 372893 Oct 11 13:18 L5.jpg
-rw-r--r-- 1 pi pi 368350 Oct 11 13:18 L6.jpg
-rw-r--r-- 1 pi pi 371502 Oct 11 13:18 L7.jpg
-rw-r--r-- 1 pi pi 364685 Oct 11 13:18 L8.jpg
-rw-r--r-- 1 pi pi 371636 Oct 11 13:18 L9.jpg

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

Re: New version of Raspistill

Fri Oct 11, 2013 8:46 pm

Can you try this change to raspistill.c? Its in the new function wait_for_next_frame and replaces the current case for IMMEDIATELY. It should put in a longer delay for the first frame.

Code: Select all

   case FRAME_NEXT_IMMEDIATELY :
   {
      // No wait, just go to next frame.
      // Actually, we do need a slight delay here otherwise exposure goes
      // badly wrong since we never allow it frames to work it out
      // Make the very first delay quite log to give the camera plenty of time to settle.
      // This could probably be tuned down.

      if (*frame == 0)
         vcos_sleep(1000);
      else
         vcos_sleep(30);

      *frame+=1;

      return keep_running;
   }
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

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

Re: New version of Raspistill

Sat Oct 12, 2013 4:29 am

@JamesH: I just put in that minor change to RaspiStill.c and it seems to be working OK so far, no black frames after a few tries.

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

Re: New version of Raspistill

Sat Oct 12, 2013 8:12 am

jbeale wrote:@JamesH: I just put in that minor change to RaspiStill.c and it seems to be working OK so far, no black frames after a few tries.
Thanks for testing. May still be problems if there are dramatic changes in scene brightness I think. The extra delay at the start gives the system plenty of time to sort out exposure, which I presume the current 30ms didn't do.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: New version of Raspistill

Sat Oct 12, 2013 2:57 pm

Hi James & thanks for your continued efforts to refine the camera apps.

Is there no way of knowing when the camera module has stabilised wrt exposure eg polling some agc value or such?

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

Re: New version of Raspistill

Sat Oct 12, 2013 3:17 pm

gregeric wrote:Hi James & thanks for your continued efforts to refine the camera apps.

Is there no way of knowing when the camera module has stabilised wrt exposure eg polling some agc value or such?
I'm not sure there is, because exposure changes all the time even just in small increments. But I will check on Monday if I remember.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

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

Re: New version of Raspistill

Sun Oct 13, 2013 4:32 pm

This change has now been merged, but it doesn't include the minor fix for the first frame. I'll push that tomorrow. I might have time to add signal based capture as well. Just trying to figure out how signals work!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

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

Re: New version of Raspistill

Sun Oct 13, 2013 5:22 pm

jamesh wrote:This change has now been merged, but it doesn't include the minor fix for the first frame. I'll push that tomorrow. I might have time to add signal based capture as well. Just trying to figure out how signals work!
Good news on the update! I don't know about signals either, but the example of raspiFastCamD.c looks pretty straightforward, of course other code is needed but here is the signal handler:
code: https://bitbucket.org/niklas_rother/ras ... ?at=master

Code: Select all

/**
 * Handler for sigusr1 signals
 * @param signal_number ID of incoming signal.
 */
static void sigusr1_handler(int signal_number)
{
        vcos_semaphore_post(&signal_semaphore);
}

...

   // Register our application with the logging system
   vcos_log_register("RaspiStill", VCOS_LOG_CATEGORY);

   signal(SIGINT, sigint_handler);
   signal(SIGKILL, sigint_handler);
   signal(SIGUSR1, sigusr1_handler);

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

Re: New version of Raspistill

Sun Oct 13, 2013 5:51 pm

Yes, I was going to use SIGUSR1 as well. Looks pretty simple, but cannot test at the moment as 'reorganising' the 'computer room'. Will hopefully get a chance at work tomorrow.

Note I was going to use something like sigwait() rather than put in a handler for the specific signal. If that a bad idea, would be interested to know! (and why)
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

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

Re: New version of Raspistill

Mon Oct 14, 2013 9:56 am

OK, have pushed a new revision to my github. This adds the fix for black frames described above, and also adds the signal mode, whereby you can send a SIGUSR1 to the raspistill process and it will take a capture.

https://github.com/JamesH65/userland/tree/signal_mode

I tested by running raspistill as follows,

Code: Select all

raspistill -t 200000 -s -o signaltest%d.jpg -v
then SSH'ing in from a Cygwin on Windows installation, and using

Code: Select all

kill -USR1 <process ID of raspistill>
to take a capture.

Would appreciate people doing some testing if time allows.

Thanks

James
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

gordon77
Posts: 4292
Joined: Sun Aug 05, 2012 3:12 pm

Re: New version of Raspistill

Mon Oct 14, 2013 11:02 am

Any chance of someone giving instructions how to use stuff from github, or where to find some ?

I click on Jamesh link but I'm afraid I don't know what to do next

Thanks

Gordon77

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

Re: New version of Raspistill

Mon Oct 14, 2013 11:12 am

gordon77 wrote:Any chance of someone giving instructions how to use stuff from github, or where to find some ?

I click on Jamesh link but I'm afraid I don't know what to do next

Thanks

Gordon77
Unfortunately git is a PITA, but I am forced to use it. You need to clone the repository to your machine (Pi, or PC if cross compiling) using the command that you will find on githib

Something like this..in a folder of your choice. (Note, I may have made mistakes in these instructions - I am not a git fan)

git clone https://github.com/JamesH65/userland.git

Then you will need to select the correct brand, somehow. Move in to the userland folder...

git checkout signal_mode

Then you need to build - again from userland root.

./buildme
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

PiGraham
Posts: 3671
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: New version of Raspistill

Mon Oct 14, 2013 11:26 am

jamesh wrote:Unfortunately git is a PITA, but I am forced to use it.
A brief aside. What is your preferred VCS?

So as not to derail the topic I opened a new one here:
http://www.raspberrypi.org/phpBB3/viewt ... 59#p437459

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

Re: New version of Raspistill

Mon Oct 14, 2013 11:45 am

PiGraham wrote:
jamesh wrote:Unfortunately git is a PITA, but I am forced to use it.
A brief aside. What is your preferred VCS?

So as not to derail the topic I opened a new one here:
http://www.raspberrypi.org/phpBB3/viewt ... 59#p437459
I've always got on OK with Perforce. But you have to pay for it. Now we are moving to GIT (enforced due to Android and kernel using GIT). It's like watching a slo-mo train wreck.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

ethanol100
Posts: 587
Joined: Wed Oct 02, 2013 12:28 pm

Re: New version of Raspistill

Mon Oct 14, 2013 5:03 pm

Hello,
thanks for the new version of raspistill, signal is working for me, but only if I want to capture one image, but I have no success using the signal for the timelapse mode. The program always exit after the first

Code: Select all

kill -USR1 `pgrep raspistill`
So how would I start timelapse mode with signal? I have tried with

Code: Select all

 raspistill -s -tl 1000 -t 100000 -o test%04d.jpg

but could we use a number of frames, and set -t 0?

By the way, I have changed the branch again with

Code: Select all

git fetch origin
git checkout -b  signal_mode  origin/signal_mode
The "git fetch origin" updates the list of remote branches.
You can get a list of remote branches and local branches with
"git branch -a"

Edit: I have found my problem with the timelapse, I was thinking you need to specify -tl and -t somehow to trigger the way to capture a sequence of pictures and define the count of images. But that is wrong, just use "raspistill -s -o %d.jpg" then it works as expected, each time a SIGUSR1 is received it takes a picture and runs until it is killed. Very nice, but can you somehow mention this in the docs or check if a user specifies more then one method?
Last edited by ethanol100 on Tue Oct 15, 2013 9:10 am, edited 1 time in total.

gordon77
Posts: 4292
Joined: Sun Aug 05, 2012 3:12 pm

Re: New version of Raspistill

Mon Oct 14, 2013 5:31 pm

jamesh wrote:
gordon77 wrote:Any chance of someone giving instructions how to use stuff from github, or where to find some ?

I click on Jamesh link but I'm afraid I don't know what to do next

Thanks

Gordon77
Unfortunately git is a PITA, but I am forced to use it. You need to clone the repository to your machine (Pi, or PC if cross compiling) using the command that you will find on githib

Something like this..in a folder of your choice. (Note, I may have made mistakes in these instructions - I am not a git fan)

git clone https://github.com/JamesH65/userland.git

Then you will need to select the correct brand, somehow. Move in to the userland folder...

git checkout signal_mode

Then you need to build - again from userland root.

./buildme
Thanks James for trying but most of this means nothing to me, pita? correct brand? l'll leave it to you experts and wait until its in the raspbian builds

Gordon77

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

Re: New version of Raspistill

Mon Oct 14, 2013 6:11 pm

PITA = pain in the ass - evidently James is not a fan of the current open-source version control system du jour (personally I've gone from cvs->subversion->mercurial->git and the latter is growing on me, albeit in rather mouldy fashion...). Also, I suspect "correct brand" was meant to be "correct branch" (most versioning systems permit multiple "branches" of the same software to be developed simultaneously; this can allow multiple developers to work simultaneously on fixing a variety of separate bugs).

As for the rest, I'll try and make a terminal session out of it; I've included a few extra lines here to make sure you've got the stuff necessary for building the tools. Don't enter the "$" at the start of the lines - that's just representing the shell prompt:

Code: Select all

$ cd
$ sudo apt-get install build-essential git cmake
$ git clone https://github.com/JamesH65/userland.git
$ cd userland
$ git checkout signal_mode
$ ./buildme
At this point, go make tea/coffee/your-choice-of-cocktail as the build takes a fair old while (assuming you're running it on the Pi). Once the build has finished, run raspistill et al as usual and see what happens: the ./buildme script installs the newly built items to the system root - personally I'm not a fan of this, and I tend to comment the "sudo make install" bit out and run them from the build directory, but I suspect you'll want to keep things simple; you can always re-install them without much difficulty anyway.


Good luck!

Dave.

gordon77
Posts: 4292
Joined: Sun Aug 05, 2012 3:12 pm

Re: New version of Raspistill

Mon Oct 14, 2013 7:01 pm

Thanks, l'll give it a go when l get a chance

Gordon77

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

Re: New version of Raspistill

Mon Oct 14, 2013 10:31 pm

waveform80 wrote:PITA = pain in the ass - evidently James is not a fan of the current open-source version control system du jour (personally I've gone from cvs->subversion->mercurial->git and the latter is growing on me, albeit in rather mouldy fashion...). Also, I suspect "correct brand" was meant to be "correct branch" (most versioning systems permit multiple "branches" of the same software to be developed simultaneously; this can allow multiple developers to work simultaneously on fixing a variety of separate bugs).

As for the rest, I'll try and make a terminal session out of it; I've included a few extra lines here to make sure you've got the stuff necessary for building the tools. Don't enter the "$" at the start of the lines - that's just representing the shell prompt:

Code: Select all

$ cd
$ sudo apt-get install build-essential git cmake
$ git clone https://github.com/JamesH65/userland.git
$ cd userland
$ git checkout signal_mode
$ ./buildme
At this point, go make tea/coffee/your-choice-of-cocktail as the build takes a fair old while (assuming you're running it on the Pi). Once the build has finished, run raspistill et al as usual and see what happens: the ./buildme script installs the newly built items to the system root - personally I'm not a fan of this, and I tend to comment the "sudo make install" bit out and run them from the build directory, but I suspect you'll want to keep things simple; you can always re-install them without much difficulty anyway.


Good luck!

Dave.
Thanks - I really must learn to type.

But I still think GIT is a PITA.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

Return to “Camera board”