Quantcast
Channel: bugs, errors - openFrameworks
Viewing all articles
Browse latest Browse all 636

Conditional definition of ofVideoGrabber using preprocessors causes "Access Violation"?

$
0
0

@hsab wrote:

Hi everyone.

I'm trying to easily switch between ofVideoGrabber and ofVideoPlayer for debugging purposes using C++ preprocessors, namely #ifndef #ifdef etc. For some reason I get access violation when I actually intend to use the webcam (when USECAM is indeed defined), but ofVideoPlayer works fine.

This is happening at line 51 of ofVideoGrabber.cpp:

50        if( requestedDeviceID >= 0 ){
51	             grabber->setDeviceID(requestedDeviceID);
52        }

I know this is C++ specific question, probably something going on with the pointer, but I would highly appreciate if someone can help out and point me in the right direction.

I have a piece of code like this in my ofApp.cpp:

#ifndef USECAM
#define USECAM
#endif

#include "ofApp.h"

void ofApp::setup() {
	#ifdef USECAM
	simpleCam.setup(640, 480, true);
	#else
	simpleCam.load("movies/test3.mp4");
	//simpleCam.setVolume(0);
	simpleCam.setLoopState(OF_LOOP_NORMAL);
	simpleCam.play();
	#endif
    ...
}

And I have the following in my ofApp.h:

class ofApp : public ofBaseApp {
public:
	...
	// Camera
	#ifdef USECAM
	ofVideoGrabber		simpleCam;
	#else
	ofVideoPlayer		simpleCam;
	#endif
    ...
}

Thanks in advance.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 636

Trending Articles