Converting `BufferedImage` to `Mat` in OpenCV

I also was trying to do the same thing, because of need to combining image processed with two libraries. And what I’ve tried to do is to put byte[] in to Mat instead of RGB value. And it worked! So what I did was: 1.Converted BufferedImage to byte array with: byte[] pixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData(); … Read more

How to write a Float Mat to a file in OpenCV

Using pure OpenCV API calls: // Declare what you need cv::FileStorage file(“some_name.ext”, cv::FileStorage::WRITE); cv::Mat someMatrixOfAnyType; // Write to file! file << “matName” << someMatrixOfAnyType; //Close the file and release all the memory buffers file.release(); The file extension can be xml or yml. In both cases you get a small header that you can easily remove/parse, … Read more

What is the difference between UMat and Mat in OpenCV?

Perhaps section 3 of this document will help: [link now broken] https://software.intel.com/sites/default/files/managed/2f/19/inde_opencv_3.0_arch_guide.pdf Specifically, section 3.1: A unified abstraction cv::UMat that enables the same APIs to be implemented using CPU or OpenCL code, without a requirement to call OpenCL accelerated version explicitly. These functions use an OpenCL-enabled GPU if exists in the system, and automatically switch … Read more

Pandas: Creating DataFrame from Series

Here is how to create a DataFrame where each series is a row. For a single Series (resulting in a single-row DataFrame): series = pd.Series([1,2], index=[‘a’,’b’]) df = pd.DataFrame([series]) For multiple series with identical indices: cols = [‘a’,’b’] list_of_series = [pd.Series([1,2],index=cols), pd.Series([3,4],index=cols)] df = pd.DataFrame(list_of_series, columns=cols) For multiple series with possibly different indices: list_of_series = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)