How to distort jpeg image file using distortion factors?

I have a distorted shot of my webcam. as a jpeg file, internal matrix and distortion factors: -

matrix intrisic matrix
      (1137.0919189453125,0.0,383.99273681640625)
      (0.0,264.17974853515625,312.74951171875)
      (0.0,0.0,1.0)

matrix distortion :-
    (-0.26913660764694214)
    (0.22259517014026642)
    (-0.0928017795085907)
    (0.26249778270721436)

I don’t know how to load these distortion factors into CvMat to get an undistorted image using these distortion factors. Also, I want to do this only with javacv.

edit: - Also, I know the function

IplImage mapx=cvCreateImage(cvSize(src_img),IPL_DEPTH_32F,1);
IplImage mapy=cvCreateImage(cvSize(src_img),IPL_DEPTH_32F,1);

cvInitUndistortMap(CvMat intrinsic,CvMat distortion, IplImage mapx, IplImage mapy); 
cvRemap(IplImage tm,IplImage src,IplImage mapx,IplImage mapy,CV_INTER_LINEAR|CV_WARP_FILL_OUTLIERS,cvScalarAll(0));

but I don’t know how to initialize the corresponding cvMats for the internal matrix and distortion coefficient.?

+5
source share
1 answer

Why not use cv::undistort?

It takes your matrices as its parameters.

void undistort(const Mat& src, Mat& dst, const Mat& cameraMatrix, const Mat& distCoeffs, const Mat& newCameraMatrix=Mat())

The matrix srcis your image.

dst - .

cameraMatrix - .

distCoeffs - .

:

, newCameraMatrix. GetOptimalNewCameraMatrix newCameraMatrix, .


OK. ... .

public static native void cvUndistortPoints(CvMat src, CvMat dst, CvMat camera_matrix, CvMat dist_coeffs, CvMat R/*=null*/, CvMat P/*=null*/); http://www.java2s.com/Open-Source/Android/UnTagged/educationalrobots/name/audet/samuel/javacv/jna/cv.java.htm.

imgproc.

null.


- CvMat - , , , , , JNA-:)

, : public static CvMat create(int rows, int cols, int type);

, .

cxcore.java, , CV_64FC1, double. , float s, CV_32FC1.

, : opencv_core.cvSet2D(matrix, i, j, value); i - , j - !

?

Cheerio!

+2

All Articles