Hi Again,

 

Sorry I do not know how to reply directly to your post.

Thank you for your quick reply. Your comment that lensfun is only doing the
coordinate transformations did the trick. If anyone else is interested, here
is a quick opencv example:

 

    lfDatabase *ldb = lf_db_new ();

    ldb->Load ();

 

    cv::Mat mat = cv::imread("TESTIMAGE.jpg", 1);

 

    int width = mat.cols;

    int height = mat.rows;

 

    //GET LENS

    const lfLens **lenses = ldb->FindLenses(NULL, NULL, "Nikkor AF-S 24-85mm
f/3.5-4.5G ED VR");

    const lfLens *myLens = lenses[0];

 

    //MODIFY IMAGE

    lfModifier *modifier = lfModifier::Create(myLens,myLens->CropFactor,
width, height);

    modifier->Initialize(myLens, LF_PF_U8, myLens->MinFocal,
myLens->MinAperture, 0.2, 0.0, lenses[0]->Type, LF_MODIFY_ALL, true);

    bool ret = true;

    float *pos = new float [mat.cols * 2];

 

    cv::Mat mapX(height, width, CV_32FC1);

    cv::Mat mapY(height, width, CV_32FC1);

 

    for (int y = 0; y < mat.rows; y++)

    {

        ret = modifier->ApplyGeometryDistortion(0.0, y, mat.cols, 1, pos);

        if (ret)

        {

            float *src = pos;

            for (unsigned x = 0; x < mat.cols; x++)

            {

                mapX.at<float>(y, x) = src[0];

                mapY.at<float>(y, x) = src[1];

                src += 2;

            }

        }

    }

    cv::Mat dest(height, width, CV_8UC3);

 

    //APPLY TRANSFORMATION AND SAVE

    cv::remap(mat, dest, mapX, mapY, cv::INTER_CUBIC);

    cv::imwrite("TESTIMAGE_corrected.jpg", dest);

 

        ldb->Destroy();

 

 

 

Von: Martin Semsch [mailto:[email protected]] 
Gesendet: Freitag, 20. März 2015 09:31
An: '[email protected]'
Betreff: OpenCV and lfModifier

 

Hi,

 

First let me thank you for this great project. 

I wanted to ask whether there is an example somewhere on how to use lensfun
with OpenCV Mats?

The only example I can find is the tmod.cpp, which I am not able to
replicate using openCV. Is the image class used in the example a custom
class or part of some framework?

 

Thank you

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Lensfun-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lensfun-users

Reply via email to