Jetson Nano and OpenCV: Swapping color channels of a live video

So this video was a play around with opencv. An image has 3 channels: blue, green an red. I’ve swapped the blue and red color channels and found some interesting stuff!


Things Required:

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

Reference Material:

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


View on/Download from Github: (LINK)

import cv2
import numpy as np
dispW= 320
dispH= 240
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'
cam= cv2.VideoCapture(camSet)
while True:
    ret, frame=
    #gray= cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    b,g,r= cv2.split(frame)
    blank= np.zeros([240,320,1], np.uint8)
    blue= cv2.merge((b, blank, blank))
    green= cv2.merge((blank, g, blank))
    red= cv2.merge((blank, blank, r))
    r[:]= r[:]*0.1
    merge= cv2.merge((r,g,b))
    cv2.imshow('merge', merge)
    cv2.moveWindow('merge', 800,0)
    cv2.imshow('Blue', blue)
    cv2.moveWindow('Blue', 0, 300)
    cv2.imshow('Green', green)
    cv2.moveWindow('Green', 400, 300)
    cv2.imshow('Red', red)
    cv2.moveWindow('Red', 400,0)
    #cv2.imshow('Gray', gray)
    #cv2.moveWindow('Gray', 400, 0)
    cv2.imshow('nanoCam', frame)
    cv2.moveWindow('nanoCam', 0,0)
    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