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

Re: New version of Raspistill

Mon Oct 14, 2013 10:34 pm

I did a bit more testing myself, and it seems to work OK. So unless I hear otherwise I'll put in a pull request for the new version tomorrow so it goes to mainline.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

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

Re: New version of Raspistill

Tue Oct 15, 2013 9:59 am

Hello James,
it seems that there exists a problem if you send a "kill -USR1". When running the program without the -s switch, it receives USR1 and prints "User defined signal 1" and exits the program(without saving an image). If you use the -s switch I can only get 2-3 frames before the program is terminated, does this happens if the program is not just waiting for USR1 at "sigwait( &waitset, &sig );"? "Is it because of the default disposition" of SIGUSR1 which is TERM?
My test was "raspistill -v -s -o signal%d.jpg" in one terminal and "for i in {1..10}; do kill -USR1 `pgrep raspistill`; sleep 10; done" in another terminal.

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

Re: New version of Raspistill

Tue Oct 15, 2013 10:27 am

ethanol100 wrote:Hello James,
it seems that there exists a problem if you send a "kill -USR1". When running the program without the -s switch, it receives USR1 and prints "User defined signal 1" and exits the program(without saving an image). If you use the -s switch I can only get 2-3 frames before the program is terminated, does this happens if the program is not just waiting for USR1 at "sigwait( &waitset, &sig );"? "Is it because of the default disposition" of SIGUSR1 which is TERM?
My test was "raspistill -v -s -o signal%d.jpg" in one terminal and "for i in {1..10}; do kill -USR1 `pgrep raspistill`; sleep 10; done" in another terminal.
If you send USR1 when not in signal mode, I would expect what you say to happen. USR error as it were!

But I've not had problems with multiple captures going wrong. It may be if you send the signals too quickly? Although 10s should be plenty. If you get a USR1 whilst the system is not waiting for it I think that will drop out. I'll need to check. Buit not actually sure how to stop that happening - I guess a signal handler that does ntohin, or is there a better way to disable a signal?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

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

Re: New version of Raspistill

Tue Oct 15, 2013 11:29 am

OK, I've pushed a new version on a new branch signal_mode2, which should fix the problems quoted. I now disable the USR1 signal unless it in use. I have also added a signal handler for it so that it if is received out of the wait, it shouldn't drop out. Seems to work in my testing.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

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

Re: New version of Raspistill

Tue Oct 15, 2013 12:19 pm

Thank you,
I think it is a good option, because if we could receive the singal to early or in the wrong moment it could be useful. But I need to apologise, in the mentioned case the problem was me, I have not set -t value and therefore it has just timed out when the wait function was executed after the timeout. Sorry for that, I had assumed that the timeout would be disabled for symbol and key press events.

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

Re: New version of Raspistill

Tue Oct 15, 2013 12:41 pm

ethanol100 wrote:Thank you,
I think it is a good option, because if we could receive the singal to early or in the wrong moment it could be useful. But I need to apologise, in the mentioned case the problem was me, I have not set -t value and therefore it has just timed out when the wait function was executed after the timeout. Sorry for that, I had assumed that the timeout would be disabled for symbol and key press events.
I did wonder about disabling the timeout when in a mode like this, but I think there are circumstances where people may still want it in combination. And you can always use -t 0
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

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

Re: New version of Raspistill

Wed Oct 16, 2013 1:09 pm

I have started the process.......

in the meantime is raspistill updated whenever I do an upgrade & update ?

I do I know the version of raspistill I am using ?

Thanks

Gordon77

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

Re: New version of Raspistill

Wed Oct 16, 2013 1:24 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.
I treid entring your instructions but got...

Code: Select all

$ cd
$ sudo apt-get install build-essential git cmake
.....

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

> Cloning into 'userland'
>remote: Counting objects: 1609, done.
>remote: Compressing objects: 100% (955/955), done.
>remote: Total 1609 (delta 768), resued 1357 (delta 602)
>Receiving objects: 100% (1609/1609), 31.53 MiB | 450 KiB/s, done.
>Resolving deltas: 100% (768/768), done.
>Checking out files: 100% (501/501), done.


$ cd userland

> pi@raspberrypi ~/userland $

$ git checkout signal_mode

> error: pathspec 'signal_mode' did not match any file(s) known to git.

what next ?

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

Re: New version of Raspistill

Wed Oct 16, 2013 1:35 pm

Can you try signal_mode2

I had to make a change and couldn't figure out how to reuse the same branch (its a long story) so created a new one.

To get a list of branches

git br
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

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

Re: New version of Raspistill

Wed Oct 16, 2013 1:40 pm

jamesh wrote:Can you try signal_mode2

I had to make a change and couldn't figure out how to reuse the same branch (its a long story) so created a new one.

To get a list of branches

git br
Thanks that worked. it's now busy building..........

I wish I knew what I was doing :D

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

Re: New version of Raspistill

Wed Oct 16, 2013 1:43 pm

gordon77 wrote:
jamesh wrote:Can you try signal_mode2

I had to make a change and couldn't figure out how to reuse the same branch (its a long story) so created a new one.

To get a list of branches

git br
Thanks that worked. it's now busy building..........

I wish I knew what I was doing :D
Me too.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

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

Re: New version of Raspistill

Wed Oct 16, 2013 2:04 pm

Hello gordon77,
if you start raspistill without arguments the program will output the version in the first output line.
(you can run "raspistill 2>&1| head -1" to get only the first line)

For the update and upgrade I guess:
rapistill is part of the "firmware"(v1.3.3) and it is included in the package libraspberrypi-bin(v1.2).
I think raspistill will be overwritten if you run rpi-update (when it finds a new firmware version) and it would be overwritten if the libraspberrypi-bin package would be upgraded (apt-get update && apt-get upgrade). But you will find the binary you have compiled in the userland folder and running buildme again will reinstall your compiled version.

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

Re: New version of Raspistill

Wed Oct 16, 2013 2:26 pm

ethanol100 wrote:Hello gordon77,
if you start raspistill without arguments the program will output the version in the first output line.
(you can run "raspistill 2>&1| head -1" to get only the first line)

For the update and upgrade I guess:
rapistill is part of the "firmware"(v1.3.3) and it is included in the package libraspberrypi-bin(v1.2).
I think raspistill will be overwritten if you run rpi-update (when it finds a new firmware version) and it would be overwritten if the libraspberrypi-bin package would be upgraded (apt-get update && apt-get upgrade). But you will find the binary you have compiled in the userland folder and running buildme again will reinstall your compiled version.
Thanks, it all seems to have completed building now. How do I run the new version of raspistill ?
When I installed a recent version it went in / home/pi and I used ./raspistill but this time I see that version hasn't changed but there is version with todays date in /userland/build/bin.

Thanks for the help :D

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

Re: New version of Raspistill

Wed Oct 16, 2013 3:03 pm

If you have not edited the buildme script, it has called make install. Then is installed at /opt/vc/bin/raspistill, so just running "raspistill" should use the right version. So you can now try i.e. "raspistill -v -s -t 0 -o test.jpg" and in a new terminal test "kill -USR1 `pgrep raspistill`". If you have disabled make install, then you need to change to the userland/build/bin directory and execute ./raspistill there.

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

Re: New version of Raspistill

Wed Oct 16, 2013 3:22 pm

ethanol100 wrote:If you have not edited the buildme script, it has called make install. Then is installed at /opt/vc/bin/raspistill, so just running "raspistill" should use the right version. So you can now try i.e. "raspistill -v -s -t 0 -o test.jpg" and in a new terminal test "kill -USR1 `pgrep raspistill`". If you have disabled make install, then you need to change to the userland/build/bin directory and execute ./raspistill there.
Thanks, I tried this. Raspistill is running and if I try the kill I get:

bash: kill: pgrep raspistill: arguments must be process or job ID, and raspistill carries on running.

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

Re: New version of Raspistill

Wed Oct 16, 2013 3:29 pm

Then you can try to find the process id manual with "ps -ef | grep raspi". The second column of the line with raspistill is the process id.
i.e. "pi 3003 2946 0 15:28 pts/3 00:00:00 raspistill -v"
Now you can run "kill -USR1 3003".

(It needs to be backticks ` around the pgrep raspistill, because it needs to execute "pgrep raspistill" to find the process id and the output is than used for the kill command line.)

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

Re: New version of Raspistill

Wed Oct 16, 2013 10:50 pm

In more 'exciting' news, I've now modified raspivid to toggle from record to pause and vica versa using similar actions (keypress, signal and timed). Its in the video_pause branch of my userland repo. The docs have been updated on that branch to show how to use it. If anyone has time to test that would be appreciated.

Might be useful for surveillance cams - you can 'unpause' on a PIR for example.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

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

Re: New version of Raspistill

Thu Oct 17, 2013 1:05 am

Great work! If anyone else wants to try it, just do the below, which compiles and also installs the new code for immediate use.

Code: Select all

git clone https://github.com/JamesH65/userland
cd userland
git fetch origin
git checkout -b video_pause origin/video_pause
./buildme
I did a quick test of toggling pause/record using keyboard trigger, and also signal trigger (kill -SIGUSR1 <PID>) and found them to work as expected. Don't forget the '-t 0' unless you want a specific timeout (can kill with Ctrl-C or kill -9 <PID>). With the start/stop record feature, now it could be used like a real camcorder.
raspivid -w 256 -h 256 -k -t 0 -o test2.h264
raspivid -w 256 -h 256 -s -t 0 -o test3.h264 &
I think this new control is a very useful feature. Just thinking out loud -for possible record-control by more than one process, the toggle action might be tricky to manage, but I guess I could easily enough modify the code so it takes SIGUSR1 to start recording (with no effect if already recording) and SIGUSR2 to pause recording (with no effect if already paused).

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

Re: New version of Raspistill

Thu Oct 17, 2013 8:42 am

After the fetch, you can just do

git checkout video_pause

Since 1.6 GIT will automatically connect that to the remote branch.

I did wonder about using a second signal for pause, but wasn't sure of a use case that wasn't covered by the current version. I'm sure there is one!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

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

Re: New version of Raspistill

Thu Oct 17, 2013 10:22 am

Thank you, it is a very nice feature for raspivid.

Could we also have a switch to set if the initial mode is paused or started?
Would it be possible to record only while a key is pressed?
And a last feature request, would it be possible to just capture one image after receiving the signal? Then we could use this to generate a time-lapse video mode with fps lower than one.
(I guess: no,no,no. Because the wait function is not coupled to frames,we are using wait to switch and therefore changes like key press cannot be monitored and the camera exposure thing could be a problem.)

I have tried to capture a 1 fps video using

Code: Select all

(raspivid -s -fps 2 -t 60000 -o /tmp/test.h264 &); sleep 0.5;for i in {0..120}; do kill -USR1 `pgrep raspivid`; sleep 0.5; done
which seems to work somehow, I just have lost some frames.

I think of creating a PIV(http://en.wikipedia.org/wiki/Particle_image_velocimetry) like system to monitor sand dunes or something, taking two pictures which are short time delay to calculate a velocity field and then wait some time, so you could watch motion on two time scales.(Sorry, my point of view is biased from my research..)

There is a difference between checkout -b and checkout without the -b switch, without -b I think it would merge the changes in your active local branch with the remote ones. In this case it is not important, but it would be a difference, if we have changed something. (I'm relative new to git, so not really sure about it.)
Last edited by ethanol100 on Thu Oct 17, 2013 10:32 am, edited 1 time in total.

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

Re: New version of Raspistill

Thu Oct 17, 2013 10:27 am

ethanol100 wrote:Thank you, it is a very nice feature for raspivid.

Could we also have a switch to set if the initial mode is paused or started?
Would it be possible to record only while a key is pressed?
And a last feature request, would it be possible to just capture one image after receiving the signal? Then we could use this to generate a time-lapse video mode with fps lower than one.
(I guess: no,no,no. Because the wait function is not coupled to frames,we are using wait to switch and therefore changes like key press cannot be monitored and the camera exposure thing could be a problem.)

I have tried to capture a 1 fps video using

Code: Select all

(raspivid -s -fps 2 -t 60000 -o /tmp/test.h264 &); sleep 0.5;for i in {0..120}; do kill -USR1 `pgrep raspivid`; sleep 0.5; done
which seems to work somehow, I just have lost some frames.

There is a difference between checkout -b and checkout without the -b switch, without -b I think it would merge the changes in your active local branch with the remote ones. In this case it is not important, but it would be a difference, if we have changed something. (I'm relative new to git, so not really sure about it.)
Initial mode would be possible. The others not so sure.

As to the git command, I had assumed there was no local branch already named after the remote one. Although -b simply creates a branch during the checkout (same as git br <name> then git checkout <name>) I think, so if a local branch already exists with the same name, I am not sure what happens.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

poing
Posts: 1132
Joined: Thu Mar 08, 2012 3:32 pm

Re: New version of Raspistill

Thu Oct 17, 2013 10:39 am

This seems to work. I also found something interesting.

I ssh into the Pi with putty. I then give the command

Code: Select all

raspivid -w 256 -h 256 -k -t 0 -o test2.h264
and the video capture starts. If I then quickly double click the test2.h264 file in Windows Explorer VLC opens with the video playing while it's being recorded. I always thought it's impossible to both record and watch the video but that now seems to work!

When I press Enter the capture stops while VLC continues to play until the lag is completed and then ends. I need a lag of about 2 seconds when starting VLC, otherwise VLC will end after about a second. The lag seems to be quickly increasing while playing, not sure how to prevent that.

Edit: -fps 25 seems to do the trick; a constant 2 second lag.

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

Re: New version of Raspistill

Thu Oct 17, 2013 11:09 am

Record/play is fine - you can open a file being written to by one process, in read only mode in another process (same process?). PVR's do it all the time and they generally run Linux.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

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

Re: New version of Raspistill

Thu Oct 17, 2013 3:58 pm

Just pushed an update to the video_pause branch to allow the initial state of the camera to be defined, so if people can give that a go, if I don't get any nasty bug reports before tomorrow I'll send a pull request to Dom to get this changed merge to the Raspi Userland.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

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

Re: New version of Raspistill

Thu Oct 17, 2013 4:59 pm

jamesh wrote:Just pushed an update to the video_pause branch to allow the initial state of the camera to be defined, so if people can give that a go, if I don't get any nasty bug reports before tomorrow I'll send a pull request to Dom to get this changed merge to the Raspi Userland.
Tank you!
I have quickly tested the updated version and for me it is working very well.
Now I can start and wait for something interesting to occur.

(Could you write somewhere in the docs, that you can only choose between -k and -s and not both at the same time. A check for incompatible input parameter would be a nice feature for the future.)

Return to “Camera board”