Der Name des default branch ist ab jetzt für neue Repositories main. The name of the default branch for new repositories is from now on main.

Commit 0e71db5a authored by Daniel Müller's avatar Daniel Müller
Browse files

Merge branch 'fix/image-streaming' into 'master'

[impl] Streaming mode

See merge request !9
parents 1b00ad54 b7c7d89b
......@@ -56,7 +56,6 @@ public:
~ImageDisplay();
/** @brief callback for sensorMsgs::Images encapsulated in an ImageDisplay msg*/
void callbackImageDisplay(const homer_robot_face::DisplayImage::ConstPtr& image_msg);
/** @brief callback for images from harddisk*/
public slots:
void pop_image_from_queue();
......@@ -75,6 +74,7 @@ private:
* the display frequency)*/
std::queue<std::unique_ptr<QImage>> image_queue_;
std::queue<int> timeout_queue_;
bool streaming_mode_ = false;
/** @brief timer to specify the duration of painting the current image*/
QTimer* reset_timer_; // no smart pointer when using parenting of Qt
......
......@@ -202,16 +202,30 @@ void ImageDisplay::processImageData(const homer_robot_face::DisplayImage::ConstP
image_ptr->detach();
}
streaming_mode_ = (image_msg->time == 0) ? true : false;
if (streaming_mode_)
{
while (image_queue_.size() > 0)
{
pop_image_from_queue();
}
timeout_queue_.push(2000);
}
else
{
timeout_queue_.push(image_msg->time);
}
image_queue_.push(std::move(image_ptr));
timeout_queue_.push(image_msg->time * 1000);
}
void ImageDisplay::callbackImageDisplay(const homer_robot_face::DisplayImage::ConstPtr& image_msg)
{
// ROS_INFO_STREAM("Received ImageDisplay msg, draw image for " << image_msg->time << "seconds.");
// ROS_INFO_STREAM("Received ImageDisplay msg, draw image for " << image_msg << "milliseconds.");
processImageData(image_msg);
if (image_queue_.size()<2)
if (image_queue_.size()<2 || streaming_mode_)
{
emit newImageToShow();
}
......
......@@ -20,19 +20,16 @@ class RobotFaceInterface:
bridge = CvBridge()
@staticmethod
def display_image_on_front_display(image, displayTime=1):
def display_image_on_front_display(image, displayTime=1000):
"""This method displays an image on Lisas face.\
:path: Path of imagefile to display as `String`
:displayTime: Duration in seconds that image should be displayed for
:image: Image to be displayed, can be `ROS Image` or `Numpy array`
:displayTime: Duration in milliseconds that image should be displayed for. \
If 0 then will be displayed for max of 2 secs or until new image is recieved
:returns: `None`
"""
#print(type(image))
if (type(image) == numpy.ndarray):
#print("is numpy.ndarray")
imageTemp = image
if image.dtype == numpy.dtype('float64'):
imageTemp = (image * 255).astype('uint8')
......@@ -47,8 +44,6 @@ class RobotFaceInterface:
)
elif (type(image) == Image):
#print("is rosImage")
RobotFaceInterface.imagePublisher.publish(
DisplayImage(
time = displayTime,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment