Mapping data from Eigen to OpenCV and back

Eigen is a C++ template library for matrix and vector operations. It is highly optimized for numeric operations and support vectorization and use aligned memory allocators.

When it comes to matrix operations, Eigen is much faster than OpenCV. However, it can be situations when it is necessary to pass Eigen data to OpenCV functions.

In this post I will show how to map Eigen data to OpenCV with easy and efficient way. No copy, minimal overhead and maximum syntax sugar:

Simple case

Eigen::ArrayXXd img(480, 640);
cv::imshow("test", eigen2cv(img));

Proposed approach does not limited to continuous memory layout - it support expression and blocks as well. If given expression has to be evaluated - it will be evaluated into temporary dense storage and then mapped to OpenCV structure:


// Unsharp mask
Eigen::ArrayXXd img, blur;    
cv::GaussianBlur(eigen2cv(img), eigen2cv(blur));

cv::imshow("sharpened", eigen2cv(1.5 * img - 0.5 * blur));

A good resource on image processing using Python

Let me introduce you Adrian Rosebrock and his http://www.pyimagesearch.com/ website. It’s about computer vision and image processing using Python and OpenCV. Looks like there are more than one person that like to share programming experience via blogging :) Here’s how Adrian position himself: This blog is dedicated to helping other programmers understand how image search engines work. While a lot of computer vision concepts are theoretical in nature, I’m a big fan of “learning by example”.

How to detect circles in noisy images

p | This was a request from a(href=“http://www.reddit.com/r/computervision/comments/2a1lvi/help_how_to_process_this_image_to_find_the_circles/") /r/computervision. | A reddit member was asking on how to count number of eggs on quite | noisy image like you may see below. | I’ve decided to write a simple algorithm that does the job and explain how it works. div.beforeafter img(src="source.jpg",alt="before") img(src="display.jpg",alt="after") span.more h2 Step 1 - Filter image p img(src=“source.jpg”,alt=“Source image”) | The original image has noticeable color noise and therefore it must be filtered before we pass it to further stages.

Computer vision Digest - June 2014

This is a second issue of monthly computer vision digest - a list things that you don’t wanna miss, a list of what happened in computer vision in June 2014. Previous issues: Computer Vision Digest (May 2014) In this issue: Signed Distance Field - converting raster masks to vector form QVision: Computer Vision Library for Qt Closer look on licence plate recognition OpenCV 3.0 Feel free to leave your suggestions on interesting materials in post comments or via Twitter by mentioning [@cvtalks](https://twitter.

Computer vision Digest - May 2014

This is a first issue of monthly computer vision digest - a list things that you don’t wanna miss, a list of what happened in computer vision in May 2014. In this issue: Browser image processing - how fast is it? Object recognition using neural networks via JavaScript NASA shares it’s own computer vision library Easy optimization of image processing pipelines using decoupling algorithms OpenCV Apparel Store Browser image processing - how fast is it?