00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00042 #include <stdio.h>
00043 #include <stdlib.h>
00044 #include <iostream>
00045 #include <QDebug>
00046 #include <math.h>
00047
00048
00049 #include <qvcore/qvapplication.h>
00050 #include <qvcameras/qvmplayercamera.h>
00051 #include <qvgui/qvgui.h>
00052
00053 #include <qvdta/qvpolyline.h>
00054 #include <qvdta/qvdta.h>
00055
00056 #include <TooN/TooN.h>
00057 #include <TooN/numerics.h>
00058 #include <TooN/numhelpers.h>
00059 #include <TooN/SVD.h>
00060 #include <TooN/LU.h>
00061 #include <TooN/SymEigen.h>
00062
00063 #define PI 3.14159
00064 #define MAX(x,y) (((x) > (y))?(x):(y))
00065
00066 Q_DECLARE_METATYPE(Matrix<>);
00067
00069 void GetHotPoints(const QVImage<sFloat> cornerResponseImage, QList<QPoint> &hotPoints, uInt maxWindow)
00070 {
00071 const uInt rows = cornerResponseImage.getRows(), cols = cornerResponseImage.getCols();
00072
00073 QVImage<uChar> binaryCornerImage(cols, rows);
00074 FilterLocalMax(cornerResponseImage, binaryCornerImage, maxWindow, maxWindow);
00075
00076 QVIMAGE_INIT_READ(uChar,binaryCornerImage);
00077 for (uInt row = 0; row < binaryCornerImage.getRows(); row++)
00078 for (uInt col = 0; col < binaryCornerImage.getCols(); col++)
00079 if (QVIMAGE_PIXEL(binaryCornerImage, col, row,0))
00080 hotPoints.append(QPoint(col, row));
00081 }
00082
00083 void GetMaximalPoints(const QVImage<sFloat> cornerResponseImage, QList<QPoint> &hotPoints, QList<QPoint> &maximalPoints, uInt maxPoints)
00084 {
00085 while( hotPoints.size() > 0 && maximalPoints.size() < maxPoints )
00086 {
00087 uInt maxIndex = 0;
00088 for (int n=0; n < hotPoints.size(); n++)
00089 if ( cornerResponseImage(hotPoints.at(n)) > cornerResponseImage(hotPoints.at(maxIndex)) )
00090 maxIndex = n;
00091
00092 maximalPoints.append(hotPoints.at(maxIndex));
00093 hotPoints.removeAt(maxIndex);
00094 }
00095 }
00096
00097 uInt getClosestPointIndex(const QPoint point, const QList<QPoint> &pointList)
00098 {
00099 uInt index = 0;
00100 for (uInt n = 1; n < pointList.size(); n++)
00101 if ((point - pointList.at(n)).manhattanLength() < (point - pointList.at(index)).manhattanLength())
00102 index = n;
00103
00104 return index;
00105 }
00106
00107 QPoint getMeanPoint(const QList<QPoint> &pointList)
00108 {
00109 QPoint center(0,0);
00110
00111 for (uInt n = 0; n < pointList.size(); n++)
00112 {
00113 center.rx() += pointList.at(n).x();
00114 center.ry() += pointList.at(n).y();
00115 }
00116
00117 center.rx() = center.rx() / pointList.size();
00118 center.ry() = center.ry() / pointList.size();
00119
00120 return center;
00121 }
00122
00123 double angle(const QPoint &p)
00124 {
00125 double x = p.x(), y = p.y();
00126 if (x>0)
00127 if (y>=0)
00128 return atan(y/x);
00129 else
00130 return atan(y/x) + 2*PI;
00131 else if (x == 0)
00132 if (y>0)
00133 return PI/2;
00134 else
00135 return 3*PI/2;
00136 else
00137 return atan(y/x)+PI;
00138 }
00139
00140 double clockWiseAngle(const QPoint &p1, const QPoint &p2)
00141 {
00142 double clockAngle = angle(p2) - angle(p1);
00143 return (clockAngle < 0)? clockAngle + 2*PI:clockAngle;
00144 }
00145
00147 double angle(const double x, const double y)
00148 {
00149 if (x>0)
00150 if (y>=0)
00151 return atan(y/x);
00152 else
00153 return atan(y/x) + 2*PI;
00154 else if (x == 0)
00155 if (y>0)
00156 return PI/2;
00157 else
00158 return 3*PI/2;
00159 else
00160 return atan(y/x)+PI;
00161 }
00162
00163 double clockWiseAngle(const double x1, const double y1, const double x2, const double y2)
00164 {
00165 double clockAngle = angle(x2,y2) - angle(x1,y1);
00166 return (clockAngle < 0)? clockAngle + 2*PI:clockAngle;
00167 }
00168
00169
00170
00171 QList<QPoint> GetTemplatePoints(uInt zoom, QPoint center)
00172 {
00173 QPoint rPoints[5] =
00174
00175 { QPoint(0,0), QPoint(-1,-1), QPoint(+1,-1), QPoint(+1,+1), QPoint(-1,+1) };
00176
00177 QList<QPoint> templatePoints;
00178
00179 for (uInt i= 0; i < 5; i++)
00180 templatePoints.append(zoom*rPoints[i]+center);
00181
00182 return templatePoints;
00183 }
00184
00185
00186
00187 bool SortTemplatePoints(QList<QPoint> &points)
00188 {
00189 if (points.size() != 5)
00190 return false;
00191
00192 QList<QPoint> result;
00193
00194
00195 uInt index[5];
00196
00197
00198 uInt indexp = getClosestPointIndex(getMeanPoint(points), points);
00199
00200 result.append(points.at(indexp));
00201 points.removeAt(indexp);
00202
00203
00204 double minDistance = 1000000;
00205 for (uInt n = 0; n < points.size(); n++)
00206 if ( points.at(n).manhattanLength() < minDistance )
00207 {
00208 minDistance = points.at(n).manhattanLength();
00209 indexp = n;
00210 }
00211
00212 result.append(points.at(indexp));
00213 points.removeAt(indexp);
00214
00215
00216 while(points.size() > 0)
00217 {
00218 indexp = 0;
00219 double minAngle = clockWiseAngle( result.back() - result.front(), points.at(indexp) - result.front());
00220
00221 for (uInt n = 1; n < points.size(); n++)
00222 {
00223 double actualAngle = clockWiseAngle( result.back() - result.front(), points.at(n) - result.front());
00224 if ( actualAngle < minAngle )
00225 {
00226 minAngle = actualAngle;
00227 indexp = n;
00228 }
00229 }
00230
00231 result.append(points.at(indexp));
00232 points.removeAt(indexp);
00233 }
00234
00235 points = result;
00236
00237 return true;
00238 }
00239
00240
00241
00242
00243 Matrix<> CalibrateHomography(const Matrix<> &sourcePoints, const Matrix<> &destinationPoints)
00244 {
00245 Q_ASSERT(sourcePoints.num_cols() == 2);
00246 Q_ASSERT(sourcePoints.num_cols() == destinationPoints.num_cols());
00247 Q_ASSERT(sourcePoints.num_rows() == destinationPoints.num_rows());
00248
00249 const uInt rows = sourcePoints.num_rows();
00250
00251
00252
00253 Matrix<> coefsMatrix(3*rows,9);
00254
00255
00256 for (uInt n = 0; n < rows; n++)
00257 {
00258 double x = sourcePoints[n][0], y = sourcePoints[n][1],
00259 p = destinationPoints[n][0], q = destinationPoints[n][1];
00260
00261 double equation1[9] = { 0, 0, 0, -x, -y, -1, q*x, q*y, q},
00262 equation2[9] = { x, y, 1, 0, 0, 0, -p*x, -p*y, -p},
00263 equation3[9] = { -q*x, -q*y, -q, p*x, p*y, p, 0, 0, 0};
00264
00265 coefsMatrix[3*n] = Vector<9>(equation1);
00266 coefsMatrix[3*n+1] = Vector<9>(equation2);
00267 coefsMatrix[3*n+2] = Vector<9>(equation3);
00268 }
00269
00270
00271 SVD<> svdCoefsMatrix(coefsMatrix);
00272
00273 Vector<9> x = svdCoefsMatrix.get_VT()[8];
00274 Matrix<> homography(3,3);
00275
00276 homography[0][0] = x[0]; homography[0][1] = x[1]; homography[0][2] = x[2];
00277 homography[1][0] = x[3]; homography[1][1] = x[4]; homography[1][2] = x[5];
00278 homography[2][0] = x[6]; homography[2][1] = x[7]; homography[2][2] = x[8];
00279
00280 return homography;
00281 }
00282
00283
00284 QPoint applyHomography(const QPoint p, const Matrix<> homography)
00285 {
00286 const double values[3] = { p.x(), p.y(), 1 };
00287 Vector<3> p1 = Vector<3>(values), p2 = homography * p1;
00288 return QPoint(round(p2[0]/p2[2]), round(p2[1]/p2[2]));
00289 }
00290
00291
00292 void normalizeHomogeneousCoordinates(Matrix<> &points)
00293 {
00294 const uInt cols = points.num_cols(), rows = points.num_rows();
00295
00296 for (uInt i = 0; i < rows; i++)
00297 for (uInt j = 0; j < cols; j++)
00298 points[i][j] /= points[i][cols-1];
00299 }
00300
00301 void normalizeHomogeneousCoordinates(Vector<> &point)
00302 {
00303 for (uInt j = 0; j < 3; j++)
00304 point[j] /= point[2];
00305 }
00306
00307
00308
00309 double testErrorHomography(const Matrix<> &sourcePoints, const Matrix<> &destinationPoints, const Matrix<> homography)
00310 {
00311 const uInt cols = sourcePoints.num_cols(), rows = sourcePoints.num_rows();
00312
00313 Matrix <> projectedPoints(sourcePoints.num_rows(),3);
00314 Matrix <> residuals (sourcePoints.num_rows(),3);
00315
00316 projectedPoints = sourcePoints * homography.T();
00317 normalizeHomogeneousCoordinates(projectedPoints);
00318 residuals = projectedPoints - destinationPoints;
00319
00320 double accum = 0;
00321 for (uInt i = 0; i < rows; i++)
00322 {
00323 double square = 0;
00324 for (uInt j = 0; j < cols; j++)
00325 square += residuals[i][j]*residuals[i][j];
00326 accum += sqrt(square);
00327 }
00328
00329 return accum;
00330 }
00331
00332
00333
00334 void myWarpPerspective(const QVImage<uChar> &src, QVImage<uChar> &dest, const Matrix <> H)
00335 {
00336 const uInt cols = src.getCols(), rows = src.getRows();
00337 const QPoint center = QPoint(cols/2, rows/2);
00338 const Matrix<> Hinv = SVD<>(H).get_pinv();
00339
00340 for (uInt col = 0; col < cols; col++)
00341 for (uInt row = 0; row < rows; row++)
00342 {
00343 QPoint p2 = QPoint(col, row), p1 = applyHomography(p2-center, Hinv);
00344 if (src.getROI().contains(p1))
00345 dest(p2) = src(p1);
00346 }
00347 }
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375 Matrix <> RotationMatrix2d(const double theta)
00376 {
00377 const double m[3*3] = {
00378 cos(theta), -sin(theta), 0,
00379 sin(theta), cos(theta), 0,
00380 0, 0, 1
00381 };
00382
00383 return Matrix<3,3>(m);
00384 }
00385
00386 bool linesIntersectionPoint(const double x1, const double y1, const double x2, const double y2, const double x3, const double y3, const double x4, const double y4,
00387 double &x5, double &y5)
00388 {
00389 const double x5num = x1 *(x4 *(-y2 + y3) + x3 *(y2 - y4)) + x2 *(x4 *(y1 - y3) + x3 *(-y1 + y4)),
00390 x5denom = x4 *(y1 - y2) + x3 *(-y1 + y2) + (x1 - x2)* (y3 - y4),
00391 y5num = x4 *(y1 - y2)* y3 + x1* y2* y3 - x3* y1* y4 - x1* y2* y4 + x3 *y2* y4 + x2 *y1 *(-y3 + y4),
00392 y5denom = x4 *(y1 - y2) + x3 *(-y1 + y2) + (x1 - x2)* (y3 - y4);
00393
00394 if (x5denom == 0 || y5denom == 0)
00395 return false;
00396
00397 x5 = x5num / x5denom;
00398 y5 = y5num / y5denom;
00399
00400 return true;
00401 }
00402
00403
00404 bool closestPointAtLine(const double xc, const double yc, const double x5, const double y5, const double x6, const double y6, double &x7, double &y7)
00405 {
00406 const double x7num = xc*x5*x5 + x6*(xc*x6-(yc-y5)*(y5-y6)) + x5*(-2*xc*x6+(yc-y6)*(y5-y6)),
00407 x7denom = x5*x5-2*x5*x6+x6*x6+(y5-y6)*(y5-y6),
00408 y7num = x6*x6*y5+yc*(y5-y6)*(y5-y6)+x5*x5*y6+xc*x6*(-y5+y6)+x5*((xc-x6)*y5-(xc+x6)*y6),
00409 y7denom = x5*x5 - 2*x5*x6 + x6*x6 + (y5-y6)*(y5-y6);
00410
00411
00412 if (x7denom == 0 || y7denom == 0)
00413 return false;
00414
00415 x7 = x7num / x7denom;
00416 y7 = y7num / y7denom;
00417
00418 return true;
00419
00420 }
00421
00422
00423 void myDrawLine(QVImage<uChar,3> &image, const int x1, const int y1, const int x2, const int y2)
00424 {
00425 const uInt rows = image.getRows(), cols = image.getCols();
00426 const double m = (double)(y2-y1)/(double)(x2-x1);
00427
00428 for(int x = 0; x< cols; x++)
00429 {
00430 int y = m*(x - x1) + y1;
00431 if ( y >= 0 && y < rows)
00432 {
00433 image(x,y,0) = 255;
00434 image(x,y,1) = 0;
00435 image(x,y,2) = 0;
00436 }
00437 }
00438 }
00439
00440
00441
00442 void pointListToMatrix(const QList<QPoint> &points, Matrix<> &matrix)
00443 {
00444 Q_ASSERT(points.size() == matrix.get_rows());
00445 Q_ASSERT(3 == matrix.get_cols());
00446
00447 for (uInt n = 0; n < points.size(); n++)
00448 {
00449 double v[3] = { points.at(n).x(), points.at(n).y(), 1 };
00450 matrix[n] = Vector<3>(v);
00451 }
00452 }
00453
00454
00455 #define NORM(x,y) (sqrt((x)*(x) + (y)*(y)))
00456
00457 void getSubpixelPrecissionPoints(const QVImage<sFloat> &weightImage, QList<QPoint> &pointList, Matrix<> &pointsMatrix, uInt margin)
00458 {
00459 const uInt rows = weightImage.getRows(), cols = weightImage.getCols();
00460
00461 QVIMAGE_INIT_READ(sFloat, weightImage);
00462 for (uInt n = 0; n < pointList.size(); n++)
00463 {
00464 const QPoint p = pointList.at(n);
00465 const int x = p.x(), y = p.y();
00466 if (x > margin && x < cols-margin && y > margin && y < rows-margin)
00467 {
00468 double v[3] = {0, 0, 1}, sum = 0;
00469 for (uint i = x-margin; i<=x+margin; i++)
00470 for (uint j = y-margin; j<=y+margin; j++)
00471 {
00472 const double factor = QVIMAGE_PIXEL(weightImage, i, j, 0);
00473 v[0] += i*factor;
00474 v[1] += j*factor;
00475 sum += factor;
00476 }
00477
00478 v[0] = v[0] / sum;
00479 v[1] = v[1] / sum;
00480
00481 pointsMatrix[n] = Vector<3>(v);
00482 }
00483 }
00484 }
00485
00486 class MyWorker: public QVWorker
00487 {
00488 public:
00489 MyWorker(QString name): QVWorker(name)
00490 {
00491 addProperty<double>("Max error", inputFlag, 2.5, "window size", 0, 10);
00492 addProperty<int>("Zoom", inputFlag, 20, "window size", 1, 256);
00493 addProperty<int>("Window size", inputFlag, 10, "window size", 1, 100);
00494 addProperty<int>("Margin", inputFlag, 1, "window size", 1, 64);
00495 addProperty<double>("Distance", inputFlag, 2, "window size", 0.1, 5);
00496 addProperty< QVImage<uChar,1> >("Input image", inputFlag|outputFlag);
00497 addProperty< QVImage<uChar,3> >("Corners", outputFlag);
00498 addProperty< QVImage<uChar,3> >("Wrapped", outputFlag);
00499 addProperty< QVImage<uChar,3> >("Wrapped2", outputFlag);
00500 addProperty< QVImage<sFloat,1> >("Response image", outputFlag);
00501
00502 addTrigger("Grab homography");
00503 addProperty< Matrix<> >("Actual homography", outputFlag);
00504 }
00505
00506 void processTrigger(QString triggerName)
00507 {
00508 Matrix <> H = getPropertyValue< Matrix<> >("Actual homography");
00509 std::cout << "H = {"
00510 << "{" << H[0][0] << ", " << H[0][1] << ", " << H[0][2] << "},"
00511 << "{" << H[1][0] << ", " << H[1][1] << ", " << H[1][2] << "},"
00512 << "{" << H[2][0] << ", " << H[2][1] << ", " << H[2][2] << "}};" << std::endl;
00513 };
00514
00515 void iterate()
00516 {
00517 const QVImage<uChar> image = getPropertyValue< QVImage<uChar,1> >("Input image");
00518 const uInt rows = image.getRows(), cols = image.getCols(),
00519 sizeMax = getPropertyValue<int>("Window size"),
00520 zoom = getPropertyValue<int>("Zoom"),
00521 margin = getPropertyValue<int>("Margin");
00522
00523 const double maxError = getPropertyValue<double>("Max error"),
00524 distance = getPropertyValue<double>("Distance");
00525
00526 QVImage<uChar,3> destino = image;
00527
00528 timeFlag("grab Frame");
00529
00531
00532 QVImage<sFloat> temp(cols, rows), cornerResponseImage(cols, rows);
00533 HarrisCornerResponseImage(image, cornerResponseImage);
00534
00535
00536 timeFlag("Corner response image");
00537
00538
00539
00540
00542
00543 QList<QPoint> hotPoints;
00544 GetHotPoints(cornerResponseImage, hotPoints, sizeMax);
00545
00546 timeFlag("Get hotpoints");
00547
00549
00550 QList<QPoint> maximalPoints, templatePoints = GetTemplatePoints(1, QPoint(0, 0));
00551 GetMaximalPoints(cornerResponseImage, hotPoints, maximalPoints, 5);
00552 SortTemplatePoints(maximalPoints);
00553
00554 timeFlag("Get max hotpoints");
00555
00556 if (maximalPoints.size() == 5)
00557 {
00558 Matrix <> sourcePoints(5,3), sourcePoints2(5,3), destinationTemplatePoints(5,3);
00559
00560
00561
00562
00563 getSubpixelPrecissionPoints(cornerResponseImage, maximalPoints, sourcePoints,margin);
00564 pointListToMatrix(maximalPoints, sourcePoints2);
00565 pointListToMatrix(templatePoints, destinationTemplatePoints);
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579 Matrix<> H = CalibrateHomography(sourcePoints, destinationTemplatePoints);
00580 Matrix<> H2 = CalibrateHomography(sourcePoints2, destinationTemplatePoints);
00581
00582 if (testErrorHomography(sourcePoints, destinationTemplatePoints, H) < maxError)
00583 {
00584 std::cout << "--------------------------" << std::endl;
00585
00586
00587
00588 std::cout << "ERROR 1 " << testErrorHomography(sourcePoints, destinationTemplatePoints, H) << std::endl;
00589 std::cout << "ERROR 2 " << testErrorHomography(sourcePoints2, destinationTemplatePoints, H2) << std::endl;
00590
00591 setPropertyValue< Matrix<> >("Actual homography", H);
00592
00593 QVImage<uChar> wrapped(cols, rows);
00594 Set(wrapped,0);
00595
00596 myWarpPerspective(image, wrapped, H);
00597
00598 QVImage<uChar> wrapped2(cols, rows);
00599 Set(wrapped2,0);
00600
00601 myWarpPerspective(image, wrapped2, H2);
00602
00603 QVImage<uChar> diff(cols, rows);
00604 AbsDiff(wrapped, wrapped2, diff);
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00661 const double pA[3] = { cols/2, rows, 1},
00662 pB[3] = { cols/2, rows/distance, 1};
00663 Vector<> vA(3), vB(3), vC(3), vD(3), vE(3), temp(3);
00664
00665 vA = H*Vector<3>(pA);
00666 vB = H*Vector<3>(pB);
00667
00668 normalizeHomogeneousCoordinates(vA);
00669 normalizeHomogeneousCoordinates(vB);
00670
00671 temp = vB-vA;
00672
00673 double l = NORM(temp[0], temp[1]);
00674 temp *= (50/l);
00675
00676 vC = vB + sqrt(2)*temp;
00677 vD = vB + RotationMatrix2d(PI/4)*temp;
00678 vE = vB + RotationMatrix2d(-PI/4)*temp;
00679
00680 QVImage<uChar,3> wrappedC3 = wrapped;
00681
00682
00683 QList<QPoint> plist;
00684
00685 plist.append(QPoint(vA[0] + cols/2, vA[1] + rows/2));
00686 plist.append(QPoint(vB[0] + cols/2, vB[1] + rows/2));
00687 plist.append(QPoint(vC[0] + cols/2, vC[1] + rows/2));
00688 plist.append(QPoint(vD[0] + cols/2, vD[1] + rows/2));
00689 plist.append(QPoint(vE[0] + cols/2, vE[1] + rows/2));
00690
00691 drawPoints(plist, wrappedC3);
00692
00694
00695 Matrix <> Hinv(3,3);
00696 Vector<> vAp(3), vBp(3), vCp(3), vDp(3), vEp(3);
00697 Hinv = SVD<>(H).get_pinv();
00698
00699 vAp = Hinv*vA;
00700 vBp = Hinv*vB;
00701 vCp = Hinv*vC;
00702 vDp = Hinv*vD;
00703 vEp = Hinv*vE;
00704
00705 normalizeHomogeneousCoordinates(vAp);
00706 normalizeHomogeneousCoordinates(vBp);
00707 normalizeHomogeneousCoordinates(vCp);
00708 normalizeHomogeneousCoordinates(vDp);
00709 normalizeHomogeneousCoordinates(vEp);
00710
00712
00713 double x5 = 0, y5 = 0, x6 = 0, y6 = 0, x7 = 0, y7 = 0,
00714 xc = ((double)cols)/2, yc = ((double)rows)/2;
00715
00716 linesIntersectionPoint( vBp[0], vBp[1], vEp[0], vEp[1], vCp[0], vCp[1], vDp[0], vDp[1], x5, y5);
00717 linesIntersectionPoint( vCp[0], vCp[1], vEp[0], vEp[1], vBp[0], vBp[1], vDp[0], vDp[1], x6, y6);
00718 closestPointAtLine(xc, yc, x5, y5, x6, y6, x7, y7);
00719
00720 myDrawLine(destino, x5, y5, x6, y6);
00721 QList<QPoint> horizontCenter, imageCenter;
00722 horizontCenter.append(QPoint(x7, y7));
00723 imageCenter.append(QPoint(xc, yc));
00724 drawPoints(horizontCenter, destino);
00725 drawPoints(imageCenter, destino);
00726
00728
00729 QList<QPoint> plist2;
00730 plist2.append(QPoint(vAp[0], vAp[1]));
00731 plist2.append(QPoint(vBp[0], vBp[1]));
00732 plist2.append(QPoint(vCp[0], vCp[1]));
00733 plist2.append(QPoint(vDp[0], vDp[1]));
00734 plist2.append(QPoint(vEp[0], vEp[1]));
00735
00736
00737
00738 drawPoints(plist2, destino);
00739
00740 setPropertyValue< QVImage<uChar,3> >("Wrapped", wrappedC3);
00741 setPropertyValue< QVImage<uChar,1> >("Wrapped2", wrapped2);
00742
00743 }
00744 }
00745
00746 timeFlag("Calibrate");
00747
00748
00749
00750 setPropertyValue< QVImage<uChar,3> >("Corners", destino);
00751 timeFlag("Draw corners");
00752
00754
00755
00756
00757
00758
00759 }
00760 };
00761
00762 int main(int argc, char *argv[])
00763 {
00764 QVApplication app(argc, argv,
00765
00766 "Example program for QVision library. Applies corner detection over an input video."
00767
00768 );
00769
00770 QVMPlayerCamera camera("Video");
00771 MyWorker worker("Corners Worker");
00772 camera.link(&worker,"Input image");
00773
00774 QVGUI interface;
00775
00776 QVImageCanvas imageCanvas("Corners");
00777 imageCanvas.linkProperty(worker, "Corners");
00778
00779 QVImageCanvas imageCanvas2("Wrapped");
00780 imageCanvas2.linkProperty(worker, "Wrapped");
00781
00782 QVImageCanvas imageCanvas4("Wrapped 2");
00783 imageCanvas4.linkProperty(worker, "Wrapped2");
00784
00785 return app.exec();
00786 }
00787
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890