I want to read images from a video camera using OpenCv

Hello, Thank you always.

I am studying oF using technical books.
The code written for that book does not work well again.

I get an error [No matching member function for call to ‘setFromPixels’] in [setFromPixels ()].

#pragma once

#include "ofMain.h"
#include "ofxOpenCv.h"

class ofApp : public ofBaseApp{

	void setup();
	void update();
	void draw();

	void keyPressed(int key);
	void keyReleased(int key);
	void mouseMoved(int x, int y );
	void mouseDragged(int x, int y, int button);
	void mousePressed(int x, int y, int button);
	void mouseReleased(int x, int y, int button);
	void mouseEntered(int x, int y);
	void mouseExited(int x, int y);
	void windowResized(int w, int h);
	void dragEvent(ofDragInfo dragInfo);
	void gotMessage(ofMessage msg);

ofVideoGrabber vidGrabber;
ofxCvColorImage colorImg;


#include "ofApp.h"

void ofApp::setup(){

ofBackground(0, 0, 0);

vidGrabber.initGrabber(320, 240);



void ofApp::update(){

bool bNewFrame = false;
bNewFrame = vidGrabber.isFrameNew();

    colorImg.setFromPixels(vidGrabber.getPixels(), 320, 240);


void ofApp::draw(){



It is like this

please tell me.

Hi samurai.
The code you are trying to use is out-of-date.
vidGrabber.getPixels() now return a ofPixels object not an unsigned * char.
So, try to use setPixels(vidGrabber.getPixels()) instead setPixels(vidGrabber.getPixels,320,240).


Thank you very much.:slight_smile:

We successfully worked with vidGrabber.getPixels () instead of (vidGrabber.getPixels, 320, 240).