yolov5 image recognition

       This case uses the eye-to-hand mode, uses the camera to take pictures, loads the yolov5 model data through OpenCV, recognizes the image block and locates the position of the image block in the recognition area. Through the relevant points, the space coordinate position of the block relative to the robot arm is calculated. Set a set of related actions for the robot arm, and put the recognized object into the corresponding area.

1 Camera Adjustment

First, you need to use python to run OpenVideo.py under the aikit_V2 package. If the enabled camera is a computer camera, cap_num needs to be modified. For details, please refer to: Precautions. Make sure that the camera completely covers the entire recognition area, and the recognition area is square in the video, as shown in the figure below. If the recognition area does not meet the requirements in the video, the camera position needs to be adjusted.

M5 version:

  • Open a command prompt terminal (shortcut Win+R, enter "cmd" to access the terminal). Switch to the directory path where "aikit_V2" is located, then enter the target folder.
cd Desktop/aikit_V2/AiKit_270M5/
  • Enter the following command to open the camera for adjustment
python scripts/OpenVideo.py

Raspberry Pi version:

  • Open a console terminal (shortcut key Ctrl+Alt+T), enter the target folder
cd ~/aikit_V2/AiKit_270Pi/
  • Enter the following command to open the camera for adjustment
python scripts/OpenVideo.py

2 Case Reproduction

M5 version:

  • Open a command prompt terminal (shortcut Win+R, enter "cmd" to access the terminal). Switch to the directory path where "aikit_V2" is located, then enter the target folder.
cd Desktop/aikit_V2/AiKit_270M5/
  • Then enter the following command to start the yolov5 recognition program.
python scripts/yolov5_img.py

Raspberry Pi version:

  • Open a console terminal (shortcut key Ctrl+Alt+T), enter the following command to enter the target folder:
cd ~/aikit_V2/AiKit_270Pi
  • Then enter the following command to start the yolov5 recognition program.
python scripts/yolov5_img.py
  • When the camera window can be opened normally, it means that the program is running successfully. At this time, you can place the identifiable object in the recognition area, and take pictures and intercept according to the terminal prompts. When the command terminal shows ok, it means that yolov5 is recognizing and grasping, and the robot arm is completed. After a single capture, press the space bar for the next image recognition.

Precautions

  1. If the command terminal does not display ok, and the picture cannot be recognized, you need to move the camera slightly backward or forward, and the program can run normally when the command terminal displays ok.

  2. In order to better recognize the picture, you need to reverse the object in the recognition area.

results matching ""

    No results matching ""