MCPcopy Create free account
hub / github.com/biometrics/openbr / project

Method project

openbr/plugins/classification/dlib.cpp:45–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43 }
44
45 void project(const Template &src, Template &dst) const
46 {
47 dst = src;
48
49 shape_predictor *const sp = shapeResource.acquire();
50
51 cv::Mat cvImage = src.m();
52 if (cvImage.channels() == 3)
53 cv::cvtColor(cvImage, cvImage, CV_BGR2GRAY);
54
55 cv_image<unsigned char> cimg(cvImage);
56 array2d<unsigned char> image;
57 assign_image(image,cimg);
58
59 if (src.file.rects().isEmpty()) { //If the image has no rects assume the whole image is a face
60 rectangle r(0, 0, cvImage.cols, cvImage.rows);
61 full_object_detection shape = (*sp)(image, r);
62 for (size_t i = 0; i < shape.num_parts(); i++)
63 dst.file.appendPoint(QPointF(shape.part(i)(0),shape.part(i)(1)));
64 }
65 else { // Crop the image on the rects
66 for (int j=0; j<src.file.rects().size(); ++j)
67 {
68 QRectF rect = src.file.rects()[j];
69 rectangle r(rect.left(),rect.top(),rect.right(),rect.bottom());
70 full_object_detection shape = (*sp)(image, r);
71 for (size_t i=0; i<shape.num_parts(); i++)
72 dst.file.appendPoint(QPointF(shape.part(i)(0),shape.part(i)(1)));
73 }
74 }
75
76 shapeResource.release(sp);
77 }
78};
79
80BR_REGISTER(Transform, DLandmarkerTransform)

Callers

nothing calls this directly

Calls 8

acquireMethod · 0.80
isEmptyMethod · 0.80
rectsMethod · 0.80
appendPointMethod · 0.80
rightMethod · 0.80
partMethod · 0.45
sizeMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected