1234567891011121314151617181920212223242526272829303132333435363738 |
- import ctypes
- import time
- import cv2 as cv
- import numpy as np
- mylib = ctypes.cdll.LoadLibrary("./libusb_cam_python.so")
- char_arr100 = ctypes.c_char*10000000
- y = char_arr100()
- def showpic():
- str="hello"
- i = 0;
- nlenx = ctypes.c_int*2
- nlen = nlenx()
- mylib.StartCam("/dev/video0",1920,1080,30);
- while i< 10000:
- nRtn = mylib.GetJPEGDataWithWait("/dev/video0",y,nlen,100);
- # nRtn = mylib.GetJPEGData("/dev/video0",y,nlen);
- if(nRtn>0):
- xdata = np.frombuffer(y,count = nlen[0])
- matx = cv.imdecode(xdata, cv.IMREAD_COLOR );
- cv.imshow("showing",matx)
- cv.waitKey(1)
- print(time.time(), nRtn)
- else :
- print("no data");
- time.sleep(0.001);
-
- str="exit"
- print(str);
- if __name__ == "__main__":
- print ('This is main ,for show pic from c++')
- showpic()
|