c++ - Segmentation fault when using CMVision-based -


i'm working computer vision project, , problem lies in function takes mode (for color) , segmentation pointer arguments. segmentation class - http://pastebin.com/z5d5pkqx , here if piece of code fails on me:

pair<cv::point, cv::point> blobfind(int mode, segmentation * segment){ segmentation segm(640, 480); segment->encoderuns(); segment->connectcomponents(); segment->extractregions(); segment->sortregions(); //cout << "& " << endl; if(mode==1){     //cout << "& " << endl; int x1,x2,y1,y2; if(segment->colors[orange].list!=null){     x1 = segment->colors[orange].list->x1;     y1 = segment->colors[orange].list->y1;     x2 = segment->colors[orange].list->x2;     y2 = segment->colors[orange].list->y2;     cout << y1 << endl;     return make_pair(cv::point(x1,x2), cv::point(y1,y2));     } 

and main calling function looks this:

int main() { image_context *ic; xevent event; cv::mat image; cv::videocapture cap(0); cap.set( cv_cap_prop_frame_width, 640 ); cap.set( cv_cap_prop_frame_height, 480 ); height = 480; width = 640; pair<cv::point, cv::point> nxt; segmentation segm( width, height ); segmentation * segment = &segm; // creating new window ic = new_window( "video", 100, 100, width, height ); ximage *ximage1 = ic->ximage; unsigned char *imageline1 = (unsigned char*) ximage1 -> data;  while( !end ) {     cap.read(image);     data = image.data;     segment->readthresholds("conf");     segment->thresholdimage(data);     nxt = blobfind(1, segment); 

the segmentation fault occurs when code reaches point : segment->sortregions(); inside blobfind function. (segment->readthresholds("conf"); , segment->thresholdimage(data); used inside function too, , gave function data additional field. clues might causing it? when run same sequence (encoderuns, connectcomponents, extractregions,sortregions) inside main loop, works perfectly.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -