Using frames from ofxIpVideoGrabber [solved]

I’m trying to use video from ofxIpVideoGrabber as a source for ofxCv operations. I’m having trouble with the image types for RunningBackground. Here’s an overview of the types i’m using in testApp.h

 ofxCv::RunningBackground background;
ofImage thresholded;
SharedIPVideoGrabber grabber;
ofImage grabFrame;
//cv::Mat greyFrame;

and this is where I’m having trouble in the testApp.cpp:

void testApp::update() {
	// update the cameras
    grabFrame = grabber->getPixelsRef();
    //convertColor(grabFrame, greyFrame, CV_RGB2GRAY);
    background.update(grabFrame, thresholded);

The code compiles, but breaks down at runtime. The error I get is:

OpenCV Error: Assertion failed (dst.size == src.size && dst.channels() == cn) in accumulateWeighted, file /Users/theo/Downloads/OpenCV-2.3.1/modules/imgproc/src/accum.cpp, line 426

which points back to:

//! updates the running average (dst = dst*(1-alpha) + src*alpha)
CV_EXPORTS_W void accumulateWeighted( InputArray src, InputOutputArray dst,
                                      double alpha, InputArray mask=noArray() );

which is called from background.update(cv::Mat, cv::Mat&);

I think i’ve tried a few data types for the background.update, including ofPixels, ofImage, and cv::Mat (which i produced with convertColor function, commented out above.

I’ve been banging my head against this for a few days now. Any help is much appreciated!.

After reading around more, I’m trying to pull the IP video using the cv::VideoCapture class, based on this thread.

Here’s how I’m setting it up:

in testApp.h:

#include "ofMain.h"
#include "ofxCv.h"
#include <cv.h>
#include <highgui.h>
#include <opencv2/core/core.hpp>

    cv::VideoCapture vcap;
    cv::Mat src;
    cv::Mat thresholded;
    ofImage viewImage;

in the testApp.cpp:

in setup:"");

in update:;
background.update(src, thresholded);
ofxCv::toOf(thresholded, viewImage);

There are no errors in the code, but I’m getting linker errors at compile time, all related to the cv::VideoCapture calls.

Undefined symbols for architecture i386:
  "cv::VideoCapture::read(cv::Mat&)", referenced from:
      testApp::update() in testApp.o
  "cv::VideoCapture::open(std::string const&)", referenced from:
      testApp::setup() in testApp.o
  "cv::VideoCapture::VideoCapture()", referenced from:
      testApp::testApp() in main.o
  "cv::VideoCapture::~VideoCapture()", referenced from:
      testApp::testApp() in main.o
      testApp::~testApp() in testApp.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I’m on osx 10.8.5, oF 0.8.0, xcode 5. Target for the app is 10.8, target for oF is 10.8. Let me know if you need more information. Thanks so much to all.

(edit) I also tried rebuilding it with the project generator,… same errors

I changed the name of thread to hopefully attract help. I’ve seen some options on this forum for using data from IP cameras, but nothing difinitive, and nothing that has worked for me. Help please :smile:

Replied here. Hope it helps.

I think i’ve got this figured out…
one of the issues is that ofxCv::RunningBackground's update function expects a three or four channel source image (color!). I was purposefully setting it to grayscale before using the update function. that fixed most of it. I also changed how i was setting up the grabFrame ofImage. I’m now using setFromPixels and explicitly calling the image type (OF_IMAGE_COLOR = 3 channels)

in testApp.h:

ofxCv::RunningBackground background;
ofImage thresholded;
SharedIPVideoGrabber grabber;
ofImage grabFrame;

in testApp.cpp:

grabber->update //update the IPVideoGrabber    
grabFrame.setFromPixels(grabber->getPixels(), 320, 240, OF_IMAGE_COLOR);
background.update(grabFrame, thresholded);