Jetson Nano Opencv gStreamer video distortion when show in portrait

Hi Guy,

I’m doing face recognition using opencv with jetson nano. Camare is pi camera and use gstreamer to capture video.

Everything ok when I display video in landscape, but video become distortion when I rotate video to display in portrait. Below is my code, any suggest? Thank you

def get_jetson_gstreamer_source(capture_width=1280, capture_height=720, display_width=480, display_height=640, framerate=30, flip_method=2):

 return (
         f'nvarguscamerasrc ! video/x-raw(memory:NVMM), ' +
         f'width=(int){capture_width}, height=(int){capture_height}, ' +
         f'format=(string)NV12, framerate=(fraction){framerate}/1 ! ' +
         f'nvvidconv flip-method={flip_method} ! ' +
         f'video/x-raw, width=(int){display_width}, height=(int){display_height}, format=(string)BGRx ! ' +
         'videoconvert ! video/x-raw, format=(string)BGR ! appsink'
         )

cap = cv2.VideoCapture(get_jetson_gstreamer_source(), cv2.CAP_GSTREAMER)

Hi,
Please check if the issue is seen in running the sample:

import sys
import cv2

def read_cam():
    cap = cv2.VideoCapture("nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720,format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv flip-method=1 ! video/x-raw, format=(string)BGRx ! videoconvert !  appsink")
    if cap.isOpened():
        cv2.namedWindow("demo", cv2.WINDOW_AUTOSIZE)
        while True:
            ret_val, img = cap.read();
            cv2.imshow('demo',img)
            cv2.waitKey(10)
    else:
     print "camera open failed"

    cv2.destroyAllWindows()


if __name__ == '__main__':
    read_cam()

For 90-degree rotation, it should be flip-method=1.

Hi,

Thanks for reply and sorry for late response. I set flip method to 2 is because the camera orientation. Now everything ok when I rotate the camera and use flip method to 1.

Thank you.