gscam
ROS1

gscam

테스트 환경

  • ROS Noetic
  • Webcam

프로그램을 실행하기 전 필요한 패키지들을 설치해준다.

sudo apt-get install gstreamer1.0-tools libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev

 

진행 전 ros 환경 설정을 진행합니다

source /opt/ros/foxy/setup.bash​​


다음 명령을 실행하여 작업 공간이 될 디렉토리를  생성

mkdir -p ~/gscam_ws/src​

 

작업 공간에서 gscam 패키지를 다운

cd ~/gscam_ws/src
git clone https://github.com/ros-drivers/gscam
cd gscam
sed -e "s/EXTRA_CMAKE_FLAGS = -DUSE_ROSBUILD:BOOL=1$/EXTRA_CMAKE_FLAGS = -DUSE_ROSBUILD:BOOL=1 -DGSTREAMER_VERSION_1_x=On/" -i Makefile

 

빌드 전 아래 이슈 수정 후 다음 단계 진행 - Gstreamer 1.16 이상 버전에서 사용 시 아래 패치를 적용해야 함

https://github.com/ros-drivers/gscam/pull/61/commits/a39c04b056e7f66ec6b0b283d77e3a16f7a25588

 

Fixed incorrect unref for gstreamer >= 1.16. by kaarta-ttaylor · Pull Request #61 · ros-drivers/gscam

The buffer is accessed through gst_sample_get_buffer. The buffer shouldn't be unrefed the sample should be, however, this doesn't seem work in gstreamer 1.14. If the buffer is unreffed in 1.16 it...

github.com

 

빌드 진행

cd ~/gscam_ws

sudo rosdep init # if you have not done this before
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro noetic -y
*rosdep: command not found* 시 
sudo apt install python3-rosdep 진행
*gscam2: Cannot locate rosdep definition for [camera_info_manager]* 시 
sudo apt install ros-noetic-camera-info-manager

catkin_make

 

 gscam을 실행시키기 위해 환경 설정을 진행

source ~/gscam_ws/devel/setup.bash

 

GStreamer 파이프라인이 gst-launch-1.0에서 성공적으로 실행되는지 확인, 예를 들어 웹캠을 동작시키기 위한 파이프라인은 아래와 같음

gst-launch-1.0 v4l2src device=/dev/video0 ! xvimagesink​

*영상이 나오지 않는다면 export GST_V4L2_USE_LIBV4L2=1 명령어를 실행 후 재 시도

 

gscam에서 사용하려면 아래와 같이 진행

export GST_V4L2_USE_LIBV4L2=1
export GSCAM_CONFIG="v4l2src device=/dev/video0 ! videoconvert"
rosrun gscam gscam

 

gscam을 통해 전송되는 이미지를 보기 위해서는 rqt_image_view 툴을 실행

source /opt/ros/noetic/setup/bash
rosrun rqt_image_view rqt_image_view

 

 

 

출처 :

https://github.com/ros-drivers/gscam

 

GitHub - ros-drivers/gscam: ROS Camera driver for GStreamer-based video streams.

ROS Camera driver for GStreamer-based video streams. - GitHub - ros-drivers/gscam: ROS Camera driver for GStreamer-based video streams.

github.com

 

 

 

 

 

'ROS1' 카테고리의 다른 글

usb_cam  (0) 2024.01.15