Feeds:
Articoli
Commenti

Archive for febbraio 2014

Today I was writing a function to save a specific configuration file from an OF application and I noticed that ofSystemSaveDialog() (the function commonly used to open a save dialog) does not allow me to specify a default save path.

Since I wanted my files saved in a specific location, I quickly wrote a custom function that includes a path argument; it’s super easy and mac only (Objective C ++), but I thought someone could find it useful, so here it is:


ofFileDialogResult customSaveDialog(string defaultName, string messageName, string defaultPath){
ofFileDialogResult dr;

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSSavePanel * saveDialog = [NSSavePanel savePanel];

[saveDialog setMessage:[NSString stringWithUTF8String:messageName.c_str()]];

if(!defaultPath.empty()){
NSString * s = [NSString stringWithUTF8String:defaultPath.c_str()];
s = [[s stringByExpandingTildeInPath] stringByResolvingSymlinksInPath];
NSURL * defaultPathUrl = [NSURL fileURLWithPath:s];
[saveDialog setDirectoryURL:defaultPathUrl];
}

[saveDialog setNameFieldStringValue:[NSString stringWithUTF8String:defaultName.c_str()]];

NSInteger buttonClicked = [saveDialog runModal];

NSWindow * appWindow = (NSWindow *)ofGetCocoaWindow();
if(appWindow) {
[appWindow makeKeyAndOrderFront:nil];
}

if(buttonClicked==NSFileHandlingPanelOKButton){
dr.filePath = string([[[saveDialog URL] path] UTF8String]);
}
[pool drain];

if( dr.filePath.length() > 0 ){
dr.bSuccess = true;
dr.fileName = ofFilePath::getFileName(dr.filePath);
}
return dr;
}

Read Full Post »

Recently a client bought a Kinect to be used with an OpenFrameworks app I wrote for them; we were doing some normal depth tracking, so we did expect a smooth ride, but, after a few seconds from when the Kinect got plugged, the application froze.
To keep it short, it seems that the Kinect model 1473 (the one you’ll find in shops these days) comes with a new firmware that auto-disconnects the camera after a few seconds, causing a freeze whenever you plug it into a computer and try to use it with libfreenect; this of course means that most creative coding toolkits are affected by the problem: I did run into it using ofxKinect, but it will happen also with the libreenect based Cinder Block, Processing library, etc…

Luckily Theo Watson already came up with a solution: you can find a fixed libfreenect here or, if you’re using OF, you can update to the last version on github.
The fix will work also with the Kinect for Windows and, of course, it will not break compatibility with the older 1414 Kinects.
Finally, if you don’t know the model of your Kinect, this picture will explain how to check it out:

Read Full Post »