c++ - Weird crash when I try to attribute a variable in OpenCV IOS -
there i'm not able understand. i'm using opencv ios ios device.
i have c++ class private variable cv::rect . variable located .h file. in .cpp file, have method creates cv::rect. then, attribute new created cv::rect class variable crashs , not understand why.
.h file
class detection {   public:     detection();      cv::mat processimage(cv::mat frame);      cv::mat detectface(cv::mat frame);  public:     cv::rect getrectangledetection();     void setrectangledetection(cv::rect& rect);   private:     cv::rect _rectangedetect;  };   .cpp file
    cv::mat detection::processimage(cv::mat frame){      mat originalcolorimage;     frame.copyto(originalcolorimage);     int cx = frame.cols/2;     int cy = frame.rows/2;     int width = 1000;     int height = 1000;     nslog(@"[info] rectangle creation");      cv::rect rect1(cx-width/2,  cy-height/2, width,height);      cv::rect test2;     //test2 = rect1;//it works !      setrectangledetection(rect1); // or _rectangedetect = rect1 --> both don't work      cv::rectangle( originalcolorimage,rect1,                   cv::scalar(255, 0, 0),4);        return originalcolorimage; }   i took @ crash report , saw :
exception type:  exc_bad_access (sigsegv) exception subtype: kern_invalid_address @ 0x0000000000000000 triggered thread:  0  filtered syslog: none found  thread 0 name:  dispatch queue: com.apple.main-thread thread 0 crashed: 0   detect          0x000000010007f580 cv::rect_<int>::operator=(cv::rect_<int> const&) (types.hpp:1689) 1   detect          0x000000010007f504 opencv::setrectangledetection(cv::rect_<int>) (opencv.mm:172) //this setter if i'm not using setter error come _rectangledetect = rect1.   i tried initialize variable cv::rect same behavior.
do have idea what's happen ? really, tried figure out why without success. used lot opencv before , it's first time happens.
thank !
okey found problem. silly one. actually, on other class when using detection class, forgot initialize object.
detection _detect = new detection()   as did not error following line , fact behavior seemed (even debug), did not think of that.
_detect->processimage(frame);   thank guys anyway.
Comments
Post a Comment