MCPcopy Create free account
hub / github.com/davisking/dlib / detect

Method detect

tools/python/src/cnn_face_detector.cpp:28–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26 }
27
28 std::vector<mmod_rect> detect (
29 py::array pyimage,
30 const int upsample_num_times
31 )
32 {
33 pyramid_down<2> pyr;
34 std::vector<mmod_rect> rects;
35
36 // Copy the data into dlib based objects
37 matrix<rgb_pixel> image;
38 if (is_image<unsigned char>(pyimage))
39 assign_image(image, numpy_image<unsigned char>(pyimage));
40 else if (is_image<rgb_pixel>(pyimage))
41 assign_image(image, numpy_image<rgb_pixel>(pyimage));
42 else
43 throw dlib::error("Unsupported image type, must be 8bit gray or RGB image.");
44
45 // Upsampling the image will allow us to detect smaller faces but will cause the
46 // program to use more RAM and run longer.
47 unsigned int levels = upsample_num_times;
48 while (levels > 0)
49 {
50 levels--;
51 pyramid_up(image, pyr);
52 }
53
54 auto dets = net(image);
55
56 // Scale the detection locations back to the original image size
57 // if the image was upscaled.
58 for (auto&& d : dets) {
59 d.rect = pyr.rect_down(d.rect, upsample_num_times);
60 rects.push_back(d);
61 }
62
63 return rects;
64 }
65
66 std::vector<std::vector<mmod_rect>> detect_mult (
67 py::list imgs,

Callers

nothing calls this directly

Calls 5

errorClass · 0.85
pyramid_upFunction · 0.85
assign_imageFunction · 0.50
rect_downMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected