I am running a ROS container on a jetson nano. I took the container from here:
I’m trying to use NVIDIA VPI inside the container, and I have two problem I was hoping to get some help with:
-
I’m getting a
No module named 'vpi'
when trying to import it in Python. I presume it’s because it’s not installed inside the container, so is there a way to import VPI into the container from outside? I tried the run command from here:
VPI does not work inside of docker container - #5 by AastaLLL
but it didn’t work. -
Not sure this is the place to ask this, but if for example I have this (part of) code in C++:
int main(void){
cv::Mat image;
vector<Point2f> points;
VideoCapture cap("video.avi");
cap >> frame; //reading frame from video, size = 1936x1216
cvtColor(cap, image, cv::COLOR_RGB2GRAY); // to grayscale
cv::resize(image, image, m_ImageSizeFinal); //resize to 968x608
goodFeaturesToTrackMask = createDetectionMaskImage(); //Create mask of type CV_8UC1
cv::goodFeaturesToTrack(image, points, 500, 0.001, 15, goodFeaturesToTrackMask, 3, true);
}
What would be the correct way to convert it to VPI? This is my attempt:
import vpi
import cv2
import numpy as np
import csv
cap = cv2.VideoCapture('2021_01_25__14_05_01.avi')
backend = vpi.Backend.CUDA
image1, image2 = None, None
with backend:
writer = csv.writer(f)
start = time.time():
while cap.isOpened():
now = time.time()
ret, frame = cap.read()
if ret == True:
image = vpi.asimage(frame, vpi.Format.BGR8).convert(vpi.Format.U8)
image = image.rescale((968, 608), interp=vpi.Interp.LINEAR, border=vpi.Border.ZERO)
corners, scores = image.harriscorners(sensitivity=0.001)
But it doesn’t detect any points. Also the parameters aren’t the same between the functions (no parameter for mask for example), so I’m not sure how to go about this. What am I doing wrong?
Thank you very much for the help.