mexopencv  3.4.1
MEX interface for OpenCV library
Dataset_.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
38 #include <typeinfo>
39 using namespace std;
40 using namespace cv;
41 using namespace cv::datasets;
42 
43 // Persistent objects
44 namespace {
46 int last_id = 0;
49 
52  (cv::datasets::male, "Male")
53  (cv::datasets::female, "Female")
54  (cv::datasets::none, "None");
55 
58  (cv::datasets::circle, "Circle")
59  (cv::datasets::triangle, "Triangle")
60  (cv::datasets::updown, "Updown")
61  (cv::datasets::rightleft, "Rightleft")
62  (cv::datasets::wave, "Wave")
63  (cv::datasets::z, "Z")
64  (cv::datasets::cross, "Cross")
65  (cv::datasets::comehere, "Comehere")
66  (cv::datasets::turnaround, "Turnaround")
67  (cv::datasets::pat, "Pat");
68 
71  (cv::datasets::fist, "Fist")
72  (cv::datasets::index, "Index")
73  (cv::datasets::flat, "Flat");
74 
77  (cv::datasets::light, "Light")
78  (cv::datasets::dark, "Dark");
79 
82  (cv::datasets::woodenBoard, "WoodenBoard")
83  (cv::datasets::whitePaper, "WhitePaper")
84  (cv::datasets::paperWithCharacters, "PaperWithCharacters");
85 
88  (cv::datasets::humaneva_1, "Humaneva1")
89  (cv::datasets::humaneva_2, "Humaneva2");
90 
93  (cv::datasets::POS, "Pos")
94  (cv::datasets::NEG, "Neg");
95 
98  (cv::datasets::LEFT, "Left")
99  (cv::datasets::RIGHT, "Right")
100  (cv::datasets::LADYBUG, "Ladybug");
101 
104 {
105  const char *fields[] = {"gestureID", "initialFrame", "lastFrame"};
106  MxArray s = MxArray::Struct(fields, 3, 1, groundTruths.size());
107  for (mwIndex i = 0; i < groundTruths.size(); ++i) {
108  s.set("gestureID", groundTruths[i].gestureID, i);
109  s.set("initialFrame", groundTruths[i].initialFrame, i);
110  s.set("lastFrame", groundTruths[i].lastFrame, i);
111  }
112  return s;
113 }
114 
117 {
118  const char *fields[] = {"Wx", "Wy", "Wz", "Rx", "Ry", "Rz", "Rw",
119  "Px", "Py"};
120  MxArray s = MxArray::Struct(fields, 9, 1, 20);
121  for (mwIndex i = 0; i < 20; ++i) {
122  s.set("Wx", skel.s[i].Wx, i);
123  s.set("Wy", skel.s[i].Wy, i);
124  s.set("Wz", skel.s[i].Wz, i);
125  s.set("Rx", skel.s[i].Rx, i);
126  s.set("Ry", skel.s[i].Ry, i);
127  s.set("Rz", skel.s[i].Rz, i);
128  s.set("Rw", skel.s[i].Rw, i);
129  s.set("Px", skel.s[i].Px, i);
130  s.set("Py", skel.s[i].Py, i);
131  }
132  return s;
133 }
134 
137 {
138  const char *fields[] = {"images"};
139  MxArray s = MxArray::Struct(fields, 1, 1, pos.size());
140  for (mwIndex i = 0; i < pos.size(); ++i) {
141  s.set("images", pos[i].images, i);
142  }
143  return s;
144 }
145 
148 {
149  const char *fields[] = {"mat1", "mat2", "mat3", "mat4", "imageWidth",
150  "imageHeight"};
151  MxArray s = MxArray::Struct(fields, 6);
152  s.set("mat1", camera.mat1);
153  s.set("mat2", vector<double>(camera.mat2, camera.mat2 + 3));
154  s.set("mat3", camera.mat3);
155  s.set("mat4", vector<double>(camera.mat4, camera.mat4 + 3));
156  s.set("imageWidth", camera.imageWidth);
157  s.set("imageHeight", camera.imageHeight);
158  return s;
159 }
160 
163 {
164  const char *fields[] = {"name", "xmin", "ymin", "xmax", "ymax"};
165  MxArray s = MxArray::Struct(fields, 5, 1, parts.size());
166  for (mwIndex i = 0; i < parts.size(); ++i) {
167  s.set("name", parts[i].name, i);
168  s.set("xmin", parts[i].xmin, i);
169  s.set("ymin", parts[i].ymin, i);
170  s.set("xmax", parts[i].xmax, i);
171  s.set("ymax", parts[i].ymax, i);
172  }
173  return s;
174 }
175 
178 {
179  const char *fields[] = {"name", "xmin", "ymin", "xmax", "ymax",
180  "pose", "truncated", "difficult", "occluded", "parts"};
181  MxArray s = MxArray::Struct(fields, 10, 1, objects.size());
182  for (mwIndex i = 0; i < objects.size(); ++i) {
183  s.set("name", objects[i].name, i);
184  s.set("xmin", objects[i].xmin, i);
185  s.set("ymin", objects[i].ymin, i);
186  s.set("xmax", objects[i].xmax, i);
187  s.set("ymax", objects[i].ymax, i);
188  s.set("pose", objects[i].pose, i);
189  s.set("truncated", objects[i].truncated, i);
190  s.set("difficult", objects[i].difficult, i);
191  s.set("occluded", objects[i].occluded, i);
192  s.set("parts", toStruct(objects[i].parts), i);
193  }
194  return s;
195 }
196 
199 {
200  const char *fields[] = {"elem"};
201  MxArray s = MxArray::Struct(fields, 1, 1, poses.size());
202  for (mwIndex i = 0; i < poses.size(); ++i) {
203  s.set("elem", vector<double>(poses[i].elem, poses[i].elem + 12), i);
204  }
205  return s;
206 }
207 
210 {
211  const char *fields[] = {"value", "height", "width", "x", "y"};
212  MxArray s = MxArray::Struct(fields, 5, 1, words.size());
213  for (mwIndex i = 0; i < words.size(); ++i) {
214  s.set("value", words[i].value, i);
215  s.set("height", words[i].height, i);
216  s.set("width", words[i].width, i);
217  s.set("x", words[i].x, i);
218  s.set("y", words[i].y, i);
219  }
220  return s;
221 }
222 
225 {
226  const char *fields[] = {"value", "height", "width", "x", "y"};
227  MxArray s = MxArray::Struct(fields, 5, 1, tags.size());
228  for (mwIndex i = 0; i < tags.size(); ++i) {
229  s.set("value", tags[i].value, i);
230  s.set("height", tags[i].height, i);
231  s.set("width", tags[i].width, i);
232  s.set("x", tags[i].x, i);
233  s.set("y", tags[i].y, i);
234  }
235  return s;
236 }
237 
243 {
244  const char *fields[] = {"id", "name", "videoName"};
245  MxArray s = MxArray::Struct(fields, 3, 1, objs.size());
246  for (mwIndex i = 0; i < objs.size(); ++i) {
247  Ptr<AR_hmdbObj> obj = objs[i].staticCast<AR_hmdbObj>();
248  s.set("id", obj->id, i);
249  s.set("name", obj->name, i);
250  s.set("videoName", obj->videoName, i);
251  }
252  return s;
253 }
254 
260 {
261  const char *fields[] = {"videoUrl", "labels"};
262  MxArray s = MxArray::Struct(fields, 2, 1, objs.size());
263  for (mwIndex i = 0; i < objs.size(); ++i) {
264  Ptr<AR_sportsObj> obj = objs[i].staticCast<AR_sportsObj>();
265  s.set("videoUrl", obj->videoUrl, i);
266  s.set("labels", obj->labels, i);
267  }
268  return s;
269 }
270 
276 {
277  const char *fields[] = {"user_id", "original_image", "face_id", "age",
278  "gender", "x", "y", "dx", "dy", "tilt_ang", "fiducial_yaw_angle",
279  "fiducial_score"};
280  MxArray s = MxArray::Struct(fields, 12, 1, objs.size());
281  for (mwIndex i = 0; i < objs.size(); ++i) {
283  s.set("user_id", obj->user_id, i);
284  s.set("original_image", obj->original_image, i);
285  s.set("face_id", obj->face_id, i);
286  s.set("age", obj->age, i);
287  s.set("gender", GenderTypeInvMap[obj->gender], i);
288  s.set("x", obj->x, i);
289  s.set("y", obj->y, i);
290  s.set("dx", obj->dx, i);
291  s.set("dy", obj->dy, i);
292  s.set("tilt_ang", obj->tilt_ang, i);
293  s.set("fiducial_yaw_angle", obj->fiducial_yaw_angle, i);
294  s.set("fiducial_score", obj->fiducial_score, i);
295  }
296  return s;
297 }
298 
304 {
305  const char *fields[] = {"image1", "image2", "same"};
306  MxArray s = MxArray::Struct(fields, 3, 1, objs.size());
307  for (mwIndex i = 0; i < objs.size(); ++i) {
308  Ptr<FR_lfwObj> obj = objs[i].staticCast<FR_lfwObj>();
309  s.set("image1", obj->image1, i);
310  s.set("image2", obj->image2, i);
311  s.set("same", obj->same, i);
312  }
313  return s;
314 }
315 
321 {
322  const char *fields[] = {"name", "nameColor", "nameDepth", "nameUser",
323  "numFrames", "fps", "depth", "groundTruths", "skeletons"};
324  MxArray s = MxArray::Struct(fields, 9, 1, objs.size());
325  for (mwIndex i = 0; i < objs.size(); ++i) {
327  s.set("name", obj->name, i);
328  s.set("nameColor", obj->nameColor, i);
329  s.set("nameDepth", obj->nameDepth, i);
330  s.set("nameUser", obj->nameUser, i);
331  s.set("numFrames", obj->numFrames, i);
332  s.set("fps", obj->fps, i);
333  s.set("depth", obj->depth, i);
334  s.set("groundTruths", toStruct(obj->groundTruths), i);
335  {
336  MxArray c = MxArray::Cell(1, obj->skeletons.size());
337  for (mwIndex j = 0; j < obj->skeletons.size(); ++j)
338  c.set(j, toStruct(obj->skeletons[j]));
339  s.set("skeletons", c, i);
340  }
341  }
342  return s;
343 }
344 
350 {
351  const char *fields[] = {"rgb", "dep", "person", "background",
352  "illumination", "pose", "type"};
353  MxArray s = MxArray::Struct(fields, 7, 1, objs.size());
354  for (mwIndex i = 0; i < objs.size(); ++i) {
355  Ptr<GR_skigObj> obj = objs[i].staticCast<GR_skigObj>();
356  s.set("rgb", obj->rgb, i);
357  s.set("dep", obj->dep, i);
358  s.set("person", int(obj->person), i);
359  s.set("background", BackgroundTypeInvMap[obj->background], i);
360  s.set("illumination", IlluminationTypeInvMap[obj->illumination], i);
361  s.set("pose", PoseTypeInvMap[obj->pose], i);
362  s.set("type", ActionTypeInvMap[obj->type], i);
363  }
364  return s;
365 }
366 
372 {
373  const char *fields[] = {"person", "action", "type1", "type2", "ofs",
374  "fileName", "imageNames"};
375  MxArray s = MxArray::Struct(fields, 7, 1, objs.size());
376  for (mwIndex i = 0; i < objs.size(); ++i) {
378  s.set("person", int(obj->person), i);
379  s.set("action", obj->action, i);
380  s.set("type1", DatasetTypeInvMap[obj->type1], i);
381  s.set("type2", obj->type2, i);
382  s.set("ofs", obj->ofs, i);
383  s.set("fileName", obj->fileName, i);
384  s.set("imageNames", obj->imageNames, i);
385  }
386  return s;
387 }
388 
394 {
395  const char *fields[] = {"name"};
396  MxArray s = MxArray::Struct(fields, 1, 1, objs.size());
397  for (mwIndex i = 0; i < objs.size(); ++i) {
398  Ptr<HPE_parseObj> obj = objs[i].staticCast<HPE_parseObj>();
399  s.set("name", obj->name, i);
400  }
401  return s;
402 }
403 
409 {
410  const char *fields[] = {"imageName", "mat"};
411  MxArray s = MxArray::Struct(fields, 2, 1, objs.size());
412  for (mwIndex i = 0; i < objs.size(); ++i) {
413  Ptr<IR_affineObj> obj = objs[i].staticCast<IR_affineObj>();
414  s.set("imageName", obj->imageName, i);
415  s.set("mat", obj->mat, i);
416  }
417  return s;
418 }
419 
425 {
426  const char *fields[] = {"name", "pos"};
427  MxArray s = MxArray::Struct(fields, 2, 1, objs.size());
428  for (mwIndex i = 0; i < objs.size(); ++i) {
429  Ptr<IR_robotObj> obj = objs[i].staticCast<IR_robotObj>();
430  s.set("name", obj->name, i);
431  s.set("pos", toStruct(obj->pos), i);
432  }
433  return s;
434 }
435 
441 {
442  const char *fields[] = {"name"};
443  MxArray s = MxArray::Struct(fields, 1, 1, objs.size());
444  for (mwIndex i = 0; i < objs.size(); ++i) {
445  Ptr<IS_bsdsObj> obj = objs[i].staticCast<IS_bsdsObj>();
446  s.set("name", obj->name, i);
447  }
448  return s;
449 }
450 
456 {
457  const char *fields[] = {"imageName", "srcBw", "srcColor", "humanSeg"};
458  MxArray s = MxArray::Struct(fields, 4, 1, objs.size());
459  for (mwIndex i = 0; i < objs.size(); ++i) {
461  s.set("imageName", obj->imageName, i);
462  s.set("srcBw", obj->srcBw, i);
463  s.set("srcColor", obj->srcColor, i);
464  s.set("humanSeg", obj->humanSeg, i);
465  }
466  return s;
467 }
468 
474 {
475  const char *fields[] = {"imageName", "bounding", "p", "camera"};
476  MxArray s = MxArray::Struct(fields, 4, 1, objs.size());
477  for (mwIndex i = 0; i < objs.size(); ++i) {
478  Ptr<MSM_epflObj> obj = objs[i].staticCast<MSM_epflObj>();
479  s.set("imageName", obj->imageName, i);
480  s.set("bounding", obj->bounding, i);
481  s.set("p", obj->p, i);
482  s.set("camera", toStruct(obj->camera), i);
483  }
484  return s;
485 }
486 
492 {
493  const char *fields[] = {"imageName", "k", "r", "t"};
494  MxArray s = MxArray::Struct(fields, 4, 1, objs.size());
495  for (mwIndex i = 0; i < objs.size(); ++i) {
497  s.set("imageName", obj->imageName, i);
498  s.set("k", obj->k, i);
499  s.set("r", obj->r, i);
500  s.set("t", vector<double>(obj->t, obj->t + 3), i);
501  }
502  return s;
503 }
504 
510 {
511  const char *fields[] = {"id", "image"};
512  MxArray s = MxArray::Struct(fields, 2, 1, objs.size());
513  for (mwIndex i = 0; i < objs.size(); ++i) {
515  s.set("id", obj->id, i);
516  s.set("image", obj->image, i);
517  }
518  return s;
519 }
520 
526 {
527  const char *fields[] = {"label", "image"};
528  MxArray s = MxArray::Struct(fields, 2, 1, objs.size());
529  for (mwIndex i = 0; i < objs.size(); ++i) {
530  Ptr<OR_mnistObj> obj = objs[i].staticCast<OR_mnistObj>();
531  s.set("label", int(obj->label), i);
532  s.set("image", obj->image, i);
533  }
534  return s;
535 }
536 
542 {
543  const char *fields[] = {"filename", "width", "height", "depth", "objects"};
544  MxArray s = MxArray::Struct(fields, 5, 1, objs.size());
545  for (mwIndex i = 0; i < objs.size(); ++i) {
546  Ptr<OR_pascalObj> obj = objs[i].staticCast<OR_pascalObj>();
547  s.set("filename", obj->filename, i);
548  s.set("width", obj->width, i);
549  s.set("height", obj->height, i);
550  s.set("depth", obj->depth, i);
551  s.set("objects", toStruct(obj->objects), i);
552  }
553  return s;
554 }
555 
561 {
562  const char *fields[] = {"label", "name"};
563  MxArray s = MxArray::Struct(fields, 2, 1, objs.size());
564  for (mwIndex i = 0; i < objs.size(); ++i) {
565  Ptr<OR_sunObj> obj = objs[i].staticCast<OR_sunObj>();
566  s.set("label", obj->label, i);
567  s.set("name", obj->name, i);
568  }
569  return s;
570 }
571 
577 {
578  const char *fields[] = {"name", "imageNames"};
579  MxArray s = MxArray::Struct(fields, 2, 1, objs.size());
580  for (mwIndex i = 0; i < objs.size(); ++i) {
582  s.set("name", obj->name, i);
583  s.set("imageNames", obj->imageNames, i);
584  }
585  return s;
586 }
587 
593 {
594  const char *fields[] = {"filename", "sType", "width", "height", "depth",
595  "bndboxes"};
596  MxArray s = MxArray::Struct(fields, 6, 1, objs.size());
597  for (mwIndex i = 0; i < objs.size(); ++i) {
598  Ptr<PD_inriaObj> obj = objs[i].staticCast<PD_inriaObj>();
599  s.set("filename", obj->filename, i);
600  s.set("sType", SampleTypeInvMap[obj->sType], i);
601  s.set("width", obj->width, i);
602  s.set("height", obj->height, i);
603  s.set("depth", obj->depth, i);
604  s.set("bndboxes", obj->bndboxes, i);
605  }
606  return s;
607 }
608 
614 {
615  const char *fields[] = {"name", "images", "velodyne", "times", "p",
616  "posesArray"};
617  MxArray s = MxArray::Struct(fields, 6, 1, objs.size());
618  for (mwIndex i = 0; i < objs.size(); ++i) {
620  s.set("name", obj->name, i);
621  {
622  MxArray c = MxArray::Cell(1,4);
623  for (mwIndex j = 0; j < 4; ++j)
624  c.set(j, MxArray(obj->images[j]));
625  s.set("images", c, i);
626  }
627  s.set("velodyne", obj->velodyne, i);
628  s.set("times", obj->times, i);
629  {
630  MxArray c = MxArray::Cell(1,4);
631  for (mwIndex j = 0; j < 4; ++j)
632  c.set(j, MxArray(obj->p[j]));
633  s.set("p", c, i);
634  }
635  s.set("posesArray", toStruct(obj->posesArray), i);
636  }
637  return s;
638 }
639 
645 {
646  const char *fields[] = {"name", "transformMat", "type"};
647  MxArray s = MxArray::Struct(fields, 3, 1, objs.size());
648  for (mwIndex i = 0; i < objs.size(); ++i) {
650  s.set("name", obj->name, i);
651  s.set("transformMat", obj->transformMat, i);
652  s.set("type", ImageTypeInvMap[obj->type], i);
653  }
654  return s;
655 }
656 
662 {
663  const char *fields[] = {"imgName", "label"};
664  MxArray s = MxArray::Struct(fields, 2, 1, objs.size());
665  for (mwIndex i = 0; i < objs.size(); ++i) {
666  Ptr<TR_charsObj> obj = objs[i].staticCast<TR_charsObj>();
667  s.set("imgName", obj->imgName, i);
668  s.set("label", obj->label, i);
669  }
670  return s;
671 }
672 
678 {
679  const char *fields[] = {"fileName", "lex100", "lexFull", "words"};
680  MxArray s = MxArray::Struct(fields, 4, 1, objs.size());
681  for (mwIndex i = 0; i < objs.size(); ++i) {
682  Ptr<TR_icdarObj> obj = objs[i].staticCast<TR_icdarObj>();
683  s.set("fileName", obj->fileName, i);
684  s.set("lex100", obj->lex100, i);
685  s.set("lexFull", obj->lexFull, i);
686  s.set("words", toStruct(obj->words), i);
687  }
688  return s;
689 }
690 
696 {
697  const char *fields[] = {"fileName", "lex", "tags"};
698  MxArray s = MxArray::Struct(fields, 3, 1, objs.size());
699  for (mwIndex i = 0; i < objs.size(); ++i) {
700  Ptr<TR_svtObj> obj = objs[i].staticCast<TR_svtObj>();
701  s.set("fileName", obj->fileName, i);
702  s.set("lex", obj->lex, i);
703  s.set("tags", toStruct(obj->tags), i);
704  }
705  return s;
706 }
707 
713 {
714  const char *fields[] = {"id", "imagePath", "gtbb"};
715  MxArray s = MxArray::Struct(fields, 3, 1, objs.size());
716  for (mwIndex i = 0; i < objs.size(); ++i) {
717  Ptr<TRACK_votObj> obj = objs[i].staticCast<TRACK_votObj>();
718  s.set("id", obj->id, i);
719  s.set("imagePath", obj->imagePath, i);
720  s.set("gtbb", obj->gtbb, i);
721  }
722  return s;
723 }
724 
730 {
731  const char *fields[] = {"id", "imagePath", "gtbb"};
732  MxArray s = MxArray::Struct(fields, 3, 1, objs.size());
733  for (mwIndex i = 0; i < objs.size(); ++i) {
735  s.set("id", obj->id, i);
736  s.set("imagePath", obj->imagePath, i);
737  s.set("gtbb", obj->gtbb, i);
738  }
739  return s;
740 }
741 
747 MxArray toStruct(const vector<Ptr<Object> >& objs, const string& klass)
748 {
749  if (klass == "AR_hmdb")
750  return toStruct_AR_hmdb(objs);
751  else if (klass == "AR_sports")
752  return toStruct_AR_sports(objs);
753  else if (klass == "FR_adience")
754  return toStruct_FR_adience(objs);
755  else if (klass == "FR_lfw")
756  return toStruct_FR_lfw(objs);
757  else if (klass == "GR_chalearn")
758  return toStruct_GR_chalearn(objs);
759  else if (klass == "GR_skig")
760  return toStruct_GR_skig(objs);
761  else if (klass == "HPE_humaneva")
762  return toStruct_HPE_humaneva(objs);
763  else if (klass == "HPE_parse")
764  return toStruct_HPE_parse(objs);
765  else if (klass == "IR_affine")
766  return toStruct_IR_affine(objs);
767  else if (klass == "IR_robot")
768  return toStruct_IR_robot(objs);
769  else if (klass == "IS_bsds")
770  return toStruct_IS_bsds(objs);
771  else if (klass == "IS_weizmann")
772  return toStruct_IS_weizmann(objs);
773  else if (klass == "MSM_epfl")
774  return toStruct_MSM_epfl(objs);
775  else if (klass == "MSM_middlebury")
776  return toStruct_MSM_middlebury(objs);
777  else if (klass == "OR_imagenet")
778  return toStruct_OR_imagenet(objs);
779  else if (klass == "OR_mnist")
780  return toStruct_OR_mnist(objs);
781  else if (klass == "OR_pascal")
782  return toStruct_OR_pascal(objs);
783  else if (klass == "OR_sun")
784  return toStruct_OR_sun(objs);
785  else if (klass == "PD_caltech")
786  return toStruct_PD_caltech(objs);
787  else if (klass == "PD_inria")
788  return toStruct_PD_inria(objs);
789  else if (klass == "SLAM_kitti")
790  return toStruct_SLAM_kitti(objs);
791  else if (klass == "SLAM_tumindoor")
792  return toStruct_SLAM_tumindoor(objs);
793  else if (klass == "TR_chars")
794  return toStruct_TR_chars(objs);
795  else if (klass == "TR_icdar")
796  return toStruct_TR_icdar(objs);
797  else if (klass == "TR_svt")
798  return toStruct_TR_svt(objs);
799  else if (klass == "TRACK_vot")
800  return toStruct_TRACK_vot(objs);
801  else if (klass == "TRACK_alov")
802  return toStruct_TRACK_alov(objs);
803  else
804  mexErrMsgIdAndTxt("mexopencv:error",
805  "Unrecognized dataset class %s",klass.c_str());
806 }
807 
813 {
814  Ptr<Dataset> p;
815  if (type == "AR_hmdb")
816  p = AR_hmdb::create();
817  else if (type == "AR_sports")
818  p = AR_sports::create();
819  else if (type == "FR_adience")
820  p = FR_adience::create();
821  else if (type == "FR_lfw")
822  p = FR_lfw::create();
823  else if (type == "GR_chalearn")
824  p = GR_chalearn::create();
825  else if (type == "GR_skig")
826  p = GR_skig::create();
827  else if (type == "HPE_humaneva")
828  p = HPE_humaneva::create();
829  else if (type == "HPE_parse")
830  p = HPE_parse::create();
831  else if (type == "IR_affine")
832  p = IR_affine::create();
833  else if (type == "IR_robot")
834  p = IR_robot::create();
835  else if (type == "IS_bsds")
836  p = IS_bsds::create();
837  else if (type == "IS_weizmann")
838  p = IS_weizmann::create();
839  else if (type == "MSM_epfl")
840  p = MSM_epfl::create();
841  else if (type == "MSM_middlebury")
843  else if (type == "OR_imagenet")
844  p = OR_imagenet::create();
845  else if (type == "OR_mnist")
846  p = OR_mnist::create();
847  else if (type == "OR_pascal")
848  p = OR_pascal::create();
849  else if (type == "OR_sun")
850  p = OR_sun::create();
851  else if (type == "PD_caltech")
852  p = PD_caltech::create();
853  else if (type == "PD_inria")
854  p = PD_inria::create();
855  else if (type == "SLAM_kitti")
856  p = SLAM_kitti::create();
857  else if (type == "SLAM_tumindoor")
859  else if (type == "TR_chars")
860  p = TR_chars::create();
861  else if (type == "TR_icdar")
862  p = TR_icdar::create();
863  else if (type == "TR_svt")
864  p = TR_svt::create();
865  else if (type == "TRACK_vot")
866  p = TRACK_vot::create();
867  else if (type == "TRACK_alov")
868  p = TRACK_alov::create();
869  else
870  mexErrMsgIdAndTxt("mexopencv:error",
871  "Unrecognized dataset %s",type.c_str());
872  if (p.empty())
873  mexErrMsgIdAndTxt("mexopencv:error", "Failed to create Dataset");
874  return p;
875 }
876 }
877 
885 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
886 {
887  // Check the number of arguments
888  nargchk(nrhs>=3 && nlhs<=1);
889 
890  // Argument vector
891  vector<MxArray> rhs(prhs, prhs+nrhs);
892  int id = rhs[0].toInt();
893  string method(rhs[1].toString());
894  string klass(rhs[2].toString());
895 
896  // Constructor is called. Create a new object from argument
897  if (method == "new") {
898  nargchk(nrhs==3 && nlhs<=1);
899  obj_[++last_id] = create_Dataset(klass);
900  plhs[0] = MxArray(last_id);
901  mexLock();
902  return;
903  }
904  // static methods calls
905  else if (method == "createDirectory") {
906  nargchk(nrhs==4 && nlhs==0);
907  string path(rhs[3].toString());
909  return;
910  }
911  else if (method == "getDirList") {
912  nargchk(nrhs==4 && nlhs<=1);
913  string dirName(rhs[3].toString());
914  vector<string> fileNames;
915  cv::datasets::getDirList(dirName, fileNames);
916  plhs[0] = MxArray(fileNames);
917  return;
918  }
919  else if (method == "split") {
920  nargchk(nrhs==5 && nlhs<=1);
921  string s(rhs[3].toString());
922  char delim = (!rhs[4].isEmpty()) ? rhs[4].toString()[0] : ' ';
923  vector<string> elems;
924  cv::datasets::split(s, elems, delim);
925  plhs[0] = MxArray(elems);
926  return;
927  }
928 
929  // Big operation switch
930  Ptr<Dataset> obj = obj_[id];
931  if (obj.empty())
932  mexErrMsgIdAndTxt("mexopencv:error", "Object not found id=%d", id);
933  if (method == "delete") {
934  nargchk(nrhs==3 && nlhs==0);
935  obj_.erase(id);
936  mexUnlock();
937  }
938  else if (method == "typeid") {
939  nargchk(nrhs==3 && nlhs<=1);
940  plhs[0] = MxArray(string(typeid(*obj).name()));
941  }
942  else if (method == "load") {
943  nargchk(nrhs==4 && nlhs==0);
944  obj->load(rhs[3].toString());
945  }
946  else if (method == "getNumSplits") {
947  nargchk(nrhs==3 && nlhs<=1);
948  plhs[0] = MxArray(obj->getNumSplits());
949  }
950  else if (method == "getTrain") {
951  nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
952  int splitNum = 0;
953  for (int i=3; i<nrhs; i+=2) {
954  string key(rhs[i].toString());
955  if (key == "SplitNum")
956  splitNum = rhs[i+1].toInt();
957  else
958  mexErrMsgIdAndTxt("mexopencv:error",
959  "Unrecognized option %s", key.c_str());
960  }
961  plhs[0] = toStruct(obj->getTrain(splitNum), klass);
962  }
963  else if (method == "getTest") {
964  nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
965  int splitNum = 0;
966  for (int i=3; i<nrhs; i+=2) {
967  string key(rhs[i].toString());
968  if (key == "SplitNum")
969  splitNum = rhs[i+1].toInt();
970  else
971  mexErrMsgIdAndTxt("mexopencv:error",
972  "Unrecognized option %s", key.c_str());
973  }
974  plhs[0] = toStruct(obj->getTest(splitNum), klass);
975  }
976  else if (method == "getValidation") {
977  nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
978  int splitNum = 0;
979  for (int i=3; i<nrhs; i+=2) {
980  string key(rhs[i].toString());
981  if (key == "SplitNum")
982  splitNum = rhs[i+1].toInt();
983  else
984  mexErrMsgIdAndTxt("mexopencv:error",
985  "Unrecognized option %s", key.c_str());
986  }
987  plhs[0] = toStruct(obj->getValidation(splitNum), klass);
988  }
989  else
990  mexErrMsgIdAndTxt("mexopencv:error",
991  "Unrecognized operation %s",method.c_str());
992 }
std::vector< double > times
const ConstMap< int, string > ImageTypeInvMap
map for cv::datasets::imageType enum values
Definition: Dataset_.cpp:97
MxArray toStruct_SLAM_kitti(const vector< Ptr< Object > > &objs)
Convert SLAM_kitti objects to struct array.
Definition: Dataset_.cpp:613
std::vector< Ptr< Object > > & getValidation(int splitNum=0)
MxArray toStruct_PD_caltech(const vector< Ptr< Object > > &objs)
Convert PD_caltech objects to struct array.
Definition: Dataset_.cpp:576
std::vector< std::string > lex100
std::vector< skeleton > skeletons
MxArray toStruct(const vector< Ptr< Object > > &objs, const string &klass)
Convert objects to struct array.
Definition: Dataset_.cpp:747
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
std::vector< std::string > lexFull
virtual void load(const std::string &path)=0
MxArray toStruct_FR_adience(const vector< Ptr< Object > > &objs)
Convert FR_adience objects to struct array.
Definition: Dataset_.cpp:275
Ptr< Y > staticCast() const
MxArray toStruct_OR_imagenet(const vector< Ptr< Object > > &objs)
Convert OR_imagenet objects to struct array.
Definition: Dataset_.cpp:509
STL namespace.
std::vector< std::string > imageNames
MxArray toStruct_MSM_middlebury(const vector< Ptr< Object > > &objs)
Convert MSM_middlebury objects to struct array.
Definition: Dataset_.cpp:491
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
MxArray toStruct_IS_bsds(const vector< Ptr< Object > > &objs)
Convert IS_bsds objects to struct array.
Definition: Dataset_.cpp:440
void set(mwIndex index, const T &value)
Template for numeric array element write accessor.
Definition: MxArray.hpp:1310
MxArray toStruct_HPE_humaneva(const vector< Ptr< Object > > &objs)
Convert HPE_humaneva objects to struct array.
Definition: Dataset_.cpp:371
STL class.
std::vector< word > words
backgroundType background
MxArray toStruct_OR_mnist(const vector< Ptr< Object > > &objs)
Convert OR_mnist objects to struct array.
Definition: Dataset_.cpp:525
const ConstMap< int, string > BackgroundTypeInvMap
map for cv::datasets::backgroundType enum values
Definition: Dataset_.cpp:81
void createDirectory(const std::string &path)
std::vector< std::string > velodyne
MxArray toStruct_SLAM_tumindoor(const vector< Ptr< Object > > &objs)
Convert SLAM_tumindoor objects to struct array.
Definition: Dataset_.cpp:644
std::vector< int > labels
int getNumSplits() const
illuminationType illumination
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: Dataset_.cpp:885
std::vector< Ptr< Object > > & getTest(int splitNum=0)
int last_id
Last object id to allocate.
Definition: Dataset_.cpp:46
MxArray toStruct_IR_robot(const vector< Ptr< Object > > &objs)
Convert IR_robot objects to struct array.
Definition: Dataset_.cpp:424
MxArray toStruct_AR_sports(const vector< Ptr< Object > > &objs)
Convert AR_sports objects to struct array.
Definition: Dataset_.cpp:259
const ConstMap< int, string > SampleTypeInvMap
map for cv::datasets::sampleType enum values
Definition: Dataset_.cpp:92
MxArray toStruct_PD_inria(const vector< Ptr< Object > > &objs)
Convert PD_inria objects to struct array.
Definition: Dataset_.cpp:592
MxArray toStruct_TRACK_alov(const vector< Ptr< Object > > &objs)
Convert TRACK_alov objects to struct array.
Definition: Dataset_.cpp:729
LIBMWMEX_API_EXTERN_C void mexErrMsgIdAndTxt(const char *identifier, const char *err_msg,...)
Issue formatted error message with corresponding error identifier and return to MATLAB prompt...
std::vector< Ptr< Object > > & getTrain(int splitNum=0)
std::vector< std::string > imageNames
MxArray toStruct_GR_skig(const vector< Ptr< Object > > &objs)
Convert GR_skig objects to struct array.
Definition: Dataset_.cpp:349
LIBMWMEX_API_EXTERN_C void mexUnlock(void)
Unlock a locked MEX-function so that it can be cleared from memory.
MxArray toStruct_GR_chalearn(const vector< Ptr< Object > > &objs)
Convert GR_chalearn objects to struct array.
Definition: Dataset_.cpp:320
MxArray toStruct_IS_weizmann(const vector< Ptr< Object > > &objs)
Convert IS_weizmann objects to struct array.
Definition: Dataset_.cpp:455
mxArray object wrapper for data conversion and manipulation.
Definition: MxArray.hpp:123
void nargchk(bool cond)
Alias for input/output arguments number check.
Definition: mexopencv.hpp:181
static MxArray Struct(const char **fields=NULL, int nfields=0, mwSize m=1, mwSize n=1)
Create a new struct array.
Definition: MxArray.hpp:312
MxArray toStruct_OR_pascal(const vector< Ptr< Object > > &objs)
Convert OR_pascal objects to struct array.
Definition: Dataset_.cpp:541
MxArray toStruct_OR_sun(const vector< Ptr< Object > > &objs)
Convert OR_sun objects to struct array.
Definition: Dataset_.cpp:560
static MxArray Cell(mwSize m=1, mwSize n=1)
Create a new cell array.
Definition: MxArray.hpp:290
MxArray toStruct_TR_svt(const vector< Ptr< Object > > &objs)
Convert TR_svt objects to struct array.
Definition: Dataset_.cpp:695
T size(T... args)
const ConstMap< int, string > PoseTypeInvMap
map for cv::datasets::poseType enum values
Definition: Dataset_.cpp:70
STL class.
bool empty() const
Global constant definitions.
MxArray toStruct_AR_hmdb(const vector< Ptr< Object > > &objs)
Convert AR_hmdb objects to struct array.
Definition: Dataset_.cpp:242
MxArray toStruct_FR_lfw(const vector< Ptr< Object > > &objs)
Convert FR_lfw objects to struct array.
Definition: Dataset_.cpp:303
T c_str(T... args)
Ptr< Dataset > create_Dataset(const string &type)
Create an instance of Dataset of specified type.
Definition: Dataset_.cpp:812
map< int, Ptr< Dataset > > obj_
Object container.
Definition: Dataset_.cpp:48
std::vector< pose > posesArray
const ConstMap< int, string > ActionTypeInvMap
map for cv::datasets::actionType enum values
Definition: Dataset_.cpp:57
const ConstMap< int, string > GenderTypeInvMap
map for cv::datasets::genderType enum values
Definition: Dataset_.cpp:51
std::vector< std::string > lex
std::vector< cameraPos > pos
std::vector< double > p[4]
std::vector< groundTruth > groundTruths
MxArray toStruct_HPE_parse(const vector< Ptr< Object > > &objs)
Convert HPE_parse objects to struct array.
Definition: Dataset_.cpp:393
MxArray toStruct_TR_chars(const vector< Ptr< Object > > &objs)
Convert TR_chars objects to struct array.
Definition: Dataset_.cpp:661
int type() const
MxArray toStruct_IR_affine(const vector< Ptr< Object > > &objs)
Convert IR_affine objects to struct array.
Definition: Dataset_.cpp:408
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927
std::vector< PascalObj > objects
void getDirList(const std::string &dirName, std::vector< std::string > &fileNames)
const ConstMap< int, string > DatasetTypeInvMap
map for cv::datasets::datasetType enum values
Definition: Dataset_.cpp:87
MxArray toStruct_TRACK_vot(const vector< Ptr< Object > > &objs)
Convert TRACK_vot objects to struct array.
Definition: Dataset_.cpp:712
void create(int arows, int acols, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
std::vector< tag > tags
MxArray toStruct_MSM_epfl(const vector< Ptr< Object > > &objs)
Convert MSM_epfl objects to struct array.
Definition: Dataset_.cpp:473
MxArray toStruct_TR_icdar(const vector< Ptr< Object > > &objs)
Convert TR_icdar objects to struct array.
Definition: Dataset_.cpp:677
std::vector< Rect > bndboxes
void split(const std::string &s, std::vector< std::string > &elems, char delim)
vector< Point2f > gtbb
vector< Point2d > gtbb
std::vector< std::string > images[4]
const ConstMap< int, string > IlluminationTypeInvMap
map for cv::datasets::illuminationType enum values
Definition: Dataset_.cpp:76