Skip to content

Commit 390ae3c

Browse files
committed
The last frame was published indefinitely when playing a video file, now we stop
1 parent 339cc06 commit 390ae3c

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/video_stream.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,16 @@ virtual void do_publish(const ros::TimerEvent& event) {
187187
}
188188

189189
// Check if grabbed frame is actually filled with some content
190-
if(!frame.empty()) {
190+
if(!frame.empty() && is_new_image) {
191191
// From http://docs.opencv.org/modules/core/doc/operations_on_arrays.html#void flip(InputArray src, OutputArray dst, int flipCode)
192192
// FLIP_HORIZONTAL == 1, FLIP_VERTICAL == 0 or FLIP_BOTH == -1
193193
// Flip the image if necessary
194-
if (is_new_image){
195-
if (latest_config.flip_horizontal && latest_config.flip_vertical)
196-
cv::flip(frame, frame, -1);
197-
else if (latest_config.flip_horizontal)
198-
cv::flip(frame, frame, 1);
199-
else if (latest_config.flip_vertical)
200-
cv::flip(frame, frame, 0);
201-
}
194+
if (latest_config.flip_horizontal && latest_config.flip_vertical)
195+
cv::flip(frame, frame, -1);
196+
else if (latest_config.flip_horizontal)
197+
cv::flip(frame, frame, 1);
198+
else if (latest_config.flip_vertical)
199+
cv::flip(frame, frame, 0);
202200
cv_bridge::CvImagePtr cv_image =
203201
boost::make_shared<cv_bridge::CvImage>(header, "bgr8", frame);
204202
if (latest_config.output_encoding != "bgr8")

0 commit comments

Comments
 (0)