Ask Your Question
0

Camera calibration or Image processing

asked 2016-12-16 01:24:20 -0600

nanuyo gravatar image

Hi guys,

image description

This is taken by a Camera which is installed in an Oven. and, I convert it to the picture below by Photoshop.

image description

I think that Opencv can do it also but I don't know how to do. I found "Camera calibration" and "Image processing" on the OpenCV tutorials & books. but, I'd like to know which one can do this image conversion. if you have any sample code for it, please share with me.. thanks a lot..

HJ

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-12-16 02:13:26 -0600

berak gravatar image

assuming, both camera and tray are in a "fixed position" (so we can simply hardcode the corners of the tray),

a simple perspective transform will do the job:

#include <opencv2/opencv.hpp>
using namespace cv;

int main()
{
    Mat img = imread("oven.jpg");
    vector<Point2f> pts;  // hardcoded, in clockwise order
    pts.push_back(Point2f(167,27));
    pts.push_back(Point2f(367,55));
    pts.push_back(Point2f(382,159));
    pts.push_back(Point2f(182,197));

    Size sz(400,250);    // desired output size
    vector<Point2f> rct; // desired coords, same order
    rct.push_back(Point2f(0,0));
    rct.push_back(Point2f(sz.width,0));
    rct.push_back(Point2f(sz.width,sz.height));
    rct.push_back(Point2f(0,sz.height));

    Mat P = getPerspectiveTransform(pts,rct);
    Mat persp;
    warpPerspective(img, persp, P, sz, INTER_LINEAR);

    imshow("org",img);
    imshow("persp", persp);
    waitKey();
    return 0;
}

image description

edit flag offensive delete link more

Comments

thanks a lot for your help.. it is the best answer what I ever seen.. thanks again

nanuyo gravatar imagenanuyo ( 2016-12-21 18:25:57 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-12-16 01:24:20 -0600

Seen: 202 times

Last updated: Dec 16 '16