Aitor - 09 April 2009 03:18 AM
cdog, is nice to see that same camera helps you with the mounts. I’ve used cameras screws for the new mount too.
ZeblodS, i’m am trying to work with this camera and wide angle lense, i wan’t to program touch detection for this, and i’ve searched thoose links for barrel distortion correction (hope they can help you):
http://www.cs.hmc.edu/~fleck/iowa-lab/wide.html
http://www.proxel.se/manuals/lensanalyzer_help.html
http://www.all-in-one.ee/~dersch/barrel/barrel.html
http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/lenscorrection/
http://wiki.panotools.org/Lens_correction_model
http://toothwalker.org/optics/distortion.html
http://rtreport.ksc.nasa.gov/techreports/2003report/100/110.html
I am currently doing a barrel correction algorithm and so far it work pretty fine.
I am at this state :
void barrelTest()
{
// Init OpenCV
IplImage* in = cvLoadImage("test.png", 1);
IplImage* ou = cvCreateImage(cvSize(in->width, in->height), IPL_DEPTH_8U, 1);
// Variables globales
unsigned char *inp = (unsigned char*)in->imageData;
unsigned char *oup = (unsigned char*)ou->imageData;
unsigned short x = in->width;
unsigned short y = in->height;
unsigned short midX = x / 2.0;
unsigned short midY = y / 2.0;
// Parametres de la transformation
double cor = 0.0000051;
// Traitement
double coefX = 1.0 + midX * midX * cor;
double coefY = 1.0 + midY * midY * cor;
for(unsigned short i = 0; i < x; i++)
for(unsigned short j = 0; j < y; j++)
{
double cushion = (1.0 + (midX - i) * (midX - i) * cor) * (1.0 + (midY - j) * (midY - j) * cor);
short newI = midX + ((i - midX) * cushion) / coefX;
short newJ = midY + ((j - midY) * cushion) / coefY;
if(newI >= 0 && newI < x && newJ >= 0 && newJ < y)
oup[newJ * x + newI] = ( inp[(j * x + i) * 3] + inp[(j * x + i) * 3 + 1] + inp[(j * x + i) * 3 + 2] ) / 3.0;
}
// Affichage du résultat
cvNamedWindow("Resultat", CV_WINDOW_AUTOSIZE);
cvShowImage("Resultat", ou);
cvWaitKey(0);
// Destruction generale
cvDestroyWindow("Resultat");
cvReleaseImage(&in);
cvReleaseImage(&ou);
}
It is using the OpenCV lib (not for the barrel correction) and the “test.png” picture is one of theses picture : http://nuigroup.com/forums/viewreply/30729/
The final purpose is to make that code in CUDA language (C language for nVidia’s GPU), so I am using OpenCV only for loading and displaying the picture, the rest of the code is just C language.
For now, it correct the barrel effect using the “cor” var (not intuitive values...). I will try to make the “cor” var going between 0 and 100% (instead of 0.0000XXX values...)
After that I think it will be a much better idea to stride the output picture and seek for the corresponding pixel in the input picture (currently it is the opposite, so I have some black pixel in the output picture...)
[EDIT]
I find a weird result with that code. It looks like your camera was not exactly perpendicular to the screen. Is it true, or this algo is wrong ?

Click thumbnail to see full-size image