ofSystem() windows

I guess this is really basic, but I have a few questions about ofSystem().

I need to record and play files from the kinect2 in my application, I found there is a command line utility to do this called KSUtil. It works perfectly with the ofxKinectForWindows2 addon, but I want to control this all from within my OF app.

I have added a path to KSUtil to my PATH variable and from the normal command line I can call this

KSUtil -play d:\Kinect\20170111_073508_00.xef

and it works perfectly, I thought I could call this from ofSystem(), but it does not work, I get an error that the specified file cannot be found. Is there some difference between what happens via ofSystem() and just using the command line?

Also how can I deal with white spaces in file paths when using ofSystem(), I get errors in other instances from having spaces in file paths and names, but I would like to be able to handle these as well.

Cheers

fred

I had a similar issue. Just switched the backslash to a common slash.

the \ in strings means escape the following character, for example \t means tab or \n means break line so if you use backslahes the next character is interpreted as an special character.

usually a forward slash works but also using a double backslash like:

ofSystem("KSUtil -play d:\\Kinect\\20170111_073508_00.xef");

Cheers, double slashes or the forward slash solved the problem.

Also just noticed that calling cout<<“KSUtil -play d:\Kinect\20170111_073508_00.xef”<<endl will also execute the command, is that normal?

Ok, the string works fine when I type it in but I want to get the path from an

ofOpenFileDialogueResult

if (key == ‘o’) {
kinectFilePath = “”;
//Open the Open File Dialog
ofFileDialogResult openFileResult = ofSystemLoadDialog(“Select a jpg or png”);

	//Check if the user opened a file
	if (openFileResult.bSuccess) {

		ofLogVerbose("User selected a file");

		//We have a file, check it and process it
		kinectFilePath += openFileResult.getPath();
		std::replace(kinectFilePath.begin(), kinectFilePath.end(), '/','\\');

		kinectFilePath = "KSUtil - play " + kinectFilePath;
		ofSystem(kinectFilePath);
	}
	else {
		ofLogVerbose("User hit cancel");
	}
}

I am not sure how to manage this.