c++ - How to close camera (OpenCv Beaglebone) -
good day,
i trying figure out how close camera on beaglebone in opencv. have tried numerous commands such release(&camera) none exist , camera continues stay on when don't want to.
videocapture capture(0); capture.set(cv_cap_prop_frame_width,320); capture.set(cv_cap_prop_frame_height,240); if(!capture.isopened()){ cout << "failed connect camera." << endl; } mat frame, edges, cont; while(1){ cout<<sending<<endl; if(sending){ for(int i=0; i<frames; i++){ capture >> frame; if(frame.empty()){ cout << "failed capture image" << endl; return 0; } cvtcolor(frame, edges, cv_bgr2gray); code this, @ end of loop, want close camera, of course still stays open
the camera deinitialized automatically in videocapture destructor.
check example opencv docu:
int main(int, char**) { videocapture cap(0); // open default camera if(!cap.isopened()) // check if succeeded return -1; mat edges; namedwindow("edges",1); for(;;) { mat frame; cap >> frame; // new frame camera cvtcolor(frame, edges, cv_bgr2gray); gaussianblur(edges, edges, size(7,7), 1.5, 1.5); canny(edges, edges, 0, 30, 3); imshow("edges", edges); if(waitkey(30) >= 0) break; } // camera deinitialized automatically in videocapture destructor return 0; } also
cvqueryframe
grabs , returns frame camera or file
iplimage* cvqueryframe( cvcapture* capture );
capture video capturing structure.
the function cvqueryframe grabs frame camera or video file, decompresses , > returns it. function combination of cvgrabframe , cvretrieveframe in 1 > call. the returned image should not released or modified user.
i hope works you. best of luck.
Comments
Post a Comment