SnowLeopard
Posts: 106
Joined: Sun Aug 18, 2013 6:10 am

Rational (fraction) as shutter speed value

Sat Oct 26, 2013 8:51 pm

Hello,
I've put together a patch that adds a new command line option which takes rational number for the shutter speed value (ie 1/60). Here's the changed file: https://github.com/SnowLeopard71/userla ... mControl.c The new command line option is -ssr (or -shutterr) -- I used an extra 'r' for rational. Since the MMAL code already provides functions for manipulating rational numbers, it was pretty easy, even for a non-programmer.
The main reason I did this is in spite of not knowing much about photography, using a fraction for the shutter speed seems more "standard" (for lack of better term) than microseconds.
Here are the reported "Exposure times" (from exiftags):
3319/200000 sec = .016595 (1/60 = .016667)
1983/200000 sec = .009915 (1/100 = .01)
77/15625 sec = .004928 (1/200 = .005)

Questions for all of you:
Is this worth adding to the official code?
Is the option name okay or is there better name for it?
Should this usage replace the current option that uses microseconds?

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

Re: Rational (fraction) as shutter speed value

Sat Oct 26, 2013 9:01 pm

Is this worth adding to the official code? Yes
Is the option name okay or is there better name for it? Seems OK
Should this usage replace the current option that uses microseconds? No, l like using uSecs as well.

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

Re: Rational (fraction) as shutter speed value

Sun Oct 27, 2013 9:22 am

Look fine to me - as long as you are correctly cloned from the main repo you can submit a PR to get it merged to the main tree. No need to remove the us.

Thanks for the contribution.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

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

Re: Rational (fraction) as shutter speed value

Sun Oct 27, 2013 10:23 am

Looks like a great addition to me. Thanks!

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

Re: Rational (fraction) as shutter speed value

Sun Oct 27, 2013 11:36 am

Should be possible to search the parameter string for a / character and set accordingly, so avoiding the need to have two different commands.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

SnowLeopard
Posts: 106
Joined: Sun Aug 18, 2013 6:10 am

Re: Rational (fraction) as shutter speed value

Sun Oct 27, 2013 9:44 pm

jamesh wrote:Should be possible to search the parameter string for a / character and set accordingly, so avoiding the need to have two different commands.
Excellent suggestion! I didn't like the extra option I introduced at all and this way is much cleaner. Updated version is now on my github.
Help output reads: -ss, --shutter : Set shutter speed in microseconds or fraction of second (ie 1/60)
I removed the ssr/shutterr, so it only has one shutter option which looks for a '/' in the parameter. If no slash is found, the string is converted to int (atoi()) and value is assumed to be in microseconds. If a slash is found, the MMAL rational number functions are used to convert the fraction to an integer.
Using -ss 1000 and -ss 1/1000 generated images with identical Exposure Times according to exiftags (23/25000).

SnowLeopard
Posts: 106
Joined: Sun Aug 18, 2013 6:10 am

Re: Rational (fraction) as shutter speed value

Sun Oct 27, 2013 10:44 pm

Umm I did a pull request to have the change merged and I've just realized I didn't change the version number -- probably should have some other indication than the help output for the -ss option.
The other thing is that James' latest changes with respect to max bitrate and timeout haven't gone into the official code yet.

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

Re: Rational (fraction) as shutter speed value

Mon Oct 28, 2013 10:04 am

Hmm, I seem to have not put in a PR for those last changes. I've just done so.

Increasing the version number is pretty hit and miss - need to automate on each successful PR I think, but no idea how to do that. I've been trying to be more conscientious on incrementing but occasionally forget. Of course, when you have multiple contributions that cross, it get more complicated.

Did you update the .odt file as well (docs). If you didn't don't worry, I'll add it next time I make a change.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

SnowLeopard
Posts: 106
Joined: Sun Aug 18, 2013 6:10 am

Re: Rational (fraction) as shutter speed value

Mon Oct 28, 2013 4:55 pm

jamesh wrote:Did you update the .odt file as well (docs). If you didn't don't worry, I'll add it next time I make a change.
Oops, forgot about about the docs. :oops:

It also occurred to me we might want to add the shutter speed to raspicamcontrol_dump_parameters() somewhere.

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

Re: Rational (fraction) as shutter speed value

Mon Oct 28, 2013 6:02 pm

SnowLeopard wrote:
jamesh wrote:Did you update the .odt file as well (docs). If you didn't don't worry, I'll add it next time I make a change.
Oops, forgot about about the docs. :oops:

It also occurred to me we might want to add the shutter speed to raspicamcontrol_dump_parameters() somewhere.
Thought I had done that...bad memory!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

Arp
Posts: 26
Joined: Wed Sep 11, 2013 1:26 pm
Location: NRW, Germany

Re: Rational (fraction) as shutter speed value

Wed Jan 08, 2014 9:23 pm

Is this patch already in the new version? Or will it be implemented? I find it very usefull.

I just played around with raspivid and -ss 100000/30 yields a different result then -ss 33333... I guess it only takes the 100000 part, because the frames are much longer exposed.

Return to “Camera board”