User Tools

Site Tools


projects:farmrobot:step-by-step-example

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
projects:farmrobot:step-by-step-example [2021/02/27 16:17]
jason
projects:farmrobot:step-by-step-example [2021/04/01 02:25] (current)
Line 59: Line 59:
  
 <WRAP info> <WRAP info>
-Consult the repository's [[https://git.hsrw.eu/jason.theiler/farm-robot-yolov5/-/blob/master/README.md|README]] to get more information about the ''nvgstcapture-1.0'' tool.+Consult the repository's [[https://gitlab.com/fablabkamplintfort1/farmrobot/-/blob/master/README.md|README]] to get more information about the ''nvgstcapture-1.0'' tool.
 </WRAP> </WRAP>
  
Line 143: Line 143:
 ===== - Setting up our custom implementation of YOLOv5 ===== ===== - Setting up our custom implementation of YOLOv5 =====
  
-First, clone the [[https://gitlab.hsrw.eu/jason.theiler/farm-robot-yolov5|repository]] into the home (''~'') directory:+==== - Cloning the repositories ==== 
 + 
 +First, clone the [[https://gitlab.com/fablabkamplintfort1/farmrobot|repository]] into the home (''~'') directory:
  
 <file shell> <file shell>
-git clone https://gitlab.hsrw.eu/jason.theiler/farm-robot-yolov5.git+git clone https://gitlab.com/fablabkamplintfort1/farmrobot.git
 </file> </file>
  
Line 159: Line 161:
 Once this is set up, you are theoretically ready to build the [[https://www.docker.com/|Docker]] image. But you usually want to configure the implementation via the ''.toml'' configuration files first. Once this is set up, you are theoretically ready to build the [[https://www.docker.com/|Docker]] image. But you usually want to configure the implementation via the ''.toml'' configuration files first.
  
-The repository comes with a ''default_config.toml'' which contains the default configuration. **However, you should not edit this file directly, since it is version controlled by the repository!** Instead, copy the file with a new name (e.g. ''config.toml''), like so:+==== - Configuration ==== 
 + 
 +The repository comes with a ''default_config.toml'' which contains the default configuration. **However, you should not edit this file directly, since it is version controlled by the repository!** Instead, copy the file with a new name (''config.toml''), like so:
  
 <file shell> <file shell>
Line 165: Line 169:
 </file> </file>
  
 +The ''config.toml'' file is ignored by default, so you can edit it however you like.
 +
 +In the newly created ''config.toml'' you will have to edit atleast one value, the ''source''. The ''source'' value should consist of a [[https://gstreamer.freedesktop.org/|GStreamer]] pipeline. With the [[https://www.elpcctv.com/-p-248.html|ELP-USB8MP02G-SFV]] camera, you can use the following [[https://gstreamer.freedesktop.org/|GStreamer]] pipeline:
 +
 +<file shell>
 +v4l2src device=/dev/video0 ! image/jpeg, width=2592, height=1944, framerate=15/1 ! nvv4l2decoder mjpeg=1 ! nvvidconv flip-method=0 ! video/x-raw, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink
 +</file>
 +
 +<WRAP important>
 +It is important to replace the ''width='', ''height='' and ''framerate='' values, with the values of a supported format of the used camera!
 +</WRAP>
 +
 +The configured ''config.toml'' should look something like this now:
 +
 +<file toml>
 +[yolov5]
 +# Input source.
 +source = "v4l2src device=/dev/video0 ! image/jpeg, width=2592, height=1944, framerate=15/1 ! nvv4l2decoder mjpeg=1 ! nvvidconv flip-method=0 ! video/x-raw, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink"
 +
 +...
 +</file>
 +
 +<WRAP info>
 +Consult the repository's [[https://gitlab.com/fablabkamplintfort1/farmrobot/-/blob/master/README.md|README]] to get more information about [[https://gstreamer.freedesktop.org/|GStreamer]] pipelines.
 +</WRAP>
 +
 +<WRAP important>
 +If you intend to run the [[https://www.nvidia.com/en-us/autonomous-machines/embedded-systems/jetson-xavier-nx/|NVIDIA Jetson Xavier NX]] without an internet connection, you have to manually download the configured ''weights'', before you build and instantiate the [[https://www.docker.com/|Docker]] container. The default [[https://github.com/ultralytics/yolov5|YOLOv5]] weights can be found on its [[https://github.com/ultralytics/yolov5/releases|releases page]].
 +</WRAP>
 +
 +==== - Building the Docker image ====
 +
 +Building the [[https://www.docker.com/|Docker]] image is easy and straightforward. Simply run:
 +
 +<file shell>
 +sudo docker build -t farm-robot-yolov5 .
 +</file>
 +
 +<WRAP important>
 +The build process of the [[https://www.docker.com/|Docker]] image could take up to an hour!
 +</WRAP>
 +
 +==== - Instantiating the Docker container ====
 +
 +When instantiating the [[https://www.docker.com/|Docker]] container you need to pay attention to mount all required devices (camera and configured Arduino)! With the devices used in this example, you can instantiate the container, like so:
 +
 +<file shell>
 +sudo docker run -it --rm --runtime nvidia --device /dev/video0 --device /dev/ttyUSB0 farm-robot-yolov5
 +</file>
 +
 +<WRAP info>
 +Consult the repository's [[https://gitlab.com/fablabkamplintfort1/farmrobot/-/blob/master/README.md|README]] to get more information about mounting devices to a [[https://www.docker.com/|Docker]] container.
 +</WRAP>
 +
 +==== - Starting the inference ====
 +
 +Once the interactive [[https://www.docker.com/|Docker]] container booted, you can run the ''__main__.py'':
 +
 +<file shell>
 +python3 .
 +</file>
 +
 +If everything is configured correctly, the delta arm should start to move to its home position and then to its configured initial position. A few seconds after that, [[https://github.com/ultralytics/yolov5|YOLOv5]]'s inference should start. When [[https://github.com/ultralytics/yolov5|YOLOv5]] detects an object that has been declared as a "target" (via the ''targets'' list in the ''config.toml''), the delta arm should move to the object's position.
  
projects/farmrobot/step-by-step-example.1614442653.txt.gz · Last modified: 2021/02/27 16:17 by jason