User Tools

Site Tools


projects:farmrobot:nvidia-jetson-tx1

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
Next revision Both sides next revision
projects:farmrobot:nvidia-jetson-tx1 [2021/01/03 20:13]
jason
projects:farmrobot:nvidia-jetson-tx1 [2021/01/10 02:12]
jason
Line 6: Line 6:
 | ''jetson''  | ''jetson''    | | ''jetson''  | ''jetson''    |
  
-===== Stats =====+===== Running YOLOv5 with on-board camera ===== 
 + 
 +Arguments for NVIDIA's GStreamer camera pipeline depend on supported camera formats. 
 + 
 +To start YOLOv5's detection, run the following command and provide the GStreamer camera pipeline as the source: 
 + 
 +<file shell> 
 +python3.8 detect.py --source "nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)2592, height=(int)1458, framerate=(fraction)30/1, format=(string)NV12 ! nvvidconv flip-method=0 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink" 
 +</file> 
 + 
 +===== Current data ===== 
 + 
 +==== On-board camera ==== 
 + 
 +<file shell> 
 +sudo apt install -y v4l-utils 
 +</file> 
 + 
 +<file shell> 
 +v4l2-ctl -d /dev/video0 --list-formats-ext 
 + 
 +ioctl: VIDIOC_ENUM_FMT 
 +        Index       : 0 
 +        Type        : Video Capture 
 +        Pixel Format: 'BG10' 
 +        Name        : 10-bit Bayer BGBG/GRGR 
 +                Size: Discrete 2592x1944 
 +                        Interval: Discrete 0.033s (30.000 fps) 
 +                Size: Discrete 2592x1458 
 +                        Interval: Discrete 0.033s (30.000 fps) 
 +                Size: Discrete 1280x720 
 +                        Interval: Discrete 0.008s (120.000 fps) 
 +</file> 
 + 
 +{{:projects:farmrobot:img_20210106_183252.jpg?400|}} 
 +{{:projects:farmrobot:img_20210106_183318.jpg?400|}} 
 +{{:projects:farmrobot:img_20210106_183359.jpg?400|}} 
 +{{:projects:farmrobot:img_20210106_183426.jpg?400|}} 
 +{{:projects:farmrobot:img_20210107_175211.jpg?400|}} 
 + 
 +==== Measurements ====
  
 YOLOv5 (street.mp4): 11/12 fps (~0.086s +- 0.005s per frame) YOLOv5 (street.mp4): 11/12 fps (~0.086s +- 0.005s per frame)
 +
 +{{:projects:farmrobot:img_20201228_205724.jpg?600|}}
  
 ===== Setup ===== ===== Setup =====
Line 55: Line 97:
  
 After the installation finished, disconnect the Jetson TX1 from the host machine. After the installation finished, disconnect the Jetson TX1 from the host machine.
 +
 +==== Mounting external storage to /home ====
 +
 +Mount the partition on the SD-card to ''/mnt'':
 +
 +<file shell>
 +sudo mount /dev/mmcblk2p1 /mnt
 +</file>
 +
 +Change into the ''/home'' directory and copy all contents to ''/mnt'':
 +
 +<file shell>
 +cd /home
 +cp -adpR * /mnt
 +</file>
 +
 +Unmount the partition from ''/mnt'':
 +
 +<file shell>
 +sudo umount /mnt
 +</file>
 +
 +Then open the disk utility and go to the mounting settings of the partition on the SD-card.
 +Set it to automatically mount on ''/home'' on boot, save and reboot the Jetson TX1.
  
 ==== Updating apt packages ==== ==== Updating apt packages ====
Line 123: Line 189:
  
 sudo swapon ~/swapfile sudo swapon ~/swapfile
 +</file>
 +
 +==== Building OpenCV from source (with GStreamer support) ====
 +
 +Because [[https://opencv.org/|OpenCV]] does not support NVIDIA's GStreamer software by default, it has to be built from source with GStreamer support enabled.
 +
 +<WRAP info>
 +[[https://developer.download.nvidia.com/embedded/L4T/r32_Release_v1.0/Docs/Accelerated_GStreamer_User_Guide.pdf?9N7jupgUlde8JwGYrJQO434MhxI7ZlJf8jfNYE-eI9uMBECrQldp3897ijsNYjnxBWWiY8OtUVfEKr4cLQNUyoevaUfjyXksRnT__8EmmhKVHWYbRK7-6NdQOQ8jJtev1-0IhZKyQ1rxjQh2_35qOofKmyWN8kH58nZHAQyVRax9kaD5tXY|Accelerated GStreamer User Guide]]
 +</WRAP>
 +
 +To get started, install the packages that OpenCV with GStreamer support depends on:
 +
 +<file shell>
 +sudo apt install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
 +</file>
 +
 +Then, install [[https://numpy.org/|NumPy]] as OpenCV also depends on it:
 +
 +<file shell>
 +python3.8 -m pip install --user numpy
 +</file>
 +
 +After all dependencies are installed, go ahead and clone the [[https://github.com/opencv/opencv|OpenCV GitHub repository]], change into its directory and checkout the latest version branch:
 +
 +<file shell>
 +git clone https://github.com/opencv/opencv.git
 +
 +cd opencv
 +
 +# General
 +git checkout <version>
 +
 +# OpenCV 4.5.0
 +git checkout 4.5.0
 +</file>
 +
 +Before you can start building OpenCV, create a ''/build`'' directory and change into it:
 +
 +<file shell>
 +mkdir build
 +
 +cd build
 +</file>
 +
 +Then, use ''cmake'' to prepare the build with the correct settings:
 +
 +<file shell>
 +cmake -D CMAKE_BUILD_TYPE=RELEASE \
 +-D INSTALL_PYTHON_EXAMPLES=ON \
 +-D INSTALL_C_EXAMPLES=OFF \
 +-D PYTHON_EXECUTABLE=$(which python3.8) \
 +-D BUILD_opencv_python2=OFF \
 +-D CMAKE_INSTALL_PREFIX=$(python3.8 -c “import sys; print(sys.prefix)”) \
 +-D PYTHON3_EXECUTABLE=$(which python3.8) \
 +-D PYTHON3_INCLUDE_DIR=$(python3.8 -c “from distutils.sysconfig import get_python_inc; print(get_python_inc())”) \
 +-D PYTHON3_PACKAGES_PATH=$(python3.8 -c “from site import getsitepackages; print(getsitepackages())”) \
 +-D WITH_GSTREAMER=ON \
 +-D BUILD_EXAMPLES=ON ..
 +</file>
 +
 +It is important to check the resulting output. Check if the output contains the following important bits:
 +
 +<file shell>
 +...
 +
 +GStreamer:         YES (<version>)
 +
 +...
 +
 +Python3:
 +  Interpreter:     <path>
 +  Libraries:       <path>
 +  numpy:           <path>
 +  install path:    <path>
 +
 +...
 +</file>
 +
 +If everything went well, you can go ahead and build it:
 +
 +<file shell>
 +sudo make -j$(nproc)
 +</file>
 +
 +When the build is finished, install it:
 +
 +<file shell>
 +sudo make install
 </file> </file>
  
Line 215: Line 369:
 </file> </file>
  
-Then change the directory into the local repository and clone the official [[https://github.com/ultralytics/yolov5|YOLOv5]] GitHub repository:+Then change the directory into the local repository and clone the official [[https://github.com/ultralytics/yolov5|YOLOv5 GitHub repository]]:
  
 <file shell> <file shell>
projects/farmrobot/nvidia-jetson-tx1.txt · Last modified: 2021/01/10 19:28 by jason