CImg icon indicating copy to clipboard operation
CImg copied to clipboard

[Feature Request] - OpenCV; cv::UMat (Data Structure)

Open HotDenim opened this issue 4 years ago • 2 comments

There is the Plugin for converting the image data structure to the OpenCV (www.opencv.org) data structure, cv::Mat:

CImg/plugins/cvMat.h

But OpenCV also has a similar image data structure: cv::UMat

Can a plug-In be made for this also ?.

HotDenim avatar Jan 07 '21 18:01 HotDenim

There is the Plugin for converting the image data structure to the OpenCV (www.opencv.org) data structure, cv::Mat:

CImg/plugins/cvMat.h

But OpenCV also has a similar image data structure: cv::UMat

Can a plug-In be made for this also ?.

how to use cv::Mat,i include the cvMat, then compile,but so many errors.

xinsuinizhuan avatar Feb 24 '21 08:02 xinsuinizhuan

To use the plugin:

#include <opencv2/core.hpp> #define cimg_plugin1 "cvMat.h" #define cimg_use_opencv #include <CImg.h> ....

============ SAMPLE COMPLETE PROGRAM ======= #include #include <opencv2/core.hpp> #include <opencv2/highgui.hpp> //this is required for cv::imshow()

#define cimg_plugin1 "cvMat.h" #define cimg_use_opencv #include <CImg.h>

using namespace cv; using namespace cimg_library;

int main( int argc, char** argv ) {

namedWindow( "OpenCV-Display", cv::WINDOW_AUTOSIZE );


if(argc < 2) {
	std::cerr << "An argument must be given\n";
	exit(0);
}

//Read CIMG Image CImg cimg( argv[1] ); cimg.display("Original CIMG Image in CIMG Window\n",false);

//Create an OPENCV copy from CIMG Mat cv_image = cimg.get_MAT(); imshow("OpenCV-Display", cv_image); std::cout << "Press key...\n"; cv::waitKey(0); //Wait for key press destroyWindow("OpenCV-Display"); //Close OpenCV Window

// Convert to CIMG from OPENCV CImg cimg2(cv_image); cimg2.display("Final CIMG Image in CIMG Window\n",false);

return 0;

}

aalbiol avatar Feb 25 '21 21:02 aalbiol