[bash]Environment variables:#include#include "ippcore.h" void main(){ const IppLibraryVersion *libver =0; libver = ippGetLibVersion(); printf("Lib: %s", libver); while(1){ //that I can read the output } }[/bash]
void libinfo(void) {
const IppLibraryVersion* lib = ippsGetLibVersion();
printf(%s %s %d.%d.%d.%d\n, lib->Name, lib->Version,
lib->major, lib->minor, lib->majorBuild, lib->build);
}
Output will be,
ippsa6 v0.0 Alpha
0.0.5.5
Regards,
Naveen Gv
[cpp]#include#include #include "ipp.h" #include "cv.h" #include "highgui.h" #include "ocam_functions.h" #define _USE_MATH_DEFINES int i; int n=0; int width=640; int height=480; int fps=0; float sf = 4; struct ocam_model o, o_cata; // ocam_models for the fisheye and catadioptric cameras int main(int argc, char *argv[]){ //const IppLibraryVersion *libver =0; //libver = ippGetLibVersion(); //printf("%s %sn", libver->Name, libver->Version); /* --------------------------------------------------------------------*/ /* Read the parameters of the omnidirectional camera from the TXT file */ /* --------------------------------------------------------------------*/ //struct ocam_model o, o_cata; // our ocam_models for the fisheye and catadioptric cameras get_ocam_model(&o, "./calib_results.txt"); //initilize camera CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY ); if( !capture ) { fprintf( stderr, "ERROR: capture is NULL n" ); getchar(); return -1; } //Set camera parameters cvSetCaptureProperty(capture ,CV_CAP_PROP_FRAME_WIDTH , width); cvSetCaptureProperty(capture ,CV_CAP_PROP_FRAME_HEIGHT , height); cvSetCaptureProperty(capture ,CV_CAP_PROP_FPS , fps); // Create a window in which the captured images will be presented cvNamedWindow( "distorted", CV_WINDOW_AUTOSIZE ); //cvNamedWindow( "original", CV_WINDOW_AUTOSIZE ); /* --------------------------------------------------------------------*/ /* Allocate space for the unistorted images */ /* --------------------------------------------------------------------*/ IplImage* frame = cvQueryFrame( capture ); IplImage *dst_persp = cvCreateImage( cvGetSize(frame), 8, 3 ); // undistorted perspective and panoramic image // Show the image captured from the camera in the window and repeat while( 1 ) { // Get one frame IplImage* frame = cvQueryFrame( capture ); if( !frame ){ fprintf( stderr, "ERROR: frame is null...n" ); getchar(); break; } CvMat* mapx_persp = cvCreateMat(frame->height, frame->width, CV_32FC1); CvMat* mapy_persp = cvCreateMat(frame->height, frame->width, CV_32FC1); create_perspecive_undistortion_LUT( mapx_persp, mapy_persp, &o, sf ); cvRemap( frame, dst_persp, mapx_persp, mapy_persp, CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, cvScalarAll(0) ); cvShowImage( "distorted", dst_persp ); // Do not release the frame! //cvShowImage( "original", frame ); //If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version), //remove higher bits using AND operator if( (cvWaitKey(10) & 255) == 27 ) { // Release the capture device housekeeping cvReleaseCapture( &capture ); cvDestroyWindow( "distorted" ); //cvDestroyWindow( "original" ); break;} }return 0; }[/cpp]
[cpp]#define _USE_MATH_DEFINES #include#include "ocam_functions.h" //------------------------------------------------------------------------------ int get_ocam_model(struct ocam_model *myocam_model, char *filename) { double *pol = myocam_model->pol; double *invpol = myocam_model->invpol; double *xc = &(myocam_model->xc); double *yc = &(myocam_model->yc); double *c = &(myocam_model->c); double *d = &(myocam_model->d); double *e = &(myocam_model->e); int *width = &(myocam_model->width); int *height = &(myocam_model->height); int *length_pol = &(myocam_model->length_pol); int *length_invpol = &(myocam_model->length_invpol); FILE *f; char buf[CMV_MAX_BUF]; int i; //Open file if(!(f=fopen(filename,"r"))) { printf("File %s cannot be openedn", filename); return -1; } //Read polynomial coefficients fgets(buf,CMV_MAX_BUF,f); fscanf(f,"n"); fscanf(f,"%d", length_pol); for (i = 0; i < *length_pol; i++) { fscanf(f," %lf",&pol); } //Read inverse polynomial coefficients fscanf(f,"n"); fgets(buf,CMV_MAX_BUF,f); fscanf(f,"n"); fscanf(f,"%d", length_invpol); for (i = 0; i < *length_invpol; i++) { fscanf(f," %lf",&invpol); } //Read center coordinates fscanf(f,"n"); fgets(buf,CMV_MAX_BUF,f); fscanf(f,"n"); fscanf(f,"%lf %lfn", xc, yc); //Read affine coefficients fgets(buf,CMV_MAX_BUF,f); fscanf(f,"n"); fscanf(f,"%lf %lf %lfn", c,d,e); //Read image size fgets(buf,CMV_MAX_BUF,f); fscanf(f,"n"); fscanf(f,"%d %d", height, width); fclose(f); return 0; } //------------------------------------------------------------------------------ void cam2world(double point3D[3], double point2D[2], struct ocam_model *myocam_model) { double *pol = myocam_model->pol; double xc = (myocam_model->xc); double yc = (myocam_model->yc); double c = (myocam_model->c); double d = (myocam_model->d); double e = (myocam_model->e); int length_pol = (myocam_model->length_pol); double invdet = 1/(c-d*e); // 1/det(A), where A = [c,d;e,1] as in the Matlab file double xp = invdet*( (point2D[0] - xc) - d*(point2D[1] - yc) ); double yp = invdet*( -e*(point2D[0] - xc) + c*(point2D[1] - yc) ); double r = sqrt( xp*xp + yp*yp ); //distance [pixels] of the point from the image center double zp = pol[0]; double r_i = 1; int i; for (i = 1; i < length_pol; i++) { r_i *= r; zp += r_i*pol; } //normalize to unit norm double invnorm = 1/sqrt( xp*xp + yp*yp + zp*zp ); point3D[0] = invnorm*xp; point3D[1] = invnorm*yp; point3D[2] = invnorm*zp; } //------------------------------------------------------------------------------ void world2cam(double point2D[2], double point3D[3], struct ocam_model *myocam_model) { double *invpol = myocam_model->invpol; double xc = (myocam_model->xc); double yc = (myocam_model->yc); double c = (myocam_model->c); double d = (myocam_model->d); double e = (myocam_model->e); int width = (myocam_model->width); int height = (myocam_model->height); int length_invpol = (myocam_model->length_invpol); double norm = sqrt(point3D[0]*point3D[0] + point3D[1]*point3D[1]); double theta = atan(point3D[2]/norm); double t, t_i; double rho, x, y; double invnorm; int i; if (norm != 0) { invnorm = 1/norm; t = theta; rho = invpol[0]; t_i = 1; for (i = 1; i < length_invpol; i++) { t_i *= t; rho += t_i*invpol; } x = point3D[0]*invnorm*rho; y = point3D[1]*invnorm*rho; point2D[0] = x*c + y*d + xc; point2D[1] = x*e + y + yc; } else { point2D[0] = xc; point2D[1] = yc; } } //------------------------------------------------------------------------------ void create_perspecive_undistortion_LUT( CvMat *mapx, CvMat *mapy, struct ocam_model *ocam_model, float sf) { int i, j; int width = mapx->cols; //New width int height = mapx->rows;//New height float *data_mapx = mapx->data.fl; float *data_mapy = mapy->data.fl; float Nxc = height/2.0; float Nyc = width/2.0; float Nz = -width/sf; double M[3]; double m[2]; for (i=0; i
header ocam_functions.h:[bash]/*------------------------------------------------------------------------------ Example code that shows the use of the 'cam2world" and 'world2cam" functions Shows also how to undistort images into perspective or panoramic images ------------------------------------------------------------------------------*/ #include#include #include #include #include #include #define CMV_MAX_BUF 1024 #define MAX_POL_LENGTH 64 struct ocam_model { double pol[MAX_POL_LENGTH]; // the polynomial coefficients: pol[0] + x"pol[1] + x^2*pol[2] + ... + x^(N-1)*pol[N-1] int length_pol; // length of polynomial double invpol[MAX_POL_LENGTH]; // the coefficients of the inverse polynomial int length_invpol; // length of inverse polynomial double xc; // row coordinate of the center double yc; // column coordinate of the center double c; // affine parameter double d; // affine parameter double e; // affine parameter int width; // image width int height; // image height }; /*------------------------------------------------------------------------------ This function reads the parameters of the omnidirectional camera model from a given TXT file ------------------------------------------------------------------------------*/ int get_ocam_model(struct ocam_model *myocam_model, char *filename); /*------------------------------------------------------------------------------ WORLD2CAM projects a 3D point on to the image WORLD2CAM(POINT2D, POINT3D, OCAM_MODEL) projects a 3D point (point3D) on to the image and returns the pixel coordinates (point2D). POINT3D = [X;Y;Z] are the coordinates of the 3D point. OCAM_MODEL is the model of the calibrated camera. POINT2D = [rows;cols] are the pixel coordinates of the reprojected point NOTE: the coordinates of "point2D" and "center" are already according to the C convention, that is, start from 0 instead than from 1. ------------------------------------------------------------------------------*/ void world2cam(double point2D[2], double point3D[3], struct ocam_model *myocam_model); /*------------------------------------------------------------------------------ CAM2WORLD projects a 2D point onto the unit sphere CAM2WORLD(POINT3D, POINT2D, OCAM_MODEL) back-projects a 2D point (point2D), in pixels coordinates, onto the unit sphere returns the normalized coordinates point3D = [x;y;z] where (x^2 + y^2 + z^2) = 1. POINT3D = [X;Y;Z] are the coordinates of the 3D points, such that (x^2 + y^2 + z^2) = 1. OCAM_MODEL is the model of the calibrated camera. POINT2D = [rows;cols] are the pixel coordinates of the point in pixels Copyright (C) 2009 DAVIDE SCARAMUZZA Author: Davide Scaramuzza - email: davide.scaramuzza@ieee.org NOTE: the coordinates of "point2D" and "center" are already according to the C convention, that is, start from 0 instead than from 1. ------------------------------------------------------------------------------*/ void cam2world(double point3D[3], double point2D[2], struct ocam_model *myocam_model); /*------------------------------------------------------------------------------ Create Look Up Table for undistorting the image into a perspective image It assumes the the final image plane is perpendicular to the camera axis ------------------------------------------------------------------------------*/ void create_perspecive_undistortion_LUT( CvMat *mapx, CvMat *mapy, struct ocam_model *ocam_model, float sf); /*------------------------------------------------------------------------------ Create Look Up Table for undistorting the image into a panoramic image It computes a trasformation from cartesian to polar coordinates Therefore it does not need the calibration parameters The region to undistorted in contained between Rmin and Rmax xc, yc are the row and column coordinates of the image center ------------------------------------------------------------------------------*/ void create_panoramic_undistortion_LUT ( CvMat *mapx, CvMat *mapy, float Rmin, float Rmax, float xc, float yc ); [/bash]
additional dependencies:
cv210d.lib
cvaux210d.lib
cxcore210d.lib
highgui210d.lib
ml210d.lib
freeglut.lib
opengl32.lib
Is there anything else I have to include for IPP support?
Thanks a lot and sorry for my mistakes. I'm only a German mechanical engineer ;-)
Hi,
You can take an advantage of IPP optimization from your OpenCV application, Please refer to Knowledge Base article
Regards,
Naveen Gv
For more complete information about compiler optimizations, see our Optimization Notice.