c# - How do I take an Screenshot of my camera on EMGUCV 3.1? -


i'm doing simple program on emgu cv, need take screenshot of camera recording , save in specific folder, here follows code of camera capture:

        imageviewer viewer = new imageviewer();          videocapture capture = new videocapture();          application.idle += new eventhandler(delegate (object sender, eventargs e)         {             viewer.image = capture.queryframe();         });         viewer.showdialog(); 

i apologize simple terms, still noob in programming.

it seems posted standard code emgucv wiki. let me try explain how can show video feed of webcam on computer , save screenshot when press button (you'll have create ui elements yourself). you'll need form picturebox element display image , button save snapshot.

i'll explain in code through comments , work standard emgucv code:

private capture capture; private bool takesnapshot = false;  public form1() {     initializecomponent(); }  private void form1_load(object sender, eventargs e) {     // make sure initialize webcam capture if capture element still null     if (capture == null)     {         try         {             // start grabbing data, change number if want use camera             capture = new capture(0);         }         catch (nullreferenceexception excpt)         {             // no camera has been found             messagebox.show(excpt.message);         }     }      // makes sure image fitted picturebox     originalimagecontainer.sizemode = pictureboxsizemode.stretchimage;      // when capture initialized, start processing images in porcessframe method     if (capture != null)         application.idle += processframe; }  // registered method, whenever application idle, method called. // allows process new frame during time. private void processframe(object sender, eventargs arg) {     // newest webcam frame     image<bgr, double> capturedimage = capture.queryframe();     // show in picturebox. if don't want convert bitmap should use imagebox (which emgucv element)     originalimagecontainer.image = capturedimage.tobitmap();      // if button clicked indicating want snapshot, save image     if(takesnapshot)     {         // save image         capturedimage.save(@"c:\your\picture\path\image.jpg");         // set bool false again make sure take 1 snapshot         takesnapshot = !takesnapshot;     } }  //when clicking save button private void savebutton_click(object sender, eventargs e) {     // set bool true, on next frame processing frame saved     takesnapshot = !takesnapshot; } 

hope helps you. let me know if still unclear!


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -