29#include <Image/ImageProcessor.h>
45 ARMARX_DEBUG <<
"Initializing SimpleEpisodicMemoryImageConnector";
49 ARMARX_VERBOSE <<
"Using image provider with ID '" << m_image_provider_id <<
"'.";
54 m_image_received =
false;
70 num_of_received_images =
static_cast<unsigned int>(m_image_provider_info.numberImages);
71 m_input_image_buf = new ::CByteImage*[num_of_received_images];
72 for (
unsigned int i = 0; i < num_of_received_images; ++i)
80 this, &SimpleEpisodicMemoryImageConnector::checkForNewImages, m_periodic_task_interval);
81 m_periodic_task->start();
89 m_periodic_task->stop();
94 for (
unsigned int i = 0; i < num_of_received_images; ++i)
96 delete m_input_image_buf[i];
98 delete[] m_input_image_buf;
110 const IceUtil::Time timeout = IceUtil::Time::milliSeconds(1000);
111 if (!
waitForImages(m_image_provider_id,
static_cast<int>(timeout.toMilliSeconds())))
113 ARMARX_WARNING <<
"Timeout while waiting for camera images (>" << timeout <<
")";
117 ARMARX_DEBUG <<
"Received a new image. Putting image to member variable";
118 std::lock_guard<std::mutex> lock{m_input_image_mutex};
120 int num_images =
getImages(m_image_provider_id, m_input_image_buf, m_image_meta_info);
121 m_timestamp_last_image = IceUtil::Time::microSeconds(m_image_meta_info->timeProvided);
123 if (
static_cast<unsigned int>(num_images) != num_of_received_images)
130 ::ImageProcessor::CopyImage(m_input_image_buf[m_image_provider_channel], m_input_image);
131 m_image_received =
true;
137visionx::SimpleEpisodicMemoryImageConnector::checkForNewImages()
140 if (!m_image_received)
146 <<
"Got a new image for processing. Send image to EpisodicMemory. Image information: Size: "
147 << m_input_image->width <<
", " << m_input_image->height <<
", "
148 << m_input_image->bytesPerPixel;
149 std::lock_guard<std::mutex> lock{m_input_image_mutex};
150 m_image_received =
false;
154 memoryx::ImageEvent memory_image_event;
155 memory_image_event.providerName =
156 m_image_provider_id +
"__" + std::to_string(m_image_provider_channel);
157 memory_image_event.receivedInMs = m_timestamp_last_image.toMilliSecondsDouble();
158 memory_image_event.height = m_input_image->height;
159 memory_image_event.width = m_input_image->width;
160 memory_image_event.colourType =
161 (m_input_image->bytesPerPixel == 3 ? memoryx::ColourSpace::RGB
162 : memoryx::ColourSpace::GRAYSCALE);
163 memory_image_event.data = std::vector<unsigned char>(
164 m_input_image->pixels,
165 m_input_image->pixels +
166 (m_input_image->height * m_input_image->width * m_input_image->bytesPerPixel));
167 m_simple_episodic_memory->registerImageEvent(memory_image_event);
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Property< PropertyType > getProperty(const std::string &name)
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
The periodic task executes one thread method repeatedly using the time period specified in the constr...
std::string m_simple_episodic_memory_proxy_name
memoryx::SimpleEpisodicMemoryInterface::ProxyType m_simple_episodic_memory
void usingImageProvider(std::string name)
Registers a delayed topic subscription and a delayed provider proxy retrieval which all will be avail...
bool waitForImages(int milliseconds=1000)
Wait for new images.
ImageProviderInfo getImageProvider(std::string name, ImageType destinationImageType=eRgb, bool waitForProxy=false)
Select an ImageProvider.
int getImages(CByteImage **ppImages)
Poll images from provider.
void setFramerate(float fps)
void onConnectImageProcessor() override
Implement this method in the ImageProcessor in order execute parts when the component is fully initia...
void onExitImageProcessor() override
Exit the ImapeProcessor component.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void process() override
Process the vision component.
void onInitImageProcessor() override
Setup the vision component.
void onDisconnectImageProcessor() override
Implement this method in the ImageProcessor in order execute parts when the component looses network ...
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
#define ARMARX_VERBOSE
The logging level for verbose information.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.