Skip to content

leehwasu96/Cheongju-University-Camera

Repository files navigation

Cheongju University Camera(OpenCV) Lecture Notes

Author : Hwasu Lee

Affiliation : UNICON LAB (Incheon National University, South Korea)

Position : M.A. student

E-mail : leehwasu96@naver.com (or leehwasu9696@inu.ac.kr)

Course Duration

Date : 24.07.15 ~ 24.07.17

Camera(OpenCV) Lecture Note Description

"Camera Lecture Notes (1).pdf" file is the Camera(OpenCV) lecture notes.

"Camera Lecture Notes (2).pdf" file is the Camera(YOLO v8) lecture notes.

"Practice source code" folder is a directory that contains Python example codes related to OpenCV practice.

Commands for practicing OpenCV(Python) based on ROS.


Note: This practice was conducted in an Ubuntu 20.04 LTS and ROS(Robot Operating System) 1 Noetic environment.

To set up the project, follow these steps:

1. Install libraries related to 'OpenCV'


pip install opencv-python

or

pip3 install opencv-python

pip install numpy



2. Create a package for practicing OpenCV in the ROS Noetic environment


cd ~/catkin_ws/src
catkin_create_pkg opencv_test rospy std_msgs sensor_msgs cv_bridge



3. Set up CV bridge for integrating OpenCV with the ROS environment


cd opencv_test

Modify the 'CMakeLists.txt' file.

gedit CMakeLists.txt

Add the following commands to the file.

include_directories(
  ${catkin_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
)

Modify the 'package.xml' file.

gedit package.xml

Add the following commands to the file.

<build_depend>opencv</build_depend>
<exec_depend>opencv</exec_depend>



4. Create a 'scripts' folder for practicing OpenCV and build the catkin workspace


cd ~/catkin_ws/src/opencv_test
mkdir scripts
cd scripts

Download the Python practice code located in the 'OpenCV example source code' folder within the 'Practice source code' folder in the GitHub repository to the 'scripts' folder.

chmod +x *
cd ~/catkin_ws && catkin_make
source devel/setup.bash



5. Create a 'images' folder for practicing OpenCV


cd ~/catkin_ws/src/opencv_test
mkdir images
cd images

Download the files 'image.jpg', 'road1.jpg', 'road2.jpg' from the 'images' folder within the 'Practice source code' folder in the GitHub repository to the 'images' folder.


6. Perform OpenCV practice in the ROS environment


cd ~/catkin_ws/src/opencv_test/scripts

Note: Ensure to set the 'image_path' variable correctly to the path on your local PC within each Python practice code.

6-1. Practice displaying images using OpenCV.

python3 show_image.py

6-2. Practice converting images to gray scale using OpenCV.

python3 show_gray_scale_image.py

6-3. Practice edge detection in images using OpenCV.

python3 show_edge_image.py

6-4. Practice contour detection in images using OpenCV.

python3 show_contour_image.py

6-5. Practice image rotation, resizing, and skew transformations using OpenCV.

python3 show_turn_resize_affine_image.py

6-6. Practice image filtering using Gaussian blur in OpenCV.

python3 show_blurred_image.py

6-7. Practice face detection in images using OpenCV.

python3 show_face_detection_image.py

6-8. Practice lane detection in images using Hough transform in OpenCV.

python3 hough_lane_detection.py

6-9. Practice lane detection in images using HSV(Hue+Saturation+Value) in OpenCV.

python3 hsv_lane_detection.py

6-10. Practice lane detection in images using
Hough transform and HSV(Hue+Saturation+Value) in OpenCV.

python3 hough_hsv_lane_detection.py



7. Practice lane detection and tracking using the ROS Gazebo simulation environment


7-1. ROS Gazebo simulation environment setup.

cd ~/catkin_ws/src/

git clone https://github.com/gihoonbackend/ackermann_vehicle.git

or

git clone https://github.com/0-keun/ackermann_vehicle.git

sudo apt install ros-noetic-ackermann-msgs

cd ..

rosdep install --from-paths src --ignore-src -r –y

catkin_make

source devel/setup.bash

Set Gazebo simulation environment variables in the bashrc file and perform sourcing.

gedit ~/.bashrc

Caution: Make sure to accurately write the path on your local PC.

export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:/home/{your PC name}/catkin_ws/src/ackermann_vehicle/roadmap_generator
source ~/.bashrc

7-2. Run the ROS Gazebo simulation environment.

cd catkin_ws/src/ackermann_vehicle/ackermann_vehicle_gazebo/launch
roslaunch ackermann_vehicle_noetic.launch

If the track is not created as shown in the picture below, enter the following path and replace the image file('road_straight.png' and 'road_curve.png' file), then re-run the launch file.

track_error


cd ~/catkin_ws/src/ackermann_vehicle/roadmap_generator/road_straight/materials/textures

Replace the 'road_straight.png' file with the new 'road_straight.png' file located in the images folder within the Practice source code folder in the GitHub repository.


cd ~/catkin_ws/src/ackermann_vehicle/roadmap_generator/road_curve/materials/textures

Replace the 'road_curve.png' file with the new 'road_curve.png' file located in the 'images' folder within the 'Practice source code' folder in the GitHub repository.


7-3. Download all the Python practice codes located in the 'Gazebo simulation source code' folder within the 'Practice source code' folder in the GitHub repository to the 'scripts' folder in the 'ackermann_vehicle_gazebo' package on your local PC.


7-4. Practice detecting white and yellow lanes in the Gazebo simulation track.

cd catkin_ws/src/ackermann_vehicle/ackermann_vehicle_gazebo/scripts

python3 lane_detection.py

lane_detection_result.mp4



7-5. Practice detecting white lanes after converting the camera image to a bird's-eye view in the Gazebo simulation track.

cd catkin_ws/src/ackermann_vehicle/ackermann_vehicle_gazebo/scripts

python3 bev_lane_detection.py

bev_lane_detection_result.mp4



7-6. Practice detecting and tracking white lanes after converting the camera image to a bird's-eye view in the Gazebo simulation track.

cd catkin_ws/src/ackermann_vehicle/ackermann_vehicle_gazebo/scripts

python3 bev_lane_detection_and_tracking.py

bev_lane_detection_and_tracking_result.mp4



7-7. Practice detecting white and yellow lanes, extracting midpoints, and following them after converting the camera image to a bird's-eye view in the Gazebo simulation track.

cd catkin_ws/src/ackermann_vehicle/ackermann_vehicle_gazebo/scripts

python3 bev_lane_detection_and_tracking2.py

bev_lane_detection_and_tracking2_result.mp4



Releases

No releases published

Packages

No packages published