| 75 | |
| 76 | template <typename T> |
| 77 | numpy_image<T> py_extract_image_4points ( |
| 78 | const numpy_image<T>& img, |
| 79 | const py::list& corners, |
| 80 | long rows, |
| 81 | long columns |
| 82 | ) |
| 83 | { |
| 84 | DLIB_CASSERT(rows >= 0); |
| 85 | DLIB_CASSERT(columns >= 0); |
| 86 | DLIB_CASSERT(len(corners) == 4); |
| 87 | |
| 88 | numpy_image<T> out; |
| 89 | set_image_size(out, rows, columns); |
| 90 | try |
| 91 | { |
| 92 | extract_image_4points(img, out, python_list_to_array<dpoint,4>(corners)); |
| 93 | return out; |
| 94 | } |
| 95 | catch (py::cast_error&){} |
| 96 | |
| 97 | try |
| 98 | { |
| 99 | extract_image_4points(img, out, python_list_to_array<line,4>(corners)); |
| 100 | return out; |
| 101 | } |
| 102 | catch(py::cast_error&) |
| 103 | { |
| 104 | throw dlib::error("extract_image_4points() requires the corners argument to be a list of 4 dpoints or 4 lines."); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | // ---------------------------------------------------------------------------------------- |
| 109 |
nothing calls this directly
no test coverage detected