Before experimenting with OpenCV, maybe use a simpler method:
pictureBox1->ImageLocation = openFileDialog1->FileName;
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
hello need help, need to display a Mat image into a PictureBox my code goes like this:
private: System::Void Open_Click_1(System::Object^ sender, System::EventArgs^ e)
{
openFileDialog1->Filter = "Images Files | *.JPG; *.PNG";
if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
MessageBox::Show(openFileDialog1->FileName, "Path:");
IntPtr p = Runtime::InteropServices::Marshal::StringToHGlobalAnsi(openFileDialog1->FileName);
const char* path = (const char*)p.ToPointer();
src = imread(path, 0); }
I tried this:
//the code above
. . .
src = imread(path, 0);
System::Drawing::Graphics^ graphics = pictureBox1->CreateGraphics();
System::IntPtr ptr(src.ptr());
System::Drawing::Bitmap^ b = gcnew System::Drawing::Bitmap(src.cols, src.rows, src.step, System::Drawing::Imaging::PixelFormat::Format24bppRgb, ptr);
System::Drawing::RectangleF rect(0, 0, pictureBox1->Width, pictureBox1->Height);
graphics->DrawImage(b, rect);
}
the output:
As shown the same image 3 times beside each other how to change that to show the image once or is there a better way to do it, thanks.
@Viorel , thank you sir
Before experimenting with OpenCV, maybe use a simpler method:
pictureBox1->ImageLocation = openFileDialog1->FileName;