├── Install-MediaPipe ├── How to Install MediaPipe on jetson-nano 2022.txt ├── Setup.txt ├── mediapipe-0.8.5_cuda102-cp36-none-linux_aarch64.whl └── numpy-1.19.4-cp36-none-manylinux2014_aarch64.whl ├── Wildlife.mp4 ├── classificationInLiveCamera.py ├── classificationInVideo.py ├── dog-demo.jpg ├── imageClassification.py └── install-jetson-inference └── Tutorial install /Install-MediaPipe/How to Install MediaPipe on jetson-nano 2022.txt: -------------------------------------------------------------------------------- 1 | #How to install Media pipe on jetson nano 2022 2 | # The starting point is a flashed new SD card with Jetpack 4.6 3 | 4 | 5 | # Increase swap for more swap ram 6 | # =============================== 7 | git clone https://github.com/JetsonHacksNano/installSwapfile.git 8 | cd installSwapfile 9 | 10 | ./installSwapfile.sh 11 | 12 | 13 | # setup - pre install include Python and pip 14 | # =================== 15 | 16 | sudo apt update 17 | sudo apt-get update 18 | sudo apt-get install python3-pip 19 | sudo pip3 install -U pip testresources setuptools==49.6.0 20 | 21 | # python libraries for Tensorflow 22 | # ================================ 23 | 24 | sudo apt-get install libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran 25 | 26 | 27 | # Install more Python libraries 28 | # ================================= 29 | 30 | sudo pip3 install -U --no-deps numpy==1.19.4 future==0.18.2 mock==3.0.5 keras_preprocessing==1.1.2 keras_applications==1.0.8 gast==0.4.0 protobuf pybind11 cython pkgconfig 31 | 32 | # part of Numpy -> store large amount of data in binary format 33 | sudo env H5PY_SETUP_REQUIRES=0 pip3 install -U h5py==3.1.0 34 | 35 | sudo apt-get install python3-opencv 36 | 37 | #install media pipe from the source code 38 | #======================================= 39 | 40 | 41 | git clone https://github.com/google/mediapipe.git 42 | cd mediapipe 43 | 44 | # install more libraries for the media pipe setup 45 | # =============================================== 46 | sudo apt-get install -y libopencv-core-dev libopencv-highgui-dev libopencv-calib3d-dev libopencv-features2d-dev libopencv-imgproc-dev libopencv-video-dev 47 | 48 | # set permissions for the setup script file 49 | sudo chmod 744 setup_opencv.sh 50 | 51 | 52 | # run installation from source code : about 30 minutes 53 | # ==================================================== 54 | ./setup_opencv.sh 55 | 56 | 57 | 58 | # last step 59 | sudo pip3 install opencv_contrib_python 60 | git clone https://github.com/PINTO0309/mediapipe-bin 61 | cd mediapipe-bin 62 | 63 | sudo apt install curl 64 | 65 | ./v0.8.5/numpy119x/mediapipe-0.8.5_cuda102-cp36-cp36m-linux_aarch64_numpy119x_jetsonnano_L4T32.5.1_download.sh 66 | 67 | sudo pip3 install numpy-1.19.4-cp36-none-manylinux2014_aarch64.whl 68 | sudo pip3 install mediapipe-0.8.5_cuda102-cp36-none-linux_aarch64.whl 69 | pip3 install dataclasses 70 | 71 | 72 | #download examples from here : https://github.com/feitgemel/BodyPos/tree/master/MediaPipe/Demo 73 | 74 | git clone https://github.com/feitgemel/BodyPos.git 75 | cd BodyPos 76 | cd MediaPipe 77 | cd Demo 78 | python3 MediaPipe-Holistic.py 79 | 80 | 81 | -------------------------------------------------------------------------------- /Install-MediaPipe/Setup.txt: -------------------------------------------------------------------------------- 1 | pip install setup 2 | wget https://bootstrap.pypa.io/get-pip.py 3 | sudo python3 get-pip.py 4 | rm get-pip.py 5 | 6 | 7 | sudo pip3 install pip --upgrade 8 | sudo pip3 install opencv_contrib_python 9 | 10 | git clone https://github.com/PINTO0309/mediapipe-bin 11 | cd mediapipe-bin 12 | 13 | ./v0.8.5/numpy119x/mediapipe-0.8.5_cuda102-cp36-cp36m-linux_aarch64_numpy119x_jetsonnano_L4T32.5.1_download.sh 14 | 15 | sudo pip3 install \ 16 | numpy-1.19.4-cp36-none-manylinux2014_aarch64.whl \ 17 | mediapipe-0.8.5_cuda102-cp36-none-linux_aarch64.whl 18 | 19 | -------------------------------------------------------------------------------- /Install-MediaPipe/mediapipe-0.8.5_cuda102-cp36-none-linux_aarch64.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/feitgemel/Jetson-Nano-Python/5b5da5082e0067b33eee0e8c8bce94658d2fead4/Install-MediaPipe/mediapipe-0.8.5_cuda102-cp36-none-linux_aarch64.whl -------------------------------------------------------------------------------- /Install-MediaPipe/numpy-1.19.4-cp36-none-manylinux2014_aarch64.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/feitgemel/Jetson-Nano-Python/5b5da5082e0067b33eee0e8c8bce94658d2fead4/Install-MediaPipe/numpy-1.19.4-cp36-none-manylinux2014_aarch64.whl -------------------------------------------------------------------------------- /Wildlife.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/feitgemel/Jetson-Nano-Python/5b5da5082e0067b33eee0e8c8bce94658d2fead4/Wildlife.mp4 -------------------------------------------------------------------------------- /classificationInLiveCamera.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import jetson.inference 3 | import jetson.utils 4 | 5 | 6 | cap = cv2.VideoCapture(0) 7 | cap.set(3,1280) 8 | cap.set(4,720) 9 | 10 | net = jetson.inference.imageNet("googlenet") 11 | 12 | while cap.isOpened(): 13 | 14 | re, img = cap.read() 15 | 16 | # convert the image to Cuda format 17 | frame_rgba = cv2.cvtColor(img, cv2.COLOR_BGR2RGBA) 18 | cude_frame = jetson.utils.cudaFromNumpy(frame_rgba) 19 | 20 | # classify the image 21 | class_id , confidence = net.Classify(cude_frame) 22 | 23 | # find the description of the object 24 | class_desc = net.GetClassDesc(class_id) 25 | 26 | if confidence > 0.4 : 27 | cv2.putText(img , class_desc , (30,80), cv2.FONT_HERSHEY_COMPLEX, 1, (255,0,0),3) 28 | 29 | 30 | cv2.imshow('img',img) 31 | cv2.moveWindow('img',0,0) 32 | 33 | if cv2.waitKey(10) & 0xFF == ord('q'): 34 | break 35 | 36 | 37 | cap.release() 38 | cv2.destroyAllWindows() 39 | 40 | -------------------------------------------------------------------------------- /classificationInVideo.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import jetson.inference 3 | import jetson.utils 4 | 5 | # load the video file 6 | 7 | cap = cv2.VideoCapture('/home/feitdemo/github/Jetson-Nano-Python/Wildlife.mp4') 8 | cap.set(3,1280) 9 | cap.set(4,720) 10 | 11 | 12 | #load the network 13 | net = jetson.inference.imageNet("googlenet") 14 | 15 | while cap.isOpened(): 16 | 17 | re, img = cap.read() 18 | 19 | # convert the image to Cuda 20 | frame_rgba = cv2.cvtColor(img,cv2.COLOR_BGR2RGBA) 21 | cuda_frame = jetson.utils.cudaFromNumpy(frame_rgba) 22 | 23 | # classify the image 24 | class_id , confidence = net.Classify(cuda_frame) 25 | 26 | # find the object description 27 | class_desc = net.GetClassDesc(class_id) 28 | 29 | #print(class_desc) 30 | 31 | # more the 40% confidence , than put the text on the video file 32 | if confidence > 0.4 : 33 | cv2.putText(img, class_desc, (30,80), cv2.FONT_HERSHEY_COMPLEX, 1, (255,0,0),3 ) 34 | 35 | 36 | 37 | cv2.imshow('img',img) 38 | cv2.moveWindow('img',0,0) 39 | 40 | if cv2.waitKey(10) & 0xFF == ord('q'): 41 | break 42 | 43 | cap.release() 44 | cv2.destroyAllWindows() -------------------------------------------------------------------------------- /dog-demo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/feitgemel/Jetson-Nano-Python/5b5da5082e0067b33eee0e8c8bce94658d2fead4/dog-demo.jpg -------------------------------------------------------------------------------- /imageClassification.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import jetson.inference 3 | import jetson.utils 4 | 5 | # Use Python 3.6 6 | 7 | 8 | #loading the image 9 | img = cv2.imread('/home/feitdemo/github/Jetson-Nano-Python/dog-demo.jpg') 10 | 11 | # convert the image format to a Cuda image 12 | frame_rgba = cv2.cvtColor(img,cv2.COLOR_BGR2RGBA) 13 | cude_frame = jetson.utils.cudaFromNumpy(frame_rgba) 14 | 15 | # load the recognition network 16 | net = jetson.inference.imageNet("googlenet") 17 | 18 | # classify the image 19 | 20 | class_id , confidence = net.Classify(cude_frame) 21 | 22 | # find the description of the object 23 | class_desc = net.GetClassDesc(class_id) 24 | 25 | #print(class_desc) 26 | 27 | #show the image with the class description 28 | 29 | cv2.putText(img,class_desc,(30,80), cv2.FONT_HERSHEY_COMPLEX, 1, (255,0,0),4 ) 30 | 31 | cv2.imshow('img',img) 32 | cv2.moveWindow('img',0,0) # position of the windows and the left corner 33 | cv2.waitKey() 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /install-jetson-inference/Tutorial install: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------------------- 2 | sudo apt-get update 3 | 4 | sudo apt-get install git cmake 5 | -------------------------------------------------------------------------------------------- 6 | git clone https://github.com/dusty-nv/jetson-inference 7 | cd jetson-inference 8 | git submodule update --init 9 | -------------------------------------------------------------------------------------------- 10 | sudo apt-get install libpython3-dev python3-numpy 11 | -------------------------------------------------------------------------------------------- 12 | cd jetson-inference # omit if working directory is already jetson-inference/ from above 13 | mkdir build 14 | cd build 15 | cmake ../ 16 | -------------------------------------------------------------------------------------------- 17 | cd jetson-inference/build # omit if working directory is already build/ from above 18 | make 19 | sudo make install 20 | sudo ldconfig 21 | --------------------------------------------------------------------------------------------- 22 | 23 | # Install vscode on Jetson Nano 24 | https://github.com/JetsonHacksNano/installVSCode 25 | 26 | 27 | --------------------------------------------------------------------------------