| 65 | } |
| 66 | |
| 67 | bool IPLWarpAffine::processInputData(IPLData* data, int imageIndex, bool) |
| 68 | { |
| 69 | IPLImage* image = data->toImage(); |
| 70 | |
| 71 | // save the first image |
| 72 | if(imageIndex == 0) |
| 73 | { |
| 74 | delete _inputA; |
| 75 | _inputA = new IPLImage(*image); |
| 76 | } |
| 77 | |
| 78 | // save the second image |
| 79 | if(imageIndex == 1) |
| 80 | { |
| 81 | delete _inputB; |
| 82 | _inputB = new IPLImage(*image); |
| 83 | } |
| 84 | |
| 85 | // only continue if we have 2 valid inputs |
| 86 | if(!(_inputA && _inputB)) |
| 87 | { |
| 88 | return false; |
| 89 | } |
| 90 | |
| 91 | // get properties |
| 92 | int method = getProcessPropertyInt("method"); |
| 93 | std::vector<double> v = getProcessPropertyVectorDouble("matrix_M"); |
| 94 | IPLPoint pointA0 = getProcessPropertyPoint("points_a0"); |
| 95 | IPLPoint pointA1 = getProcessPropertyPoint("points_a1"); |
| 96 | IPLPoint pointA2 = getProcessPropertyPoint("points_a2"); |
| 97 | IPLPoint pointB0 = getProcessPropertyPoint("points_b0"); |
| 98 | IPLPoint pointB1 = getProcessPropertyPoint("points_b1"); |
| 99 | IPLPoint pointB2 = getProcessPropertyPoint("points_b2"); |
| 100 | int interpolation = getProcessPropertyInt("interpolation"); |
| 101 | int border = getProcessPropertyInt("border"); |
| 102 | |
| 103 | notifyProgressEventHandler(-1); |
| 104 | |
| 105 | // convert vector to cv::Mat |
| 106 | cv::Mat matrix(2, 3, CV_32FC1); |
| 107 | for(int i=0; i < (int) v.size(); i++) |
| 108 | { |
| 109 | int col = i % matrix.cols; |
| 110 | int row = i / matrix.cols; |
| 111 | matrix.at<float>(row, col) = v[i]; |
| 112 | } |
| 113 | |
| 114 | // automatically calculate the matrix |
| 115 | cv::Point2f pointsA[3]; |
| 116 | cv::Point2f pointsB[3]; |
| 117 | pointsA[0] = cv::Point2f(pointA0.x(), pointA0.y()); |
| 118 | pointsA[1] = cv::Point2f(pointA1.x(), pointA1.y()); |
| 119 | pointsA[2] = cv::Point2f(pointA2.x(), pointA2.y()); |
| 120 | |
| 121 | pointsB[0] = cv::Point2f(pointB0.x(), pointB0.y()); |
| 122 | pointsB[1] = cv::Point2f(pointB1.x(), pointB1.y()); |
| 123 | pointsB[2] = cv::Point2f(pointB2.x(), pointB2.y()); |
| 124 | |