Jetson Nano and OpenCV: Simple Thresholding

So in this project I started out with simple threshold!


Things Required:

  1. Jetson Nano
  2. Keyboard
  3. Mouse
  4. HDMI Screen
  5. Raspberry Pi Camera
  6. External Power Supply

Reference Material:

  1. What is simple thresholding?

Thresholding is when you classify the pixel values in an image. An important thing to remember here is that OpenCV thresholding is done on grayscale images, which are image which has pixel values ranging from 0–255. When you threshold an image you classify these pixels into either above the threshold or below the threshold. If the pixel value is smaller than the threshold, it is set to 0, otherwise, it is set to a maximum value (generally 255).

For example, this is a grayscale image

  1. You can check out this video for the project: (LINK)


Note that code below is in python

View on/Download from Github: (LINK)

import cv2
#reading the image and storing it in cvLogo
cvLogo= cv2.imread('/home/aarushi/Desktop/pyPro/cv.jpg')
#resizing the image
cvLogo= cv2.resize(cvLogo,(320,240))
cv2.imshow('Original', cvLogo)
cv2.moveWindow('Original', 300, 290)

#for thresholding we need to convert the image to grayscale
cvLogoGray= cv2.cvtColor(cvLogo, cv2.COLOR_BGR2GRAY)
#display image
cv2.imshow('GrayLogo', cvLogoGray)
cv2.moveWindow('GrayLogo', 0, 300)
#for .threshold first argument is the source image
#second is the threshold  is the thrshold limit
# thrid is the maximum value assigned to the pixels exceeding threshold value  
_,BGMask=cv2.threshold(cvLogoGray, 180, 255, cv2.THRESH_BINARY)
cv2.imshow('BGMask', BGMask)
cv2.moveWindow('BGMask', 340, 0)
camSet='nvarguscamerasrc !  video/x-raw(memory:NVMM), width=3264, height=2464, format=NV12, framerate=21/1 ! nvvidconv flip-method='+str(flip)+' ! video/x-raw, width='+str(dispW)+', height='+str(dispH)+', format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink'
while True:
    ret, frame=
    cv2.imshow('nanoCam', frame)
    if cv2.waitKey(1) == ord('q'):

Stay Tuned for upcoming posts on Jetson Nano and AI Projects! Want to be the first to know when a new and amazing post comes up?? Then feel free to subscribe!

Happy Learning!!

This image has an empty alt attribute; its file name is stay-tuned.gif

Leave a Reply


Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close