简体   繁体   中英

Retrieve frame from cv2.VideoCapture in C# variable type

I'm trying to get frames from a IP camera using cv2.VideoCapture function of Python OpenCV. I'm using PythonNet to retrieve this frames to a C# Console Application. But I can't retrieve the boolean and the image that return cv2.VideoCapture in C# variables. Anyone knows how do it?

dynamic cap = cv2.VideoCapture("camerastream");
dynamic frame1 = cap.read;

So, I already know that frame1 have the output of cv2.VideoCapture , that is a boolean and a numpy array. And that frame1 is a Python object type. But I don't know how to retrieve the boolean and the array from frame1 .

Solved! This is working.

bool retrieved;
dynamic image = np.ndarray;
dynamic cap = cv2.VideoCapture("camerastream");
dynamic frame1 = cap.read();
retrieved = frame1[0];
image = frame1[1];

I had forgotten the () in the function ... :-D

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM