none
Problem while converting from Mat to Bitmap

    Pertanyaan

  • I followed this post for converting mat to bitmap.Using opencv 3.1 with visual studio 2013

    Bitmap^ thresh_callback(int thresh)
    {
    	cv::Mat canny_output;
    	vector<vector<cv::Point> > contours;
    	vector<cv::Vec4i> hierarchy;
    
    	/// Detect edges using canny
    	cv::Canny(src_gray, canny_output, thresh, thresh * 2, 3);
    	/// Find contours
    	cv::findContours(canny_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, cv::Point(0, 0));
    
    	/// Draw contours
    	//cv::Mat drawing = cv::Mat::zeros(canny_output.size(), CV_8UC3);
    	cv::Mat drawing = src.clone();
    	for (int i = 0; i< contours.size(); i++)
    	{
    		cv::Scalar color = cv::Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));
    		drawContours(drawing, contours, i, color, 2, 8, hierarchy, 0, cv::Point());
    	}
    	System::IntPtr ptr2(drawing.ptr());
    	System::Drawing::Bitmap^ b2 = gcnew System::Drawing::Bitmap(drawing.cols,drawing.rows, drawing.step, System::Drawing::Imaging::PixelFormat::Format24bppRgb, ptr2);
    	/// Show in a window
    	//cv::namedWindow("Contours", CV_WINDOW_AUTOSIZE);
    	//cv::imshow("Contours", drawing);
    	return b2;
    }
    

    In 

    System::Drawing::Bitmap^ b2 = gcnew System::Drawing::Bitmap(drawing.cols,drawing.rows, drawing.step, System::Drawing::Imaging::PixelFormat::Format24bppRgb, ptr2);
    	/// Show in a window

    its giving error:

    Selasa, 01 Mei 2018 11.52

Semua Balasan

  • Hi victor1765,

    According to your description, your issue is more related about OpenCV. it will be more appropriate to ask your question at
    OpenCV Support.

    Thank you for your understanding.

    Regards,

    Frankie

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Rabu, 02 Mei 2018 06.48