Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SUCCESS getting and setting parameters (focus, hue) for IIDC VideoDigitizer instances.



Ok, so a couple people have asked on this list how to actually set parameters on IIDC cameras, since the old, convenient, one-line calls like VDSetHue() apparently don't work on IIDC cameras, and there were no one-line calls for things like setting the focus on any cameras before IIDC.

Well, after four days(!) of mucking around in mostly-undocumented code, I've figured out how to get and set values. A couple of other people have posted their versions of getting values (but not setting), but I'm posting both here for completeness.

This code gets the current value for the depth of focus on the connected IIDC camera and prints a bunch of info about it, then sets the focus depth to be manually at 0.1 (on a scale of 0 to 1).

I've split this up into two messages since the mailing list hates messages over 8K.

-Wil Shipley
Delicious Monster Software


long version;
OSErr result = Gestalt(gestaltQuickTime, &version); // check the version of QuickTime installed
if ((result == noErr) && (version >= 0x06408000)) { // we have version 6.4 -- so we can set autofocus off!

VideoDigitizerComponent videoDigitizerComponent = SGGetVideoDigitizerComponent(sequenceGrabberChannel);
NSLog(@"VideoDigitizerComponent %x", videoDigitizerComponent);

{ // Dump the features to make sure we understand what's going on
long width, height;
err = VDGetPreferredImageDimensions(videoDigitizerComponent, &width, &height);
if (err == noErr)
NSLog(@"VDSetPreferredImageDimensions %d %d ", width, height);
else if (err != digiUnimpErr)
NoteErr(err);

QTAtomContainer iidcFeaturesAtomContainer = NULL;
#define DUMP_ONE_FEATURE
#ifdef DUMP_ONE_FEATURE
err = VDIIDCGetFeaturesForSpecifier(videoDigitizerComponent, vdIIDCFeatureFocus, &iidcFeaturesAtomContainer);
#elif defined(DUMP_ALL_FEATURES)
err = VDIIDCGetFeatures(videoDigitizerComponent, &iidcFeaturesAtomContainer);
#else // dump default features
err = VDIIDCGetDefaultFeatures(videoDigitizerComponent, &iidcFeaturesAtomContainer);
#endif
NoteErr(err);
NSLog(@" VDIIDCGetFeaturesForSpecifier %d",iidcFeaturesAtomContainer);
if (iidcFeaturesAtomContainer != 0) {

QTLockContainer(iidcFeaturesAtomContainer);

unsigned long childIndex = QTCountChildrenOfType(iidcFeaturesAtomContainer, kParentAtomIsContainer, vdIIDCAtomTypeFeature);
NSLog(@" feature count %d",childIndex);
while (childIndex--) {
short ignoredIndex;
QTAtom currentFeatureAtom = QTFindChildByID(iidcFeaturesAtomContainer, kParentAtomIsContainer, vdIIDCAtomTypeFeature, childIndex+1, &ignoredIndex);

printf("feature index %lu: ", childIndex+1);

long dataSize = 0;
Ptr atomData = NULL;

QTAtom currentFeatureTypeAndIDAtom = QTFindChildByID(iidcFeaturesAtomContainer, currentFeatureAtom, vdIIDCAtomTypeFeatureAtomTypeAndID, vdIIDCAtomIDFeatureAtomTypeAndID, &ignoredIndex);
printf("feature type %x\n", (unsigned int)currentFeatureTypeAndIDAtom);
err = QTGetAtomDataPtr(iidcFeaturesAtomContainer, currentFeatureTypeAndIDAtom, &dataSize, &atomData);
NoteErr(err);
VDIIDCFeatureAtomTypeAndID *featureAtomTypeAndID = (void *)atomData;

printf(" feature '%c%c%c%c' of group '%c%c%c%c' has name '%s', settings in type '%c%c%c%c'\n", (char)(featureAtomTypeAndID->feature >> 24 & 0xff), (char)(featureAtomTypeAndID->feature >> 16 & 0xff), (char)(featureAtomTypeAndID->feature >> 8 & 0xff), (char)(featureAtomTypeAndID->feature >> 0 & 0xff), (char)(featureAtomTypeAndID->group >> 24 & 0xff), (char)(featureAtomTypeAndID->group >> 16 & 0xff), (char)(featureAtomTypeAndID->group >> 8 & 0xff), (char)(featureAtomTypeAndID->group >> 0 & 0xff), featureAtomTypeAndID->name, (char)(featureAtomTypeAndID->atomType >> 24 & 0xff), (char)(featureAtomTypeAndID->atomType >> 16 & 0xff), (char)(featureAtomTypeAndID->atomType >> 8 & 0xff), (char)(featureAtomTypeAndID->atomType >> 0 & 0xff));

QTAtom currentFeatureSettingsAtom = QTFindChildByID(iidcFeaturesAtomContainer, currentFeatureAtom, featureAtomTypeAndID->atomType, featureAtomTypeAndID->atomID, &ignoredIndex);
printf(" feature atom %x\n", (unsigned int)currentFeatureSettingsAtom);

dataSize = 0;
atomData = NULL;
err = QTGetAtomDataPtr(iidcFeaturesAtomContainer, currentFeatureSettingsAtom, &dataSize, &atomData);
NSLog(@"atomData %x, dataSize %d, struct size %d", atomData, dataSize, sizeof(VDIIDCFeatureSettings));
NoteErr(err);
if (featureAtomTypeAndID->atomType == vdIIDCAtomTypeFeatureSettings) {
NSParameterAssert(sizeof(VDIIDCFeatureSettings) == dataSize);
VDIIDCFeatureSettings *featureSettings = (void *)atomData;

NSString *_dumpFlags(UInt32 flags) {
NSMutableString *newString = [NSMutableString string];
if (flags & vdIIDCFeatureFlagOn)
[newString appendString:@"On "];
if (flags & vdIIDCFeatureFlagOff)
[newString appendString:@"Off "];
if (flags & vdIIDCFeatureFlagManual)
[newString appendString:@"Manual "];
if (flags & vdIIDCFeatureFlagAuto)
[newString appendString:@"Auto "];
if (flags & vdIIDCFeatureFlagTune)
[newString appendString:@"Tune "];
if (flags & vdIIDCFeatureFlagRawControl)
[newString appendString:@"Raw "];
if (flags & vdIIDCFeatureFlagAbsoluteControl)
[newString appendString:@"Absolute "];

return newString;
}

printf(" capabilities: flags %x %s, rawMinimum %d , rawMaximum %d, absoluteMinimum %f, absoluteMaximum %f\n", (unsigned int)featureSettings->capabilities.flags, [_dumpFlags(featureSettings->capabilities.flags) cString], (int)(featureSettings->capabilities.rawMinimum), (int)(featureSettings->capabilities.rawMaximum), (float)(featureSettings->capabilities.absoluteMinimum), (float)(featureSettings->capabilities.absoluteMaximum));
printf(" state: flags %x %s, value %f\n", (unsigned int)featureSettings->state.flags, [_dumpFlags(featureSettings->state.flags) cString], (float)(featureSettings->state.value));

} else if (featureAtomTypeAndID->atomType == vdIIDCAtomTypeFocusPointSettings) {
VDIIDCFocusPointSettings *focusPointSettings = (void *)atomData;

printf(" state: focusPoint %d %d\n", focusPointSettings->focusPoint.v, focusPointSettings->focusPoint.h);
}
}

QTUnlockContainer(iidcFeaturesAtomContainer);
}
}
}
_______________________________________________
quicktime-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/quicktime-api
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.