videoInput *VI; int width,height,ID,index; unsigned char* resultBufer; bool HaveNewFrame,StarToWork; //initialization private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { this->VI = new videoInput(); this->ID = 1; this->index = 0; this->VI->setupDevice(ID); this->width = this->VI->getWidth(ID); this->height = this->VI->getHeight(ID); this->resultBufer = new unsigned char[this->width*this->height*3]; this->HaveNewFrame = false; this->StarToWork = false; this->backgroundWorker1->RunWorkerAsync(); } //show the image in the picturebox private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) { if (this->HaveNewFrame) { this->HaveNewFrame = false; IntPtr pt1(this->resultBufer); System::Drawing::Bitmap^ My_Vision = gcnew System::Drawing::Bitmap(this->width,this->height,this->width*3,Drawing::Imaging::PixelFormat::Format24bppRgb,pt1); this->pictureBox1->Image = My_Vision; //I want to save each frame into my disk } } //get the frame from the webcam private: System::Void backgroundWorker1_DoWork(System::Object^ sender, System::ComponentModel::DoWorkEventArgs^ e) { while (1) { Sleep(1); if (this->VI->isFrameNew(ID)) { this->VI->getPixels(ID,this->resultBufer,false,true); this->HaveNewFrame = true; this->StarToWork = true; } } }
i++; My_Vision->Save("D:\\"+i+".bmp");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)