Tutorial: persistent camera settings

Chris French cfrench at rvsi.net
Tue Mar 22 09:08:33 GMT 2005



>    1. Tutorial: persistent camera settings  (was Re: Checking, no
>       rush,	on my open questions) (Julien Letessier)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 21 Mar 2005 23:23:21 +0100
> From: Julien Letessier <lists at mezis.net>
> Subject: Tutorial: persistent camera settings  (was Re: Checking, no
> 	rush,	on my open questions)
> To: IOXperts Video Developers Discussion List
> 	<video-developers at mailman.ioxperts.com>
> Message-ID: <da90d560ad6edcc3a4e9da419ef17ddc at mezis.net>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
>
>
> On 6 Sep 2004, at 20:50, Hank Roberts wrote:
>
>> Unibrain cameras:
>>   Their support (finally) told me their  "fire-i" camera settings last
>> only as long as the application changing them is open.  Unibrain makes
>> a Windows app that supposedly saves and reloads settings, but again
>> the settings are lost when that app closes.  No other app can save
>> settings and reapply them.
>
> Hi all,
>
> This seems to be a recurrent question, and the aforementioned lack of
> persistence is true for several other cameras in addition to the fire-i
> (e.g. some Sonys and Marlins, and at least one of my ToUcams).
>
> So here's a rough sketch the solution I use for persistence of camera
> settings.
>
> I'm not saying that this is the one way to go, as this obviously works
> only if you're using the SG (as I don't really dig VDigs), like in the
> minimung, mungrab, sonofmungrab examples.
>
> * saving settings:
>
> 	- call SGSettingsDialog() or anything you use to modify the settings
> 	- use SGGetChannelSettings() to put all settings into a UserData
> 	- use PutUserDataIntoHandle() to serialize the UserData into a Handle
> 	- use CFDataCreate() to transform you memory chunk into a CFDataRef
> 	- use CFPreferencesSetAppValue(theKey, theCFSettings,
> kCFPreferencesCurrentApplication)
> 	  to associate theKey to your settings [1], for the current 
> application
> 	- don't forget to CFPreferencesAppSynchronize()
> 	  to save to the .plist file
>
> 	The tasks of locking/unlocking handles, and CFRelease'ing the right
> stuff, if left as an exercice to the reader ;)
>
> 	Once all's done settings are stored in the dictionary entry you
> specified (theKey), in the application's [2] preferences file (that's
> something like $HOME/Library/Preferences/com.gizmo.MyNiftyApp.plist)
>
> * restoring settings
>
> 	Basically it's the same, the other way around.
>
> 	- CFPreferencesCopyAppValue(theKey, kCFPreferencesCurrentApplication)
> 	  fetches back your binary data from the .plist preferences file
> 	- PtrToHand(CFDataGetBytePtr((CFDataRef)theCFSettings)
> 	  turns it back into a handle
> 	- NewUserDataFromHandle() gives you the UserData
> 	- finally, SGSetChannelSettings() restores the settings
>
> 	This should be done pretty soon after calling SGNewChannel(), while
> the SG isn't previewing/recording (yet).
>
> [1] I recommend you use a key built from the DeviceName and the
> InputName. Otherwise you're going to obtain very weird, mixed up
> settings when plugging in a different camera, possible even ruining a
> sensitive CCD. Don't laugh.
>
> [2] This means each { user, application, camera } combination gets
> unique persistent settings. This may or may not be what you're looking
> for; in the latter case, tinkering with the options of
> CFPreferencesSetAppValue() / CFPreferencesCopyAppValue() may provide
> other combinations (e.g. user / host / camera).
>
> G'd night,
> -- 
> Julien T. Letessier
> PhD Intern                   /\/\
> PRIMA group - GRAVIR-IMAG   / _ _\   http://www.mezis.net/
> IIHM group  - CLIPS-IMAG    \__._/   aim:jletessier
>
>
> ------------------------------
>
There is an Apple Q & A note on this subject that might help too. You 
could combine this with reading the GUID from the camera to allow 
saving of multiple camera preferences to an xml file. It certainly 
works for the Sony industrial cameras and Pyro webcams, I haven't tried 
any others yet.

http://developer.apple.com/qa/qa2001/qa1286.html

Good luck,

Chris French
RVSI Acuity
Nashua, NH 03063



More information about the Video-Developers mailing list