1- Background Information:
-Why we need Image Warping?
To project the image properly on the display while moving, we need to calculate the transformation matrix that's being applied to the image before projecting it in order to fit the movement of the display.
- How image warping is implemented?
As the display moves new coordinates are given to the IRLEDS , so using these new coordinates (destination) and the corners of the image (source), we can estimate the homography matrix.
-“cvFindHomography”: which computes the homography matrix using source & destination points (IRLEDS coordinates).
-“cvWarpPerspective”: This applies the transformation calculated above to the image to be projected.
- Transformations Taxonomy:
There are 4 types of transformations:
the following picture shows the effect of applying different transformation types on an image
and since that our display moves in 8 degrees of freedom, so we used the Homography matrix.
dof: (forward/backward, up/down, left/right (translation) combined with rotation about three perpendicular axes (pitch, yaw, roll))
- Forward Warping VS Inverse Warping
This ppt explains the concept of forward & inverse warping,
remeber if u're using the inverse warping you should use the inverse of the homography matrix not the homography matrix itself
3- C# Code:
This code uses openCV 1.1, this book explains the openCv fns used below
also we use Emgu .Net Wrapper and this is its Wiki for documentation abt it
This's just a simple test code, to warp an image from srcp to dstp
private void warping()
{
imageBox2.Image=src;
float[,] srcp = { { 0, 0 }, { src.Width-1, 0 }, { 0, src.Height-1 }, { src.Width-1, src.Height-1} };
float[,] dstp = { { src.Width * 0.05f, src.Height * 0.33f }, { src.Width * 0.9f, src.Height * 0.25f }, { src.Width * 0.2f, src.Height * 0.7f }, { src.Width * 0.8f, src.Height * 0.9f } };
float[,] homog = new float[3, 3];
Matrix srcpm = new Matrix(srcp);
Matrix dstpm = new Matrix(dstp);
Matrix homogm = new Matrix(homog);
IntPtr n = new IntPtr();
CvInvoke.cvFindHomography(srcpm.Ptr, dstpm.Ptr, homogm.Ptr, Emgu.CV.CvEnum.HOMOGRAPHY_METHOD.DEFAULT, 0, n);
src= src.WarpPerspective(homogm, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC, Emgu.CV.CvEnum.WARP.CV_WARP_INVERSE_MAP, new Bgr(Color.White));
imageBox1.Image = src;
}
{
imageBox2.Image=src;
float[,] srcp = { { 0, 0 }, { src.Width-1, 0 }, { 0, src.Height-1 }, { src.Width-1, src.Height-1} };
float[,] dstp = { { src.Width * 0.05f, src.Height * 0.33f }, { src.Width * 0.9f, src.Height * 0.25f }, { src.Width * 0.2f, src.Height * 0.7f }, { src.Width * 0.8f, src.Height * 0.9f } };
float[,] homog = new float[3, 3];
Matrix
Matrix
Matrix
IntPtr n = new IntPtr();
CvInvoke.cvFindHomography(srcpm.Ptr, dstpm.Ptr, homogm.Ptr, Emgu.CV.CvEnum.HOMOGRAPHY_METHOD.DEFAULT, 0, n);
src= src.WarpPerspective(homogm, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC, Emgu.CV.CvEnum.WARP.CV_WARP_INVERSE_MAP, new Bgr(Color.White));
imageBox1.Image = src;
}
r u gonna use warping in folding the display :D? still can't imagine it awii how u'll do the hardware...mino if u still need kesset el le7am tell me ablaha bas b kam yom 3ashan ageeb el 7agat men baba :) Rabena ma3aako
ردحذفla howa kda kda we need warping 3ashan to make the display movable
ردحذفle2en eldisplay moves fe kol eletegahat fana 3ayza elimage tkoon warped belzabt 3al display
7ewar elHW ba2a e7na lsa 3amaleen bendawar 3ala 7adad ye3melena elframe zay ma7na 3ayzeeno belzabt
rabena yesahel howa fel 3'aleb lsa shewaya o3bal mane7tag elle7am
bas gazaky allah 5airan ya nora, we rabena yewafa2na gamee3an yarab