c++ - OpenCV Help - Error: no operator "=" Matches these operands. operand types are cv::Mat = IplImage* -


i have started learning how use opencv , have been following tutorials hosted website. using opencv 3.0, however, seems of tutorial information out of date.

i , on tutorial "cascade classifier" link: http://www.docs.opencv.org/doc/tutorials/objdetect/cascade_classifier/cascade_classifier.html

they provided example code not running me , cannot understand why. have provided code example below:

 #include "opencv2/objdetect/objdetect.hpp"  #include "opencv2/highgui/highgui.hpp"  #include "opencv2/imgproc/imgproc.hpp"   #include <iostream>  #include <stdio.h>   using namespace std;  using namespace cv;   /** function headers */  void detectanddisplay( mat frame );   /** global variables */  string face_cascade_name = "haarcascade_frontalface_alt.xml";  string eyes_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";  cascadeclassifier face_cascade;  cascadeclassifier eyes_cascade;  string window_name = "capture - face detection";  rng rng(12345);   /** @function main */  int main( int argc, const char** argv )  {    cvcapture* capture;    mat frame;     //-- 1. load cascades    if( !face_cascade.load( face_cascade_name ) ){ printf("--(!)error loading\n"); return -1; };    if( !eyes_cascade.load( eyes_cascade_name ) ){ printf("--(!)error loading\n"); return -1; };     //-- 2. read video stream    capture = cvcapturefromcam( -1 );    if( capture )    {      while( true )      {    frame = cvqueryframe( capture );     //-- 3. apply classifier frame        if( !frame.empty() )        { detectanddisplay( frame ); }        else        { printf(" --(!) no captured frame -- break!"); break; }         int c = waitkey(10);        if( (char)c == 'c' ) { break; }       }    }    return 0;  }  /** @function detectanddisplay */ void detectanddisplay( mat frame ) {   std::vector<rect> faces;   mat frame_gray;    cvtcolor( frame, frame_gray, cv_bgr2gray );   equalizehist( frame_gray, frame_gray );    //-- detect faces   face_cascade.detectmultiscale( frame_gray, faces, 1.1, 2, 0|cv_haar_scale_image, size(30, 30) );    for( size_t = 0; < faces.size(); i++ )   {     point center( faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5 );     ellipse( frame, center, size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, scalar( 255, 0, 255 ), 4, 8, 0 );      mat faceroi = frame_gray( faces[i] );     std::vector<rect> eyes;      //-- in each face, detect eyes     eyes_cascade.detectmultiscale( faceroi, eyes, 1.1, 2, 0 |cv_haar_scale_image, size(30, 30) );  for( size_t j = 0; j < eyes.size(); j++ )  {    point center( faces[i].x + eyes[j].x + eyes[j].width*0.5, faces[i].y + eyes[j].y + eyes[j].height*0.5 );    int radius = cvround( (eyes[j].width + eyes[j].height)*0.25 );    circle( frame, center, radius, scalar( 255, 0, 0 ), 4, 8, 0 );  }   }   //-- show got   imshow( window_name, frame );  } 

the error me arises on line 38 "frame = cvqueryframe( capture );" "=" underlined red , gives error message displayed in title of question

i'm sorry if code not displayed correctly, first time asking question.

no fear, it's not fault, - stumbled on outdated tutorial code, arcane c-api no more adequate today(and won't work 3.0).

please replace :

   cvcapture* capture;    capture = cvcapturefromcam( -1 );    if( capture )    { 

with:

   videocapture capture(-1);    if (capture.isopened())    { 

and:

   frame = cvqueryframe( capture ); 

with:

   capture.read(frame); 

also, opencv3.0 docs: http://docs.opencv.org/ref/master/

(your sample code 2.4.x)


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -