MCPcopy Create free account
hub / github.com/cpvrlab/ImagePlay / processInputData

Method processInputData

IPL/src/processes/IPLWarpPerspective.cpp:69–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

toImageMethod · 0.80
toCvMatMethod · 0.80
widthMethod · 0.80
heightMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected