设为首页收藏本站

Jetson开发者

搜索
查看: 418|回复: 1

【用户经验】打开Jetson TX1/TX2板载摄像头经验分享

[复制链接]

126

主题

162

帖子

1997

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1997
发表于 2018-6-3 17:21:33 | 显示全部楼层 |阅读模式
Jetson TX2


First of all, a original Jetpack environment (I use Jetpack 3.1 on TX2)
------------------------------------------------------------------------
step1:purge opencv 2.x & opencv4tegra
  1. sudo apt purge libopencv*
  2. sudo apt-get purge libopencv4tegra-dev libopencv4tegra
  3. sudo apt-get purge libopencv4tegra-repo
  4. sudo apt-get update
复制代码
step2: check remove
  1. apt-cache show libopencv4tegra
  2. pkg-config --modversion opencv
  3. pkg-config --cflags --libs opencv
  4. sudo apt search opencv | grep installed
复制代码

step3:install necessary items
  1. <p>sudo apt-get install libv4l-dev
  2. sudo apt-get install v4l2ucp
  3. sudo apt-get install v4l-utils
  4. sudo apt-get install \
  5.     libglew-dev \
  6.     libtiff5-dev \
  7.     zlib1g-dev \
  8.     libjpeg-dev \
  9.     libpng12-dev \
  10.     libjasper-dev \
  11.     libavcodec-dev \
  12.     libavformat-dev \
  13.     libavutil-dev \
  14.     libpostproc-dev \
  15.     libswscale-dev \
  16.     libeigen3-dev \
  17.     libtbb-dev \
  18.     libgtk2.0-dev \
  19.     pkg-config</p><p>
  20. </p>
复制代码



回复

使用道具 举报

126

主题

162

帖子

1997

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1997
 楼主| 发表于 2018-6-3 17:31:21 | 显示全部楼层
step4:download opencv sourse code (opencv 3.2.0) (https://opencv.org/releases.html).
step5:cmake opencv


  1. sudo apt-get install cmake
  2. cd /your opencv dir/
  3. cmake \
  4.     -DCMAKE_BUILD_TYPE= RELEASE\
  5.     -DCMAKE_INSTALL_PREFIX=/usr \
  6.     -DBUILD_PNG=OFF \
  7.     -DBUILD_TIFF=OFF \
  8.     -DBUILD_TBB=OFF \
  9.     -DBUILD_JPEG=OFF \
  10.     -DBUILD_JASPER=OFF \
  11.     -DBUILD_ZLIB=OFF \
  12.     -DBUILD_EXAMPLES=ON \
  13.     -DBUILD_opencv_java=OFF \
  14.     -DBUILD_opencv_python2=ON \
  15.     -DBUILD_opencv_python3=OFF \
  16.     -DENABLE_PRECOMPILED_HEADERS=OFF \
  17.     -DWITH_OPENCL=OFF \
  18.     -DWITH_OPENMP=OFF \
  19.     -DWITH_FFMPEG=ON \
  20.     -DWITH_GSTREAMER=ON \
  21.     -DWITH_GSTREAMER_0_10=OFF \
  22.     -DWITH_CUDA=ON \
  23.     -DWITH_GTK=ON \
  24.     -DWITH_VTK=OFF \
  25.     -DWITH_TBB=ON \
  26.     -DWITH_1394=OFF \
  27.     -DWITH_OPENEXR=OFF \
  28.     -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \
  29.     -DCUDA_ARCH_BIN=6.2 \
  30.     -DCUDA_ARCH_PTX="" \
  31.     -DINSTALL_C_EXAMPLES=ON \
  32.     -DINSTALL_TESTS=OFF \
  33.     -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \
  34.     ../opencv-3.2.0
复制代码

note:
-DCMAKE_BUILD_TYPE= RELEASE
-DWITH_GSTREAMER=ON
-DCUDA_ARCH_BIN=6.2

step6:make opencv
make -j6
step7:install opencv
  1. sudo make install
复制代码
------------------------------------------------------------------
It's my python code,you can try it.
  1. import numpy as np
  2. import cv2

  3. cap = cv2.VideoCapture("nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)I420, framerate=(fraction)24/1 ! nvvidconv flip-method=6 ! video/x-raw, format=(string)I420 ! videoconvert ! video/x-raw, format=(string)BGR ! appsink")
  4. #cap=cv2.VideoCapture(0)
  5. #cap=cv2.VideoCapture("/dev/video0")

  6. if not cap.isOpened() :
  7.         print("not capture")
  8.         exit()
  9. ret,frame = cap.read()
  10. while ret :
  11.         cv2.imshow('frame',frame)
  12.         ret,frame = cap.read()
  13.         if(cv2.waitKey(1) & 0xFF == ord('q')):
  14.                 break;

  15. cap.release()
  16. cv2.destroyAllWindows()
复制代码
Welcome advice.






回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

快速回复 返回顶部 返回列表