5
5
#include < vector>
6
6
7
7
inline std::vector<cv::Point > vecpoint_c2cpp (VecPoint v) {
8
- std::vector<cv::Point > rv;
8
+ std::vector<cv::Point > rv (v. length ) ;
9
9
for (int i = 0 ; i < v.length ; i++) {
10
10
Point p = v.ptr [i];
11
- rv. push_back ( cv::Point (p.x , p.y ) );
11
+ rv[i] = cv::Point (p.x , p.y );
12
12
}
13
13
return rv;
14
14
}
@@ -26,10 +26,10 @@ inline VecPoint *vecpoint_cpp2c_p(std::vector<cv::Point> v) {
26
26
}
27
27
28
28
inline std::vector<cv::Point2f> vecpoint2f_c2cpp (VecPoint2f v) {
29
- std::vector<cv::Point2f> rv;
29
+ std::vector<cv::Point2f> rv (v. length ) ;
30
30
for (int i = 0 ; i < v.length ; i++) {
31
31
Point2f p = v.ptr [i];
32
- rv. push_back ( cv::Point2f (p.x , p.y ) );
32
+ rv[i] = cv::Point2f (p.x , p.y );
33
33
}
34
34
return rv;
35
35
}
@@ -55,10 +55,10 @@ inline VecPoint2f *vecpoint2f_cpp2c_p(std::vector<cv::Point2f> v) {
55
55
}
56
56
57
57
inline std::vector<cv::Point3f> vecpoint3f_c2cpp (VecPoint3f v) {
58
- std::vector<cv::Point3f> rv;
58
+ std::vector<cv::Point3f> rv (v. length ) ;
59
59
for (int i = 0 ; i < v.length ; i++) {
60
60
Point3f p = v.ptr [i];
61
- rv. push_back ( cv::Point3f (p.x , p.y , p.z ) );
61
+ rv[i] = cv::Point3f (p.x , p.y , p.z );
62
62
}
63
63
return rv;
64
64
}
@@ -76,10 +76,10 @@ inline VecPoint3f *vecpoint3f_cpp2c_p(std::vector<cv::Point3f> v) {
76
76
}
77
77
78
78
inline std::vector<cv::Point3i> vecpoint3i_c2cpp (VecPoint3i v) {
79
- std::vector<cv::Point3i> rv;
79
+ std::vector<cv::Point3i> rv (v. length ) ;
80
80
for (int i = 0 ; i < v.length ; i++) {
81
81
Point3i p = v.ptr [i];
82
- rv. push_back ( cv::Point3i (p.x , p.y , p.z ) );
82
+ rv[i] = cv::Point3i (p.x , p.y , p.z );
83
83
}
84
84
return rv;
85
85
}
@@ -97,11 +97,11 @@ inline VecPoint3i *vecpoint3i_cpp2c_p(std::vector<cv::Point3i> v) {
97
97
}
98
98
99
99
inline std::vector<std::vector<cv::Point >> vecvecpoint_c2cpp (VecVecPoint v) {
100
- std::vector<std::vector<cv::Point >> rv;
100
+ std::vector<std::vector<cv::Point >> rv (v. length ) ;
101
101
for (int i = 0 ; i < v.length ; i++) {
102
102
VecPoint vp = v.ptr [i];
103
103
std::vector<cv::Point > pts = vecpoint_c2cpp (vp);
104
- rv. push_back ( pts) ;
104
+ rv[i] = pts;
105
105
}
106
106
return rv;
107
107
}
@@ -125,11 +125,11 @@ inline VecVecPoint *vecvecpoint_cpp2c_p(std::vector<std::vector<cv::Point>> v) {
125
125
}
126
126
127
127
inline std::vector<std::vector<cv::Point2f>> vecvecpoint2f_c2cpp (VecVecPoint2f v) {
128
- std::vector<std::vector<cv::Point2f>> rv;
128
+ std::vector<std::vector<cv::Point2f>> rv (v. length ) ;
129
129
for (int i = 0 ; i < v.length ; i++) {
130
130
VecPoint2f vp = v.ptr [i];
131
131
std::vector<cv::Point2f> pts = vecpoint2f_c2cpp (vp);
132
- rv. push_back ( pts) ;
132
+ rv[i] = pts;
133
133
}
134
134
return rv;
135
135
}
@@ -153,11 +153,11 @@ inline VecVecPoint2f *vecvecpoint2f_cpp2c_p(std::vector<std::vector<cv::Point2f>
153
153
}
154
154
155
155
inline std::vector<std::vector<cv::Point3f>> vecvecpoint3f_c2cpp (VecVecPoint3f v) {
156
- std::vector<std::vector<cv::Point3f>> rv;
156
+ std::vector<std::vector<cv::Point3f>> rv (v. length ) ;
157
157
for (int i = 0 ; i < v.length ; i++) {
158
158
VecPoint3f vp = v.ptr [i];
159
159
std::vector<cv::Point3f> pts = vecpoint3f_c2cpp (vp);
160
- rv. push_back ( pts) ;
160
+ rv[i] = pts;
161
161
}
162
162
return rv;
163
163
}
@@ -181,11 +181,11 @@ inline VecVecPoint3f *vecvecpoint3f_cpp2c_p(std::vector<std::vector<cv::Point3f>
181
181
}
182
182
183
183
inline std::vector<std::vector<cv::Point3i>> vecvecpoint3i_c2cpp (VecVecPoint3i v) {
184
- std::vector<std::vector<cv::Point3i>> rv;
184
+ std::vector<std::vector<cv::Point3i>> rv (v. length ) ;
185
185
for (int i = 0 ; i < v.length ; i++) {
186
186
VecPoint3i vp = v.ptr [i];
187
187
std::vector<cv::Point3i> pts = vecpoint3i_c2cpp (vp);
188
- rv. push_back ( pts) ;
188
+ rv[i] = pts;
189
189
}
190
190
return rv;
191
191
}
@@ -209,10 +209,10 @@ inline VecVecPoint3i *vecvecpoint3i_cpp2c_p(std::vector<std::vector<cv::Point3i>
209
209
}
210
210
211
211
inline std::vector<cv::Mat> vecmat_c2cpp (VecMat v) {
212
- std::vector<cv::Mat> rv;
212
+ std::vector<cv::Mat> rv (v. length ) ;
213
213
for (int i = 0 ; i < v.length ; i++) {
214
214
Mat m = v.ptr [i];
215
- rv. push_back ( *m.ptr ) ;
215
+ rv[i] = *m.ptr ;
216
216
}
217
217
return rv;
218
218
}
@@ -230,46 +230,44 @@ inline VecMat *vecmat_cpp2c_p(std::vector<cv::Mat> v) {
230
230
}
231
231
232
232
inline std::vector<char > vecchar_c2cpp (VecChar v) {
233
- std::vector<char > rv;
234
- for (int i = 0 ; i < v.length ; i++) {
235
- char p = v.ptr [i];
236
- rv.push_back (p);
237
- }
233
+ std::vector<char > rv (v.length );
234
+ for (int i = 0 ; i < v.length ; i++) { rv[i] = v.ptr [i]; }
238
235
return rv;
239
236
}
240
237
241
238
inline std::string vecchar_c2cpp_s (VecChar v) { return std::string (v.ptr , v.length ); }
242
239
243
240
inline VecChar vecchar_cpp2c (std::vector<char > v) {
244
241
char *ptr = new char [v.size ()];
245
- for (int i = 0 ; i < v.size (); i++) { ptr[i] = v[i]; }
242
+ std::copy (v.begin (), v.end (), ptr);
243
+ // for (int i = 0; i < v.size(); i++) { ptr[i] = v[i]; }
246
244
return VecChar{.ptr = ptr, .length = v.size ()};
247
245
}
248
246
249
247
inline VecChar *vecchar_cpp2c_p (std::vector<char > v) {
250
248
char *ptr = new char [v.size ()];
251
- for (int i = 0 ; i < v.size (); i++) { ptr[i] = v[i]; }
249
+ std::copy (v.begin (), v.end (), ptr);
250
+ // for (int i = 0; i < v.size(); i++) { ptr[i] = v[i]; }
252
251
return new VecChar{.ptr = ptr, .length = v.size ()};
253
252
}
254
253
255
254
inline VecChar vecchar_cpp2c_s (std::string v) {
256
255
char *ptr = new char [v.size ()];
257
- for (int i = 0 ; i < v.size (); i++) { ptr[i] = v[i]; }
256
+ std::copy (v.begin (), v.end (), ptr);
257
+ // for (int i = 0; i < v.size(); i++) { ptr[i] = v[i]; }
258
258
return VecChar{.ptr = ptr, .length = v.size ()};
259
259
}
260
260
261
261
inline VecChar *vecchar_cpp2c_s_p (std::string v) {
262
262
char *ptr = new char [v.size ()];
263
- for (int i = 0 ; i < v.size (); i++) { ptr[i] = v[i]; }
263
+ std::copy (v.begin (), v.end (), ptr);
264
+ // for (int i = 0; i < v.size(); i++) { ptr[i] = v[i]; }
264
265
return new VecChar{.ptr = ptr, .length = v.size ()};
265
266
}
266
267
267
268
inline std::vector<uchar> vecuchar_c2cpp (VecUChar v) {
268
- std::vector<uchar> rv;
269
- for (int i = 0 ; i < v.length ; i++) {
270
- char p = v.ptr [i];
271
- rv.push_back (p);
272
- }
269
+ std::vector<uchar> rv (v.length );
270
+ for (int i = 0 ; i < v.length ; i++) { rv[i] = v.ptr [i]; }
273
271
return rv;
274
272
}
275
273
inline VecUChar vecuchar_cpp2c (std::vector<uchar> v) {
@@ -285,18 +283,18 @@ inline VecUChar *vecuchar_cpp2c_p(std::vector<uchar> v) {
285
283
}
286
284
287
285
inline std::vector<std::vector<char >> vecvecchar_c2cpp (VecVecChar v) {
288
- std::vector<std::vector<char >> rv;
286
+ std::vector<std::vector<char >> rv (v. length ) ;
289
287
for (int i = 0 ; i < v.length ; i++) {
290
288
VecChar vc = v.ptr [i];
291
289
std::vector<char > pts = vecchar_c2cpp (vc);
292
- rv. push_back ( pts) ;
290
+ rv[i] = pts;
293
291
}
294
292
return rv;
295
293
}
296
294
297
295
inline std::vector<std::string> vecvecchar_c2cpp_s (VecVecChar v) {
298
- std::vector<std::string> rv;
299
- for (int i = 0 ; i < v.length ; i++) { rv. push_back ( vecchar_c2cpp_s (v.ptr [i]) ); }
296
+ std::vector<std::string> rv (v. length ) ;
297
+ for (int i = 0 ; i < v.length ; i++) { rv[i] = vecchar_c2cpp_s (v.ptr [i]); }
300
298
return rv;
301
299
}
302
300
@@ -325,11 +323,8 @@ inline VecVecChar *vecvecchar_cpp2c_s_p(std::vector<std::string> v) {
325
323
}
326
324
327
325
inline std::vector<int > vecint_c2cpp (VecI32 v) {
328
- std::vector<int > rv;
329
- for (int i = 0 ; i < v.length ; i++) {
330
- int p = v.ptr [i];
331
- rv.push_back (p);
332
- }
326
+ std::vector<int > rv (v.length );
327
+ for (int i = 0 ; i < v.length ; i++) { rv[i] = v.ptr [i]; }
333
328
return rv;
334
329
}
335
330
inline VecI32 vecint_cpp2c (std::vector<int > v) {
@@ -345,11 +340,8 @@ inline VecI32 *vecint_cpp2c_p(std::vector<int> v) {
345
340
}
346
341
347
342
inline std::vector<float > vecfloat_c2cpp (VecF32 v) {
348
- std::vector<float > rv;
349
- for (int i = 0 ; i < v.length ; i++) {
350
- float p = v.ptr [i];
351
- rv.push_back (p);
352
- }
343
+ std::vector<float > rv (v.length );
344
+ for (int i = 0 ; i < v.length ; i++) { rv[i] = v.ptr [i]; }
353
345
return rv;
354
346
}
355
347
@@ -366,11 +358,8 @@ inline VecF32 *vecfloat_cpp2c_p(std::vector<float> v) {
366
358
}
367
359
368
360
inline std::vector<double > vecdouble_c2cpp (VecF64 v) {
369
- std::vector<double > rv;
370
- for (int i = 0 ; i < v.length ; i++) {
371
- int p = v.ptr [i];
372
- rv.push_back (p);
373
- }
361
+ std::vector<double > rv (v.length );
362
+ for (int i = 0 ; i < v.length ; i++) { rv[i] = v.ptr [i]; }
374
363
return rv;
375
364
}
376
365
@@ -395,10 +384,10 @@ inline VecF64 *vecdouble_cpp2c_p(std::vector<double> v) {
395
384
}
396
385
397
386
inline std::vector<cv::Rect > vecrect_c2cpp (VecRect v) {
398
- std::vector<cv::Rect > rv;
387
+ std::vector<cv::Rect > rv (v. length ) ;
399
388
for (int i = 0 ; i < v.length ; i++) {
400
389
Rect p = v.ptr [i];
401
- rv. push_back ( cv::Rect (p.x , p.y , p.width , p.height ) );
390
+ rv[i] = cv::Rect (p.x , p.y , p.width , p.height );
402
391
}
403
392
return rv;
404
393
}
@@ -423,10 +412,10 @@ inline VecRect *vecrect_cpp2c_p(std::vector<cv::Rect> v) {
423
412
}
424
413
425
414
inline std::vector<cv::KeyPoint> veckeypoint_c2cpp (VecKeyPoint v) {
426
- std::vector<cv::KeyPoint> rv;
415
+ std::vector<cv::KeyPoint> rv (v. length ) ;
427
416
for (int i = 0 ; i < v.length ; i++) {
428
417
KeyPoint p = v.ptr [i];
429
- rv. push_back ( cv::KeyPoint (p.x , p.y , p.size , p.angle , p.response , p.octave , p.classID ) );
418
+ rv[i] = cv::KeyPoint (p.x , p.y , p.size , p.angle , p.response , p.octave , p.classID );
430
419
}
431
420
return rv;
432
421
}
@@ -451,10 +440,10 @@ inline VecKeyPoint *veckeypoint_cpp2c_p(std::vector<cv::KeyPoint> v) {
451
440
}
452
441
453
442
inline std::vector<cv::DMatch> vecdmatch_c2cpp (VecDMatch v) {
454
- std::vector<cv::DMatch> rv;
443
+ std::vector<cv::DMatch> rv (v. length ) ;
455
444
for (int i = 0 ; i < v.length ; i++) {
456
445
DMatch p = v.ptr [i];
457
- rv. push_back ( cv::DMatch (p.queryIdx , p.trainIdx , p.imgIdx , p.distance ) );
446
+ rv[i] = cv::DMatch (p.queryIdx , p.trainIdx , p.imgIdx , p.distance );
458
447
}
459
448
return rv;
460
449
}
@@ -476,10 +465,10 @@ inline VecDMatch *vecdmatch_cpp2c_p(std::vector<cv::DMatch> v) {
476
465
}
477
466
478
467
inline std::vector<std::vector<cv::DMatch>> vecvecdmatch_c2cpp (VecVecDMatch v) {
479
- std::vector<std::vector<cv::DMatch>> rv;
468
+ std::vector<std::vector<cv::DMatch>> rv (v. length ) ;
480
469
for (int i = 0 ; i < v.length ; i++) {
481
470
VecDMatch p = v.ptr [i];
482
- rv. push_back ( vecdmatch_c2cpp (p) );
471
+ rv[i] = vecdmatch_c2cpp (p);
483
472
}
484
473
return rv;
485
474
}
@@ -497,16 +486,16 @@ inline VecVecDMatch *vecvecdmatch_cpp2c_p(std::vector<std::vector<cv::DMatch>> v
497
486
}
498
487
499
488
inline std::vector<cv::Point2f> vecPointToVecPoint2f (VecPoint src) {
500
- std::vector<cv::Point2f> v;
501
- for (int i = 0 ; i < src.length ; i++) { v. push_back ( cv::Point2f (src.ptr [i].x , src.ptr [i].y ) ); }
489
+ std::vector<cv::Point2f> v (src. length ) ;
490
+ for (int i = 0 ; i < src.length ; i++) { v[i] = cv::Point2f (src.ptr [i].x , src.ptr [i].y ); }
502
491
return v;
503
492
}
504
493
505
494
inline std::vector<cv::Vec4f> vec_vec4f_c2cpp (VecVec4f v) {
506
- std::vector<cv::Vec4f> rv;
495
+ std::vector<cv::Vec4f> rv (v. length ) ;
507
496
for (int i = 0 ; i < v.length ; i++) {
508
497
Vec4f p = v.ptr [i];
509
- rv. push_back ( cv::Vec4f (p.val1 , p.val2 , p.val3 , p.val4 ) );
498
+ rv[i] = cv::Vec4f (p.val1 , p.val2 , p.val3 , p.val4 );
510
499
}
511
500
return rv;
512
501
}
@@ -528,10 +517,10 @@ inline VecVec4f *vec_vec4f_cpp2c_p(std::vector<cv::Vec4f> v) {
528
517
}
529
518
530
519
inline std::vector<cv::Vec6f> vec_vec6f_c2cpp (VecVec6f v) {
531
- std::vector<cv::Vec6f> rv;
520
+ std::vector<cv::Vec6f> rv (v. length ) ;
532
521
for (int i = 0 ; i < v.length ; i++) {
533
522
Vec6f p = v.ptr [i];
534
- rv. push_back ( cv::Vec6f (p.val1 , p.val2 , p.val3 , p.val4 , p.val5 , p.val6 ) );
523
+ rv[i] = cv::Vec6f (p.val1 , p.val2 , p.val3 , p.val4 , p.val5 , p.val6 );
535
524
}
536
525
return rv;
537
526
}
0 commit comments