Como exibir um cv :: Mat em um aplicativo Windows Form?
Eu tentei usarimwrite
para exibir com êxito uma imagem em um Windows Form, mas danifica o disco, por isso preciso de uma maneira melhor de fazer iss
Abaixo, é o meu código atual, que grava a imagem temporariamente no disco rígido:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
namedWindow("video",0);
VideoCapture cap(0);
flag = true;
while(flag){
Mat frame;
cap >> frame; // get a new frame from camera
**imwrite("vdo.jpg",frame);**
this->panel1->BackgroundImage = System::Drawing::Image::FromFile("vdo.jpg");
waitKey(5);
delete panel1->BackgroundImage;
this->panel1->BackgroundImage = nullptr;
}
}
Quando tento usar o OpenCVMat
que está na memória, não consigo fazê-lo funcionar. Os seguintes trechos de código são o que eu tentei até agora:
this->panel1->BackgroundImage = System::Drawing::Bitmap(frame);
o
this->panel1->BackgroundImage = gcnew System::Drawing::Bitmap( frame.widht,frame.height,System::Drawing::Imaging::PixelFormat::Undefined, ( System::IntPtr ) frame.imageData);
Quero exibirframe
neste código sem usarimwrite
. Como faço para fazer isso?