0

I'm using OpenCV to do face recognition. I'm having a problem in that I cannot delete a JPEG file when I click the first button (i.e., button1_Click fires) a second time. Below is the code I have:

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

    **remove("frame1.jpg");**
    VideoCapture cap(0); // open the default camera

    flag=true;
    while(flag)
    {
        cap >> frame;

        imshow("Camera Preview", frame);
        waitKey(30);
    }

}

private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
    flag=false;
    imwrite("frame1.jpg",frame); //create file panel

    this->panel1->BackgroundImage = System::Drawing::Image::FromFile("frame1.jpg"); //show frame in panel1
    destroyWindow("Camera Preview");
}

What should I do?

mevatron
  • 13,911
  • 4
  • 55
  • 72
alohauhu
  • 31
  • 2
  • 3

1 Answers1

0

You need to check to see that the file actually exists before you delete it. Here is a tutorial on how to do this with C++/CLI. Here is the MSDN page for the method.

Enjoy :)

mevatron
  • 13,911
  • 4
  • 55
  • 72