Skip to content

add clockwise image rotation #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Example usages in launch folder (**only the argument `video_stream_provider` is
<arg name="flip_horizontal" value="false" />
<!-- flip the image vertically -->
<arg name="flip_vertical" value="false" />
<!-- rotate image clockwise by 90 degrees once -->
<arg name="clockwise" value="false" />
<!-- force a width and height, 0 means no forcing -->
<arg name="width" value="640"/>
<arg name="height" value="480"/>
Expand Down Expand Up @@ -80,6 +82,7 @@ If you want to publish all images (don't drop any and you don't mind some possib
* `camera_info_url`: camera info loading, take care as it needs the "file:///" at the start , e.g.: `"file:///$(find your_camera_package)/config/your_camera.yaml"`.
* `flip_horizontal`: flip horizontally the image (mirror it).
* `flip_vertical`: flip vertically the image (upside down).
* `clockwise`: rotate image clockwise by 90 degrees once.
* `loop_videofile`: if the provider is a video file, enable loop playback.
* `width` and `height`: force a width and height to the capturing device (if it allows), 0 means no forcing.
* `start_frame`: if the provider is a video file, set the start frame of video.
Expand Down
1 change: 1 addition & 0 deletions cfg/VideoStream.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ gen.add("frame_id", str_t, LEVEL.RUNNING, "Camera FrameID", "camera")
gen.add("camera_info_url", str_t, LEVEL.RUNNING, "Camera info URL", "")
gen.add("flip_horizontal", bool_t, LEVEL.NORMAL, "Flip image horizontally", False)
gen.add("flip_vertical", bool_t, LEVEL.NORMAL, "Flip image vertically", False)
gen.add("clockwise", bool_t, LEVEL.NORMAL, "Rotate image clockwise by 90 degrees once", False)
gen.add("width", int_t, LEVEL.RUNNING, "Target width", 0, 0, 10000)
gen.add("height", int_t, LEVEL.RUNNING, "Target height", 0, 0, 10000)
gen.add("brightness", double_t, LEVEL.RUNNING, "Target brightness", 0.5019607843137255, 0.0, 1.0)
Expand Down
3 changes: 3 additions & 0 deletions launch/camera.launch
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
<arg name="flip_horizontal" default="false" />
<!-- flip the image vertically -->
<arg name="flip_vertical" default="false" />
<!-- rotate image clockwise by 90 degrees once -->
<arg name="clockwise" default="false" />
<!-- force width and height, 0 means no forcing -->
<arg name="width" default="0"/>
<arg name="height" default="0"/>
Expand All @@ -44,6 +46,7 @@
<param name="camera_info_url" type="string" value="$(arg camera_info_url)" />
<param name="flip_horizontal" type="bool" value="$(arg flip_horizontal)" />
<param name="flip_vertical" type="bool" value="$(arg flip_vertical)" />
<param name="clockwise" type="bool" value="$(arg clockwise)" />
<param name="loop_videofile" type="bool" value="$(arg loop_videofile)" />
<param name="start_frame" type="int" value="$(arg start_frame)" />
<param name="stop_frame" type="int" value="$(arg stop_frame)" />
Expand Down
2 changes: 2 additions & 0 deletions launch/mjpg_stream.launch
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<arg name="flip_horizontal" value="false" />
<!-- flip the image vertically -->
<arg name="flip_vertical" value="false" />
<!-- rotate image clockwise by 90 degrees once -->
<arg name="clockwise" default="false" />
<!-- visualize on an image_view window the stream generated -->
<arg name="visualize" value="false" />
</include>
Expand Down
2 changes: 2 additions & 0 deletions launch/rtsp_stream.launch
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<arg name="flip_horizontal" value="false" />
<!-- flip the image vertically -->
<arg name="flip_vertical" value="false" />
<!-- rotate image clockwise by 90 degrees once -->
<arg name="clockwise" default="false" />
<!-- visualize on an image_view window the stream generated -->
<arg name="visualize" value="true" />
</include>
Expand Down
2 changes: 2 additions & 0 deletions launch/video_file.launch
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<arg name="flip_horizontal" value="false" />
<!-- flip the image vertically -->
<arg name="flip_vertical" value="false" />
<!-- rotate image clockwise by 90 degrees once -->
<arg name="clockwise" default="false" />
<!-- enable looping playback -->
<arg name="loop_videofile" value="true" />
<!-- start frame of video -->
Expand Down
2 changes: 2 additions & 0 deletions launch/webcam.launch
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<arg name="flip_horizontal" value="false" />
<!-- flip the image vertically -->
<arg name="flip_vertical" value="false" />
<!-- rotate image clockwise by 90 degrees once -->
<arg name="clockwise" default="false" />
<!-- force width and height, 0 means no forcing -->
<!--
<arg name="width" value="0"/>
Expand Down
5 changes: 5 additions & 0 deletions src/video_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ virtual void do_publish(const ros::TimerEvent& event) {
cv::flip(frame, frame, 1);
else if (latest_config.flip_vertical)
cv::flip(frame, frame, 0);

if (latest_config.clockwise){
cv::rotate(frame, frame, cv::ROTATE_90_CLOCKWISE);
}
}
cv_bridge::CvImagePtr cv_image =
boost::make_shared<cv_bridge::CvImage>(header, "bgr8", frame);
Expand Down Expand Up @@ -385,6 +389,7 @@ virtual void configCallback(VideoStreamConfig& new_config, uint32_t level) {
NODELET_INFO_STREAM("Setting buffer size for capturing frames to: " << new_config.buffer_queue_size);
NODELET_INFO_STREAM("Flip horizontal image is: " << ((new_config.flip_horizontal)?"true":"false"));
NODELET_INFO_STREAM("Flip vertical image is: " << ((new_config.flip_vertical)?"true":"false"));
NODELET_INFO_STREAM("Rotate clockwise image is : " << ((new_config.clockwise)?"true":"false"));
NODELET_INFO_STREAM("Video start frame is: " << new_config.start_frame);
NODELET_INFO_STREAM("Video stop frame is: " << new_config.stop_frame);

Expand Down
2 changes: 2 additions & 0 deletions test/test_mjpg_stream.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<arg name="camera_info_url" default="" />
<arg name="flip_horizontal" default="false" />
<arg name="flip_vertical" default="false" />
<arg name="clockwise" default="false" />
<arg name="loop_videofile" default="false" />
<arg name="width" default="0"/>
<arg name="height" default="0"/>
Expand All @@ -26,6 +27,7 @@
<param name="camera_info_url" type="string" value="$(arg camera_info_url)" />
<param name="flip_horizontal" type="bool" value="$(arg flip_horizontal)" />
<param name="flip_vertical" type="bool" value="$(arg flip_vertical)" />
<param name="clockwise" type="bool" value="$(arg clockwise)" />
<param name="loop_videofile" type="bool" value="$(arg loop_videofile)" />
<param name="width" type="int" value="$(arg width)" />
<param name="height" type="int" value="$(arg height)" />
Expand Down
1 change: 1 addition & 0 deletions test/test_rtsp_stream.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<arg name="camera_info_url" value=""/>
<arg name="flip_horizontal" value="false"/>
<arg name="flip_vertical" value="false"/>
<arg name="clockwise" value="false"/>
<arg name="visualize" value="false"/>
</include>

Expand Down
1 change: 1 addition & 0 deletions test/test_video_file.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<arg name="camera_info_url" value=""/>
<arg name="flip_horizontal" value="false"/>
<arg name="flip_vertical" value="false"/>
<arg name="clockwise" value="false"/>
<arg name="loop_videofile" value="true"/>
<arg name="start_frame" value="30"/>
<arg name="stop_frame" value="150"/>
Expand Down