@@ -173,19 +173,33 @@ Ptr<EdgeAwareInterpolatorImpl> EdgeAwareInterpolatorImpl::create()
173
173
void EdgeAwareInterpolatorImpl::interpolate (InputArray from_image, InputArray from_points, InputArray, InputArray to_points, OutputArray dense_flow)
174
174
{
175
175
CV_Assert ( !from_image.empty () && (from_image.depth () == CV_8U) && (from_image.channels () == 3 || from_image.channels () == 1 ) );
176
- CV_Assert ( !from_points.empty () && from_points.isVector () &&
177
- !to_points .empty () && to_points .isVector () &&
178
- from_points.sameSize (to_points) );
176
+ CV_Assert ( !from_points.empty () && !to_points.empty () && from_points.sameSize (to_points) );
177
+ CV_Assert ((from_points.isVector () || from_points.isMat ()) && from_points.depth () == CV_32F);
178
+ CV_Assert ((to_points.isVector () || to_points.isMat ()) && to_points.depth () == CV_32F);
179
+ CV_Assert (from_points.sameSize (to_points));
179
180
180
181
w = from_image.cols ();
181
182
h = from_image.rows ();
182
183
183
- vector<Point2f> from_vector = *(const vector<Point2f>*)from_points.getObj ();
184
- vector<Point2f> to_vector = *(const vector<Point2f>*)to_points .getObj ();
185
- vector<SparseMatch> matches_vector (from_vector.size ());
186
- for (unsigned int i=0 ;i<from_vector.size ();i++)
187
- matches_vector[i] = SparseMatch (from_vector[i],to_vector[i]);
184
+ Mat from_mat = from_points.getMat ();
185
+ Mat to_mat = to_points.getMat ();
186
+ int npoints = from_mat.checkVector (2 , CV_32F, false );
187
+ if (from_mat.channels () != 2 )
188
+ from_mat = from_mat.reshape (2 , npoints);
189
+
190
+ if (to_mat.channels () != 2 ){
191
+ to_mat = to_mat.reshape (2 , npoints);
192
+ npoints = from_mat.checkVector (2 , CV_32F, false );
193
+ }
194
+
195
+
196
+ vector<SparseMatch> matches_vector (npoints);
197
+ for (unsigned int i=0 ;i<matches_vector.size ();i++)
198
+ matches_vector[i] = SparseMatch (from_mat.at <Point2f>(i), to_mat.at <Point2f>(i));
199
+
200
+
188
201
sort (matches_vector.begin (),matches_vector.end ());
202
+
189
203
match_num = (int )matches_vector.size ();
190
204
CV_Assert (match_num<SHRT_MAX);
191
205
@@ -1102,17 +1116,29 @@ void RICInterpolatorImpl::interpolate(InputArray from_image, InputArray from_poi
1102
1116
CV_Assert (use_variational_refinement == false || !to_image.empty ());
1103
1117
CV_Assert (use_variational_refinement == false || to_image.depth () == CV_8U);
1104
1118
CV_Assert (use_variational_refinement == false || to_image.channels () == 3 || to_image.channels () == 1 );
1105
- CV_Assert (!from_points.empty () && from_points.isVector ());
1106
- CV_Assert (!to_points.empty () && to_points.isVector ());
1119
+ CV_Assert (!from_points.empty ());
1120
+ CV_Assert (!to_points.empty ());
1121
+ CV_Assert ((from_points.isVector () || from_points.isMat ()) && from_points.depth () == CV_32F);
1122
+ CV_Assert ((to_points.isVector () || to_points.isMat ()) && to_points.depth () == CV_32F);
1107
1123
CV_Assert (from_points.sameSize (to_points));
1108
1124
1109
- vector<Point2f> from_vector = *(const vector<Point2f>*)from_points.getObj ();
1110
- vector<Point2f> to_vector = *(const vector<Point2f>*)to_points.getObj ();
1111
- vector<SparseMatch> matches_vector (from_vector.size ());
1112
- for (unsigned int i = 0 ; i < from_vector.size (); i++)
1113
- matches_vector[i] = SparseMatch (from_vector[i], to_vector[i]);
1125
+ Mat from_mat = from_points.getMat ();
1126
+ Mat to_mat = to_points.getMat ();
1127
+ int npoints = from_mat.checkVector (2 , CV_32F, false );
1128
+
1129
+ if (from_mat.channels () != 2 )
1130
+ from_mat = from_mat.reshape (2 , npoints);
1131
+
1132
+ if (to_mat.channels () != 2 ){
1133
+ to_mat = to_mat.reshape (2 , npoints);
1134
+ npoints = from_mat.checkVector (2 , CV_32F, false );
1135
+ }
1136
+
1137
+ vector<SparseMatch> matches_vector (npoints);
1138
+ for (unsigned int i=0 ;i<matches_vector.size ();i++)
1139
+ matches_vector[i] = SparseMatch (from_mat.at <Point2f>(i),to_mat.at <Point2f>(i));
1114
1140
1115
- match_num = static_cast <int >(from_vector .size ());
1141
+ match_num = static_cast <int >(matches_vector .size ());
1116
1142
1117
1143
Mat src = from_image.getMat ();
1118
1144
Size src_size = src.size ();
0 commit comments