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

Function register_extract_image_chip

tools/python/src/image2.cpp:162–468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160// ----------------------------------------------------------------------------------------
161
162void register_extract_image_chip (py::module& m)
163{
164 const char* class_docs =
165"WHAT THIS OBJECT REPRESENTS \n\
166 This is a simple tool for passing in a pair of row and column values to the \n\
167 chip_details constructor.";
168
169
170 auto print_chip_dims_str = [](const chip_dims& d)
171 {
172 std::ostringstream sout;
173 sout << "rows="<< d.rows << ", cols=" << d.cols;
174 return sout.str();
175 };
176 auto print_chip_dims_repr = [](const chip_dims& d)
177 {
178 std::ostringstream sout;
179 sout << "chip_dims(rows="<< d.rows << ", cols=" << d.cols << ")";
180 return sout.str();
181 };
182
183 py::class_<chip_dims>(m, "chip_dims", class_docs)
184 .def(py::init<unsigned long, unsigned long>(), py::arg("rows"), py::arg("cols"))
185 .def("__str__", print_chip_dims_str)
186 .def("__repr__", print_chip_dims_repr)
187 .def_readwrite("rows", &chip_dims::rows)
188 .def_readwrite("cols", &chip_dims::cols);
189
190
191
192 auto print_chip_details_str = [](const chip_details& d)
193 {
194 std::ostringstream sout;
195 sout << "rect=" << d.rect << ", angle="<< d.angle << ", rows="<< d.rows << ", cols=" << d.cols;
196 return sout.str();
197 };
198 auto print_chip_details_repr = [](const chip_details& d)
199 {
200 std::ostringstream sout;
201 sout << "chip_details(rect=drectangle("
202 << d.rect.left()<<","<<d.rect.top()<<","<<d.rect.right()<<","<<d.rect.bottom()
203 <<"), angle="<< d.angle << ", dims=chip_dims(rows="<< d.rows << ", cols=" << d.cols << "))";
204 return sout.str();
205 };
206
207
208 class_docs =
209"WHAT THIS OBJECT REPRESENTS \n\
210 This object describes where an image chip is to be extracted from within \n\
211 another image. In particular, it specifies that the image chip is \n\
212 contained within the rectangle self.rect and that prior to extraction the \n\
213 image should be rotated counter-clockwise by self.angle radians. Finally, \n\
214 the extracted chip should have self.rows rows and self.cols columns in it \n\
215 regardless of the shape of self.rect. This means that the extracted chip \n\
216 will be stretched to fit via bilinear interpolation when necessary." ;
217 /*!
218 WHAT THIS OBJECT REPRESENTS
219 This object describes where an image chip is to be extracted from within

Callers 1

bind_image_classes2Function · 0.85

Calls 6

argClass · 0.50
strMethod · 0.45
leftMethod · 0.45
topMethod · 0.45
rightMethod · 0.45
bottomMethod · 0.45

Tested by

no test coverage detected