c++ - What is the fastest way to display a byte array using imshow in opencv? -
i have pointer image buffer (byte array) , know number of rows , columns. fastest way of displaying image data in opencv. see details below.
int rows, cols; unsigned char *imagebuffer; if (err = wfs_getspotfieldimage(instr.handle, &imagebuffer, &rows, &cols)) handle_errors(err); // goes here construct "mat image" using "imagebuffer" pointer? mat image(rows, cols, cv_8uc3, scalar(255, 0, 0)); cv::namedwindow("spot field", cv::window_autosize); cv::imshow("spot field", image);
use constructor:
mat::mat(int rows, int cols, int type, void* data, size_t step=auto_step)
data – pointer user data. matrix constructors take data , step parameters not allocate matrix data. instead, initialize matrix header points specified data, means no data copied. operation efficient , can used process external data using opencv functions. external data not automatically deallocated, should take care of it.
Comments
Post a Comment