@@ -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