Categories
code graphics opencv programming

Shape manipulation with Moving Least Squares for curves [w/ code]

Hello,
I wanna share some code I’ve been working on lately that implements smooth shape manipulation using Moving Least Squares. More specifically, the excellent simple and powerful method by Schaefer et al. from Texas A&M and Rice universities (great paper). The method was written for image deformation but very straightforward modifications made it work perfectly for 2D shapes and open curves.
Let’s get down to business

Categories
code graphics opencv programming school vision work

2D curve matching in OpenCV [w/ code]


Just sharing some code and ideas for matching 2D curves. I was working for a while on matching 2D curves to discover shapes in images, but it didn’t work out, what did succeed is this 2D curve matcher that seems to be very robust for certain applications. It’s based on ideas from the Heat Kernel Signature and the CSS Image (that I introduced in my latest post), all around inspecting curves under different level of smoothing.

Categories
code graphics opencv programming school

Resampling, Smoothing and Interest points of curves (via CSS) in OpenCV [w/ code]


I’m so glad to be back to work on a graphics project (of which you will probably hear later), because it takes me back to reading papers and implementing work by talented people. I want share a little bit of utilities I’ve developed for working with 2D curves in OpenCV.

Categories
3d code graphics gui opengl programming qt Recommended Software

How I fell for QGLViewer for my Qt/OpenGL projects [w/ code]

While looking for a very simple way to start up an OpenGL visualizer for quick 3D hacks, I discovered an excellent library called libQGLViewer, and I want to quickly show how easy it is to setup a 3D environment with it. This library provides an easy to access and feature-rich QtWidget you can embed in your UIs or use stand-alone (this may sound like a marketing thing, but they are not paying me anything 🙂
This is based on the library’s own examples at: http://www.libqglviewer.com/examples/index.html, and some of the examples that come with the library source itself.
Let’s see how it’s done

Categories
3d code graphics opencv opengl programming vision

Head Pose Estimation with OpenCV & OpenGL Revisited [w/ code]

So I was contacted earlier by someone asking about the Head Pose Estimation work I put up a while back. And I remembered that I needed to go back to that work and fix some things, so it was a great opportunity.
I ended up making it a bit nicer, and it’s also a good chance for us to review some OpenCV-OpenGL interoperation stuff. Things like getting a projection matrix in OpenCV and translating it to an OpenGL ModelView matrix, are very handy.
Let’s get down to the code.

Categories
code linux programming Solutions tips

Reading a directory in C++ (Win32 & Posix)

Just a snippet of code if someone out there needs it. I keep coming back to it, so I thought why not share it…

#include <iostream>
#ifndef WIN32
#include <dirent.h>
#endif
using namespace std;
void open_imgs_dir(char* dir_name, std::vector<std::string>& file_names) {
	if (dir_name == NULL) {
		return;
	}
	string dir_name_ = string(dir_name);
	vector<string> files_;
#ifndef WIN32
//open a directory the POSIX way
	DIR *dp;
	struct dirent *ep;
	dp = opendir (dir_name);
	if (dp != NULL)
	{
		while (ep = readdir (dp)) {
			if (ep->d_name[0] != '.')
				files_.push_back(ep->d_name);
		}
		(void) closedir (dp);
	}
	else {
		cerr << ("Couldn't open the directory");
		return;
	}
#else
//open a directory the WIN32 way
	HANDLE hFind = INVALID_HANDLE_VALUE;
	WIN32_FIND_DATA fdata;
	if(dir_name_[dir_name_.size()-1] == '\\' || dir_name_[dir_name_.size()-1] == '/') {
		dir_name_ = dir_name_.substr(0,dir_name_.size()-1);
	}
	hFind = FindFirstFile(string(dir_name_).append("\\*").c_str(), &fdata);
	if (hFind != INVALID_HANDLE_VALUE)
	{
		do
		{
			if (strcmp(fdata.cFileName, ".") != 0 &&
				strcmp(fdata.cFileName, "..") != 0)
			{
				if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
				{
					continue; // a diretory
				}
				else
				{
					files_.push_back(fdata.cFileName);
				}
			}
		}
		while (FindNextFile(hFind, &fdata) != 0);
	} else {
		cerr << "can't open directory\n";
		return;
	}
	if (GetLastError() != ERROR_NO_MORE_FILES)
	{
		FindClose(hFind);
		cerr << "some other error with opening directory: " << GetLastError() << endl;
		return;
	}
	FindClose(hFind);
	hFind = INVALID_HANDLE_VALUE;
#endif
	file_names.clear();
	file_names = files_;
}

Enjoy
Roy.

Categories
3d code graphics vision

Registering point clouds rigidly with scale using PCL [w/code]

Hello
Sorry for the bombardment of posts, but I want to share some stuff I’ve been working on lately, so when I find time I just shoot the posts out.
So this time I’ll talk shortly about how to get an estimation of a rigid transformation between two clouds, that potentially are also of different scale. You will end up with a rigid transformation (Rotation Translation) and a scale factor, son in fact it will be a Similarity Transformation. We will first find the right scale, and then find the right transformation, given there is one (but we will find the best transformation there is).

Categories
3d code opencv

Checking for co-planarity of 3D points in OpenCV [w/code]

Hiya
Just catching up on some bloggin, and I wanna share a snippet of OpenCV code on how to check if your (badly) triangulated 3D points came up co-planar, and therefore a botch triangulation. It’s a very simplistic method, only a few lines, and it also is part of my Structure from Motion Toy Library project.

Categories
3d code opencv vision

Decomposing the Essential matrix using Horn and Eigen [w/code]

Hi
I’ve been working feverishly to straighten up the Structure from Motion Toy Library, and make it more robust. During my experiments with different methods I wanted to test out a different method for decomposing the Essential matrix to rotation R and translation t, other than that of Hartley and Zisserman using SVD. That’s when I came upon this paper: here by Berthold Horn from 1990, that traces the steps of Longuet-Higgins who came up with the derivation for the Essential matrix. It has a closed form solution that works pretty well, and here it is implemented with the Eigen math library (a very good library to get to know).

Categories
electronics programming Recommended Solutions tips Website

Bootloading an ATmega88 for Arduino [w/ code]

Just wanted to put up a small tut on how to put an Arduino bootloader on an ATmega88.
I very roughly followed: 
http://www.ladyada.net/learn/avr/avrdude.html
And 
http://itp.nyu.edu/physcomp/Tutorials/ArduinoBreadboard (Although they make it way too complicated)
And ATMEL’s datasheet for ATmega88 is also very good to have open at all times: 
http://www.atmel.com/Images/2545s.pdf
First, put everything on a breadboard: (This took me a while… Thanks D.Mellis and M.Feldmeier!!)

(Fritzing is awesome)