12345678910111213141516171819202122232425262728293031323334 |
- import ctypes
- import time
- import cv2 as cv
- import numpy as np
- mylib = ctypes.cdll.LoadLibrary("./libtestpythoncpp.so")
- char_arr100 = ctypes.c_char*10000000
- y = char_arr100()
- def showpic():
- str="hello"
- i = 0;
- mylib.registelisten("usbpic");
- nlenx = ctypes.c_int*2
- nlen = nlenx()
- while i< 10000:
- nRtn = mylib.GetData(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(nRtn)
- time.sleep(0.001);
- str="exit"
- print(str);
- if __name__ == "__main__":
- print ('This is main ,for show pic from c++')
- showpic()
|