forked from davisking/dlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor rgb_pixel out of object detection
Also, move the vectorize template into its own header to stop having to declare it again in vector.
- Loading branch information
1 parent
c0d0adb
commit 68ae858
Showing
6 changed files
with
55 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include <dlib/python.h> | ||
#include <boost/python/args.hpp> | ||
#include "dlib/pixel.h" | ||
|
||
using namespace dlib; | ||
using namespace std; | ||
using namespace boost::python; | ||
|
||
// ---------------------------------------------------------------------------------------- | ||
|
||
string print_rgb_pixel_str(const rgb_pixel& p) | ||
{ | ||
std::ostringstream sout; | ||
sout << "red: "<< (int)p.red | ||
<< ", green: "<< (int)p.green | ||
<< ", blue: "<< (int)p.blue; | ||
return sout.str(); | ||
} | ||
|
||
string print_rgb_pixel_repr(const rgb_pixel& p) | ||
{ | ||
std::ostringstream sout; | ||
sout << "rgb_pixel(" << p.red << "," << p.green << "," << p.blue << ")"; | ||
return sout.str(); | ||
} | ||
|
||
// ---------------------------------------------------------------------------------------- | ||
void bind_image_classes() | ||
{ | ||
using boost::python::arg; | ||
|
||
class_<rgb_pixel>("rgb_pixel") | ||
.def(init<unsigned char,unsigned char,unsigned char>( (arg("red"),arg("green"),arg("blue")) )) | ||
.def("__str__", &print_rgb_pixel_str) | ||
.def("__repr__", &print_rgb_pixel_repr) | ||
.add_property("red", &rgb_pixel::red) | ||
.add_property("green", &rgb_pixel::green) | ||
.add_property("blue", &rgb_pixel::blue); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (C) 2014 Davis E. King (davis@dlib.net) | ||
// License: Boost Software License See LICENSE.txt for the full license. | ||
#ifndef DLIB_PYTHON_INDEXING_H__ | ||
#define DLIB_PYTHON_INDEXING_H__ | ||
|
||
namespace dlib | ||
{ | ||
template <typename T> | ||
void resize(T& v, unsigned long n) { v.resize(n); } | ||
} | ||
#endif // DLIB_PYTHON_INDEXING_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters