Sunday, April 5, 2015

6

HOW TO INSTALL OPENCV 3.0.0 IN MAC OS X YOSEMITE

Here you have an easy guide on how to install OpenCV 3.0.0 in OS X Yosemite 


And how to start developing OpenCV projects with Xcode


Wednesday, January 28, 2015

3

CEEMPLE OPENCV FOR VISUAL STUDIO

Although I always develop OpenCV applications under linux and always recommend open source environments, many of you use Windows (hey, use whatever suits your needs). So this is for all of you Windows OpenCV developers, you might find it useful:


"Ceemple OpenCV for Visual Studio" - Out of the box OpenCV C++ development for Visual Studio.
Features:
  • Pre-compiled OpenCV v3.0 built with: CUDA, OpenCL, OpenMP, IPP
  • Support for Windows 64 bit distribution and Visual Studio 2013
  • Auto installation of Microsoft Image Watch extension
  • OpenCV new project wizard
  • 70+ examples of OpenCV and CUDA.
Benefits:
  • Start programming immediately using OpenCV within Visual Studio.
  • OpenCV is ready for use, built with complementary libraries.
  • No need for long setups, configurations and adaptation of OpenCV for Visual Studio.
  • Learn from the numerous code examples provided.
  • Debug with Microsoft Image Watch extension.
  • Free use.

Wednesday, November 26, 2014

11

HOW TO INSTALL OPENCV 3.0.0 IN WINDOWS 8

Although I always recommend using Linux on any of its variants, Windows is still being used by the majority of beginners in Computer Vision. Therefore, after receiving many requests, here is an explanation on how to install OpenCV 3 in Windows 8 :


and how to set up your Visual Studio 2013 environment to start programming computer vision applications:


Here is the source code for the test described on the video, it just prints out the version of OpenCV installed on your system:


#include <iostream>
#include <opencv2/opencv.hpp>

void main()
{
  std::cout << "OpenCV Version: " << CV_VERSION << std::endl;
}

Monday, May 5, 2014

0

HAPPY INTERNATIONAL DAY AGAINST DRM!

Hi everyone!

As an advocate of open source software and freedom to share knowledge let me wish you a Happy International Day Against DRM :D

And to celebrate here is an offer from my friends at Packt Publishing: All DRM-free content at just $10 for 24 hours during May 6th!!


Here is their official press release:

Packt celebrates International Day Against DRM, May 6th 2014


Packt Publishing firmly believes that you should be able to read and interact with your content when you want, where you want, and how you want – to that end they have been advocates of DRM-free content since their very first eBook was published back in 2004.

To show their continuing support for Day Against DRM, Packt Publishing is offering all its DRM-free content at $10 for 24 hours only on May 6th – that’s all 2000+ eBooks and Videos at www.packtpub.com

Our top priority at Packt has always been to meet the evolving needs of developers in the most practical way possible, while at the same time protecting the hard work of our authors. DRM-free content continues to be instrumental in making that happen, providing the flexibility and freedom that is essential for an efficient and enhanced learning experience. That’s why we’ve been DRM-free from the beginning – we’ll never put limits on the innovation of our users.”

Dave Maclean, Managing Director


Advocates of Day Against DRM are invited to spread the word and celebrate on May 6th by exploring the full range of DRM-free content at www.packtpub.com, where all eBooks and Videos will be $10 for 24 hours.

Monday, March 24, 2014

0

Packt Publishing celebrates their 2000th title with an exclusive offer - We've got IT covered!


Known for their extensive range of pragmatic IT ebooks, Packt Publishing are celebrating their 2000th book title `Learning Dart’– they want their customers to celebrate too.

To mark this milestone Packt Publishing will launch a ‘Buy One Get One Free’ offer across all eBooks on March 18th – for a limited period only.

`Learning Dart’ was selected as a title and published by Packt earlier this year. As a project that aims to revolutionise a language as crucial as JavaScript, Dart is a great example of an emerging technology which aims to support the community and their requirement for constant improvement. The content itself explains how to develop apps using Dart and HTML5 in a model-driven and fast-paced approach, enabling developers to build more complex and high-performing web apps.

David Maclean, Managing Director explains `It’s not by chance that this book is our 2000th title. Our customers and community drive demand and it is our job to ensure that whatever they’re working on, Packt provides practical help and support.

At Packt we understand that sometimes our customers want to learn a new programming language pretty much from scratch, with little knowledge of similar language concepts. Other times our customers know a related language fairly well and therefore want a fast-paced primer that brings them up to a competent professional level quickly.
That’s what makes Packt different: all our books are specifically commissioned by category experts, based on intensive research of the technology and the key tasks.’

Since 2004, Packt Publishing has been providing practical IT-related information that enables everyone to learn and develop their IT knowledge, from novice to expert. 

Packt is one of the most prolific and fast-growing tech book publishers in the world. Originally focused on open source software, Packt contributes back into the community paying a royalty on relevant books directly to open source projects. These projects have received over $400,000 as part of Packt’s Open Source Royalty Scheme to date.

Their books focus on practicality, recognising that readers are ultimately concerned with getting the job done. Packt’s digitally-focused business model allows them to quickly publish up-to-date books in very specific areas across a range of key categories – web development, game development, big data, application development, and more. Their commitment to providing a comprehensive range of titles has seen Packt publish 1054% more titles in 2013 than in 2006.

Erol Staveley, Publisher, says `Recent research shows that 88% of our customers are very satisfied with the service knowing that we offer a wide breadth of titles in a timely manner, and owing to the quality of service that they receive 94% of customers are willing to recommend Packt to friends and family. It’s great that we’ve hit such a significant milestone, and we want to continue delivering this fantastic content to our customers.’
Here are some of the best titles across Packt's main categories - but Buy One, Get One Free will apply across all 2000 titles:

·        Web Development
·        Big Data & Cloud
·        Game Development
·        App Development

Monday, November 19, 2012

1

THE NEW TSUKUBA STEREO DATASET IS OUT!

Finally! After so much work we released the "New Tsukuba Stereo Dataset" at ICPR2012


This dataset contains 1800 stereo pairs with ground truth disparity maps, occlusion maps and discontinuity maps that will help to further develop the state of the art of stereo matching algorithms and evaluate its performance. It has been generated using photo-realistic computer graphics techniques and modeled after the original "head and lamp" stereo scene released by University of Tsukuba in 1997. 

The dataset is a 1 minute video sequence and also contains the 3D position and orientation of the camera on each frame, so it also can be used to develop and evaluate camera tracking methods.

It can be downloaded freely from the CVLAB website

Enjoy it!

Friday, January 6, 2012

81

3D RECONSTRUCTION WITH OPENCV AND POINT CLOUD LIBRARY

Hi everybody!

I bring you a sample of how to reconstruct a scene in 3D using OpenCV and Point Cloud Library (PCL) with a simple program and an example scene.

All we need is the left image of our stereo camera:

(You can implement your own cheap stereo webcam following this post: OpenCV Stereo Webcam)

The disparity map generated with your preferred Stereo Matching algorithm:

(For example you can use OpenCV's stereoBM algorithm: OpenCV StereoBM)

And the reprojection matrix (Q) obtained at calibration time:


<?xml version="1.0"?>
<opencv_storage>
<Q type_id="opencv-matrix">
  <rows>4</rows>
  <cols>4</cols>
  <dt>d</dt>
  <data>
    1. 0. 0. -2.9615028381347656e+02
    0. 1. 0. -2.3373317337036133e+02
    0. 0. 0. 5.6446880931501073e+02
    0. 0. -1.1340974198400260e-01 4.1658568844268817e+00
  </data></Q>
</opencv_storage>
(You can get the matrix Q for your own stereo camera following the instructions in this post: OpenCV Camera Calibration)

Now download the source code (I highly recommend to read the source code to understand what is going on, don't worry there is comments :P):


[NOTE]: You will need to have installed OpenCV Library (you can get it here) and Point Cloud Library (you can get it here). Also you will need CMake to generate the Makefiles.

Once you have downloaded the source code and installed the dependencies, just run:

tar xzvf OpenCVReprojectImageToPointCloud-1.0.tgz
cd OpenCVReprojectImageToPointCloud
cmake .
make
./OpenCVReprojectImageToPointCloud rgb-image.ppm disparity-image.pgm Q.xml

You should see something similar to the following video:


I hope you enjoy it!
[UPDATE: 04/02/2012] I have released a bug-fix. Thanks to Chris for pointing it out.

Monday, November 14, 2011

33

OPENCV: STEREO WEBCAM

Today, an easy one :) A small program in OpenCV to implement a cheap stereo webcam and visualize the left and right images. The only thing you need are two USB webcams plugged in your computer (better if both are same brand and model):



 Download the source code:


Compile it:

tar xzvf OpenCVStereoWebcam-1.0.tgz
cd OpenCVStereoWebcam
make
./OpenCVStereoWebcam

And there you go, your cheap USB stereo webcam.


Have fun!

Sunday, October 30, 2011

3

CLEVERBOT: 59% HUMAN

Cleverbot is an Artificial Intelligence conversation system specially designed to learn from the conversations that it has with other people trying to mimic the human behavior in a conversation.



To find out the level of intelligence of this kind of artificial entities the archi-famous mathematician Alan Turing proposed in 1950 the Turing Test .  Basically, a human judge engages in a natural language conversation with a human and a machine designed to generate performance indistinguishable from that of a human being. All participants are separated from one another. If the judge cannot reliably tell the machine from the human, the machine is said to have passed the test.

Every year the Turing Test  takes place, this year was celebrated on September 3rd at Techniche 2011, IIT Guwahati, India. In this scenario, several human judges had 5 minutes conversations with another entity (they ignored whether the entity was human or not). Some people believe that if 50% of the judges classify the entity they are talking to as human when in reality it is a machine, then the machine has passed the test. 

This year Cleverbot was classified as human 59% of the times and people might say it passed the Turing Test, but we humans still have hope... humans where classified as humans 63% of the time. I will start getting scared when Cleverbot is classified more often as a human than real humans xD

Anyway, it is fun to talk to Cleverbot, you really have to try it! How? You can do it right here! Just enter some text in the text bar above and hit the "Think About It!" button. Have fun!!

EDIT [2011/11/14]: I removed the widget to talk to Cleverbot directly because it was causing undesired behavior on the website. You can still talk to it by clicking on its logo and visiting Cleverbot's homepage.

Monday, October 10, 2011

7

STEREO VISION: 3D RECONSTRUCTION ERROR

Today I would like to publish the answer to another question in the comments of a previous post that might be worth its own post:

Hi Martin,

You gave such an informative article. Good Job Martin:-)

I'll explain steps that I performed in calculating distance of object.

1. Calibrated stereo camera with chessboard 8x6 cm with 2.8cm square size.

2. My calibration was success with rms error 0.206 and rectified images was good.

3. I found my interest point on left-right image. I tried to determine distance of object using method you specified. There is an error in distance measured from 3cm for closer object to 12cm or more for distant object.
Say, actual - 27cm ; measured - 24cm.
actual - 60cm ; measured - 48cm.


My queries are,
- why does there comes this much big varition is distance measurement?
- What may be reason/solution for this error?

Is there any mistake in my procedure or do i miss parameters?

Regards
Sathya Kumar

Dear Sathya,

First of all, thank you very much for your kind comment. Regarding your queries, I am afraid that what you describe is quite normal. The steps that you followed are correct, so I don't think that you did any mistake in your procedure or missed any parameters.

The thing is, that the relation between the disparity and the depth is non-linear.


Google ads, probably not very well related to the audience of this blog...


For this reason there is such a big variation in the distance measurement error, for close objects a small variation in disparity means a small variation on depth. But, for far objects a small variation in disparity means a big variation in depth.

So, there is no easy solution, it is unavoidable to get bigger error for distant objects, but you can try to mitigate the effects and reduce the error by getting a calibration as good as possible. And to do that you should take captures of the calibration pattern in as many different positions and orientations as possible, far, near, inclined, etc... Also increasing a bit the size of the chessboard could help you to get better accuracy for distant objects.

I hope this solved your doubts.

Best regards,
Martin

Sunday, September 4, 2011

6

OPENCV: PSEUDOCOLOR AND CHROMA DEPTH

Hi everybody!

A couple of days ago one of the readers of the blog asked this on the comments of a previous post:

Hi,

I'm Mike. Nice work! :)

I saw that some people have coloured depth maps and not just shades of grey/black/white. If I want to have coloured depth maps how can I achieve this?

Thanks,
Mike.

Well Mike, some time ago I had the same question and researching a bit I found two approaches. Pseudo Color and Chroma Depth. Let me answer your question with a blog post, so anybody else who could be interested can find it easily.

Basically, what we have is a function that takes as an input a gray scale value and returns the corresponding RGB.  The Pseudo Color approach uses a trigonometric function to assign the RGB color to each gray value. The next picture shows an example:


 As you can see the output is somewhat similar to the images of the luggage scanners in airports and train stations.

But for the purpose of depth visualization, maybe it is more convenient to use Chroma Depth. This method assigns red values to high depth values, magenta values to low depth values and a rainbow color to anything in between. Like in the next picture:



To make it easy, you can download  the simple Gtk application that I made to visualize the output of both methods and play around with some parameters. The source code should be self explanatory, so I will skip the details in this post.


Just execute "make" and then "./GrayToPseudocolor -gray /path/to/your/image.something"
I would like to thank Sarah Martull for letting me use her depth image for this post.

Saturday, August 27, 2011

21

STEREO VISION: WHY CAMERA CALIBRATION IS NEEDED?

As you might well know, if you have 2 different views from the same scene then you can estimate the 3D coordinates of any point in the scene by finding the position of that point in the left image and in the right image and then apply some trigonometry.

Let's assume that we have no previous information about the relation between the cameras. We can find a point of interest in the left image, but we don't know where that point of interest will appear in the right image. So, what do we do? We have no other option than scan the whole right image looking for our point of interest. 

Now I can hear you say: "But that would be soooo slooooow!!". Yep, you are absolutely right, that brute force approach is really slow. But, if we know the relation between both cameras then we can calculate something called epipolar lines

What is so special about these lines? Well, the magic about this lines is that a point in the left image will always have its correspondent point on the right image laying on its correspondent epipolar line! So, now instead of having to scan the whole right image to find our matching point, we only have to look over a single line :)

But wait!! There is more!! If the cameras are completely parallel then something very special happens... the epipolar lines become parallel. This means that the match of a point in the left image will appear in the exact same line on the right image! Isn't that awesome?

That is one of the main reasons to wanting to calibrate your stereo camera. Another good reason is that the lenses of the cameras introduces some distortion. That distortion makes straight lines in the real world appear curved in the image... and you don't like that, do you?

Let me show you a couple of image just to clarify.


The image above shows a couple of images taken with an uncalibrated stereo camera. The cameras are more or less parallel, but they are not perfectly aligned. Do you see the red point? See how it is not in the same line on the left and right images?

Now, almost all the methods used to calculate a dense disparity map rely on calibrated images, so if we try to use this images to calculate the dense disparity map we will get really poor results. You can check it on the next picture:


But now, if we apply the magic of calibration:


The image above has been rectified and undistorted (notice the black borders around the image, they are the result of removing the distortion and aligning the images so the epipolar lines are parallel and appear on the same row in bot images). See the green point? Do you see how it appears in the same row on both images?

Now, if we use this to calculate the dense disparity map:


There it is, much better results!!

To sum up, if you want to get the best out of stereo vision:

  1. Make sure that your cameras are as parallel as possible.
  2. Calibrate the stereo camera. See this post for instructions: http://blog.martinperis.com/2011/01/opencv-stereo-camera-calibration.html
  3. Tune the parameters of your stereo matching algorithm. See this post to get an example: http://blog.martinperis.com/2011/08/opencv-stereo-matching.html
  4. Have fun with it!
So you know, questions are welcome and any comments will be appreciated ;)

Sunday, August 21, 2011

71

OPENCV: STEREO MATCHING

In a previous post I talked about how to calibrate a stereo camera using OpenCV. Today, I would like to talk about the next step. Once your stereo camera is calibrated you can estimate the 3D position (relative to the camera) of any object given its position in the left and right image. For that, we need to calculate the stereo disparity for that object (stereo disparity = the difference in image location of an object seen by the left and right camera). If we want to know the 3D position of all points in a stereo pair of images, then we want to compute a dense disparity map. And that is what this post goes about.

A dense disparity map looks like this:



 I am not going to explain the details or the math behind it, I am more of a practical kind of guy. So let's start.
Basically OpenCV provides 2 methods to calculate a dense disparity map:
In this post I will focus on cvFindStereoCorrespondenceBM, this method is based on Konolige's Block Matching Algorithm. The OpenCV call looks like this:

void cvFindStereoCorrespondenceBM(const CvArr* left, const CvArr* right, CvArr* disparity, CvStereoBMState* state)

The structure CvStereoBMState contains all the parameters that are applicable to the algorithm. There is a bunch of them (pre-filtering, Sum of Absolute Difference windows size, disparity-related, post-filtering...). So, to make it easy, I implemented a small Gtk application that takes 2 images (left image and right image), calculates the disparity map using cvFindStereoCorrespondenceBM and allows you to play with the parameters.

The application is written in C and can be downloaded here: StereoBMTuner-1.0. The application depends on the libraries gtk+-2.0, gmodule-2.0 and opencv. Be sure to have them installed in your system.

Once the file is downloaded just execute:

tar xzvf stereoBMTunner-1.0.tgz
cd StereoBMTunner
make
./main

The last command will execute the application


As you can appreciate, the disparity map generated using the default parameters is hardly similar to the first image on this post. But, you can tune the parameters until you get a clearer disparity map. This video shows the use of the application:



Once the parameters are tuned, the disparity map is much better


It is still not perfect, but it is not so bad either.
Now, to use this application with your own couple of images the only thing you need to do is execute the application like this:

./main -left /path/to/my/image/left -right /path/to/my/image/right

And that's it. Please leave a comment if you found this useful, have any problems, questions, suggestions, impressions, etc...
25JKKNMXU6FE

Monday, August 1, 2011

2

SVN: EVIL COMMIT

Subversion is a very useful centralized version control system. Is very convenient for Software development projects as it allows to the developer team work together in the same files at the same time, keep a record of all the changes and eventually return to a previous stored version of the project if somebody did something wrong or decide to do things differently. 

I have been using it for many years now in a professional environment and for over a year in my private projects (I use it even in my private life xD). I use it in conjunction with trac (which is a powerful tool for Project Management). You might think I am a bit crazy (or completely crazy), but when you have a lot on your mind it is worth having some kind of organization method and this has worked for me so far.

Anyway, recently I was working on my project, committed some changes and got this:

marpemar@MARTIN-PC:~$ svn ci -m "generate_training_samples_from_monocular_images generate color samples"
Sending generate_training_samples_from_monocular_images/main.cpp
Transmitting file data .
Committed revision 666.

Yay! I've reached 666 commits xD To celebrate it I would like to share this video recorded with gource showing the progress and evolution of my private repository until the moment of the evil commit.  Enjoy it!


Thursday, July 28, 2011

1

SMARTBIRD: A ROBOT THAT FLIES LIKE A BIRD

Today I came across a video of a tech talk at TED conference where a guy, working for the German automation company Festo, presented an astonishing development: A robot that flies like a real bird




Enjoy the video.

Saturday, July 23, 2011

2

OPENCV 2 COMPUTER VISION APPLICATION PROGRAMMING COOKBOOK

Many people contact me through this blog to ask the following question: "Hey Martin! How could I get started in the world of Computer Vision?". Well, this book is the answer.



"OpenCV 2 Computer Vision Application Programming Cookbook" is more than just a Cookbook. The author, Robert Laganiere, makes no assumptions regarding the level of knowledge of the reader, so he starts from the basics and goes into more complex subjects progressively. It doesn't matter if you are a total beginner or an experienced user of OpenCV, all the explanations are complete and easy to follow. When the author considers that the audience could be eager to get more details about any of the topics covered in the book, he provides the appropriate bibliography

The code examples are programmed in C++, keeping in mind the performance and always trying to get the best out of Object Oriented programming paradigm. Actually, even an experienced programmer can learn many tips regarding OO programming best practices from this book. As I said: more than just a Cookbook.

You can see it for your self by reading the sample chapter that you can find here.

Of course,  the functionality and capabilities of OpenCV exceeds by far what can be covered in only one book but thanks to this cookbook you will have no problem in mastering OpenCV and being ready to unleash all the potential of the most used Computer Vision library


Sunday, July 17, 2011

0

PACKT OPEN SOURCE ANNOUNCE EXCLUSIVE DISCOUNT OFFERS ON BEST SELLING BOOKS

Packt Open Source has this week announced a series of discounts on its selection of best selling Open Source books. Readers will be offered exclusive discounts off the cover price of selected print books and eBooks for a limited period only. 

So far in 2011, Packt Open Source announced in March that its donations to Open Source projects has surpassed the $300,000 mark, while in April insight into various projects was offered during the ‘Believe in Open Source’ campaign and July’s series of discounts continue this trend of Packt showing its commitment to the Open Source community.

The Packt Open Source books included in this exclusive discount offer include well known books such as JBoss AS 5 Performance Tuning, PHP jQuery Cookbook, Drupal 7 Module Development and Blender Lighting and Rendering, amongst others.

“This special discount showcases a host of Packt Open Source topics and allows readers to purchase some of our most well renowned books at an exclusive price” said Packt Open Source Marketing Executive Julian Copes. “

To ensure you do not miss this fantastic offer, visit the special discount page now, where you can view the extensive list of books included in the offer and access an array of related articles that were written by the authors.

The exclusive discounts are available from 4th July 2011. To find out more, please visit the Packt website.

Thursday, July 14, 2011

0

KINECT SERVICES FOR MRDS AVAILABLE!

After the release of Kinect SDK, here is what many people was waiting for: Kinect Services for MRDS.



This package allows you to use your Kinect within Microsoft Robotics Developer Studio and moreover use it in a Simulated Environment! 

Good job MRDS team!

Thursday, June 16, 2011

0

MICROSOFT TO RELEASE A SIMULATED VERSION OF KINECT FOR MRDS

Microsoft launched a beta version of an SDK for Kinect. Which aims to motivate people to develop crazy kinect-based applications for PC under Windows (Check ouy ROS for the OpenSource version. ).

The good news is that, recently, Trevor Taylor (Program Manager in the Microsoft Robotics Group and co-author of the book "Professional Microsoft Robotics Developer Studio") confirmed me in the forum of MRDS that the guys at Microsoft are working on providing a simulated version of Kinect for Robotics Developer Studio.

In my humble opinion, I believe that it will be a major contribution to the robotics community as you will be able to easily run very advanced experiments in a completely simulated environment!

Trevor promised that it will be ready soon so, get ready!

Tuesday, June 14, 2011

0

OPENCV: NEW COOKBOOK

Last week came to my attention a new book about OpenCV: OpenCV 2 Computer Vision Application Programming Cookbook. Stay tuned for the upcoming review on this blog!