| 69 | } |
| 70 | |
| 71 | std::shared_ptr<full_object_detection> full_obj_det_init(const rectangle& rect, const py::object& pyparts_) |
| 72 | { |
| 73 | try |
| 74 | { |
| 75 | auto&& pyparts = pyparts_.cast<py::list>(); |
| 76 | |
| 77 | const unsigned long num_parts = py::len(pyparts); |
| 78 | std::vector<point> parts; |
| 79 | for (const auto& item : pyparts) |
| 80 | parts.push_back(item.cast<point>()); |
| 81 | |
| 82 | return std::make_shared<full_object_detection>(rect, parts); |
| 83 | } |
| 84 | catch (py::cast_error&) |
| 85 | { |
| 86 | // if it's not a py::list it better be a vector<point>. |
| 87 | auto&& parts = pyparts_.cast<const std::vector<point>&>(); |
| 88 | return std::make_shared<full_object_detection>(rect, parts); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | // ---------------------------------------------------------------------------------------- |
| 93 | |