23 #include "retriever_thread.h" 25 #include <fvcams/camera.h> 26 #include <fvutils/ipc/shm_image.h> 27 #include <utils/time/tracker.h> 28 #include <fvutils/writers/seq_writer.h> 29 #include <fvutils/writers/jpeg.h> 30 #include <fvmodels/color/lookuptable.h> 51 std::string cfg_name, std::string cfg_prefix)
52 :
Thread(
"FvRetrieverThread",
Thread::OPMODE_WAITFORWAKEUP),
56 cfg_prefix_ = cfg_prefix;
57 camera_string_ = camera_string;
58 set_name(
"FvRetrieverThread_%s", cfg_name_.c_str());
72 colorspace_t cspace = YUV422_PLANAR;
73 std::string cspace_str = colorspace_to_string(cspace);
76 cspace = colorspace_by_name(cspace_str.c_str());
78 if (cspace == CS_UNKNOWN) {
79 throw Exception(
"Unknown colorspace '%s' configured", cspace_str.c_str());
84 camera_string_.c_str(), colorspace_to_string(cspace));
87 e.
append(
"FvRetrieverThread::init() failed");
92 if ( asprintf(&imgbufname,
"retriever_%s", cfg_name_.c_str()) == -1 ) {
93 throw Exception(
"Cannot allocate buffer name");
100 throw Exception(
"Shared memory segment not valid");
119 std::string save_path;
123 save_path = (
"recorded_images");
126 seq_writer->
set_path( save_path.c_str() );
136 if (
config->
get_bool(
"/firevision/retriever/use_time_tracker") ) {
138 __ttc_capture = __tt->
add_class(
"Capture");
139 __ttc_memcpy = __tt->
add_class(
"Memcpy");
140 __ttc_dispose = __tt->
add_class(
"Dispose");
149 for (
unsigned int u = 100; u < 150; ++u) {
150 for (
unsigned int v = 100; v < 150; ++v) {
151 ycm->
set(128, u, v, C_ORANGE);
155 __cam_has_timestamp_support =
true;
165 __cam_has_timestamp_support =
false;
203 if ( (++__loop_count % 200) == 0 ) {
213 if (__cam_has_timestamp_support) {
virtual unsigned int buffer_size()=0
Size of buffer.
void ping_start(unsigned int cls)
Start of given class task.
virtual void init()
Initialize the thread.
virtual void log_info(const char *component, const char *format,...)=0
Log informational message.
void lock_for_write()
Lock shared memory segment for writing.
Fawkes library namespace.
Interface to write images.
virtual bool get_bool(const char *path)=0
Get value from configuration which is of type bool.
firevision::VisionMaster * vision_master
Vision master.
virtual ~FvRetrieverThread()
Destructor.
Called method has not been implemented.
virtual unsigned int pixel_width()=0
Width of image in pixels.
A class for handling time.
Color model based on a lookup table.
FvRetrieverThread(std::string camera_string, std::string cfg_name, std::string cfg_prefix)
Constructor.
Thread class encapsulation of pthreads.
virtual colorspace_t colorspace()=0
Colorspace of returned image.
Logger * logger
This is the Logger member used to access the logger.
YuvColormap * get_colormap() const
Get colormap.
bool is_valid() const
Check validity of shared memory segment.
virtual void unregister_thread(fawkes::Thread *thread)=0
Unregister a thread.
unsigned char * buffer() const
Get image buffer.
Clock * clock
By means of this member access to the clock is given.
void set_colorspace(colorspace_t cspace)
Set the colorspace of the image.
Writes a sequence of images to disk.
void set_name(const char *format,...)
Set name of thread.
Base class for exceptions in Fawkes.
virtual void capture()=0
Capture an image.
virtual fawkes::Time * capture_time()
Get the Time of the last successfully captured image.
Thread aspect to use in FireVision apps.
void set_frame_id(const char *frame_id)
Set frame ID.
virtual void set(unsigned int y, unsigned int u, unsigned int v, color_t c)
Set color class for given YUV value.
unsigned int add_class(std::string name)
Add a new class.
Shared memory image buffer.
bool is_zero() const
Check if time is zero.
const char * name() const
Get name of thread.
void set_dimensions(unsigned int width, unsigned int height)
Set the image dimensions.
void ping_end(unsigned int cls)
End of given class task.
void print_to_stdout()
Print results to stdout.
virtual void log_debug(const char *component, const char *format,...)=0
Log debug message.
virtual unsigned char * buffer()=0
Get access to current image buffer.
virtual unsigned int pixel_height()=0
Height of image in pixels.
Time & stamp()
Set this time to the current time.
void write(unsigned char *buffer)
Write a single image to disk.
void set_path(const char *img_path)
Set the path to where the images are stored.
virtual void loop()
Thread loop.
virtual Camera * register_for_camera(const char *camera_string, fawkes::Thread *thread, colorspace_t cspace=YUV422_PLANAR)=0
Register thread for camera.
Configuration * config
This is the Configuration member used to access the configuration.
virtual void finalize()
Finalize the thread.
void set_capture_time(fawkes::Time *time)
Set the capture time.
void unlock()
Unlock memory.
void append(const char *format,...)
Append messages to the message list.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.
virtual void dispose_buffer()=0
Dispose current buffer.