ThreadedServer.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:Camera2TCP 作者: kevinkit 项目源码 文件源码
def __init__(self, host, port,camtype="webcam",ID=0,image_name='lena.png',change=True,Debug=True):
        self.host = host
        self.port = port
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.sock.bind((self.host, self.port))
        self.comThreads = []
        self.alive = True;
        self.RGB0 = [];
        self.Depth = [];
        self.Body = [];
        self.camtype = camtype;
        self.ret = False;
        self.log = "test"
        self.HDRGB = [];
        self.imageName = image_name;
        self.change = change;
        self.sys_random = random.SystemRandom();
        #Assuming 8bit pic
        self.cnt = 0;
        self.trip = 0;
        self.Debug = Debug

        self.send_counter = 0;
        self.rgb_cnt = 0;
        #Locks
        self.Lock  = threading.Lock()

        if self.Debug:
            self.img = cv2.imread(self.imageName); #This one will be altered!
            self.orig_img = cv2.imread(self.imageName); #This one will be the same
            self.ImageT = threading.Thread(target=self.imagechanger)
            self.ImageT.start()
            self.height,self.width,self.channel = self.img.shape;
            self.x_pos = random.randint(10,self.width);
            self.y_pos = random.randint(10,self.height);
            if self.ImageT.isAlive():
                self.log = "height: " + str(self.height)
        if Kinect:
            pygame.init()


            #Used to manage how fast the screen updates
            self._clock = pygame.time.Clock()
            self._done = False;
            self._infoObject = pygame.display.Info()
            self._screen = pygame.display.set_mode((self._infoObject.current_w >> 1, self._infoObject.current_h >> 1),
                                       pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.RESIZABLE, 32)



            # Kinect runtime object, we want only color and body frames
            self._kinect = PyKinectRuntime.PyKinectRuntime(PyKinectV2.FrameSourceTypes_Color | PyKinectV2.FrameSourceTypes_Body | PyKinectV2.FrameSourceTypes_Depth | PyKinectV2.FrameSourceTypes_Infrared)
            # back buffer surface for getting Kinect color frames, 32bit color, width and height equal to the Kinect color frame size
            self._frame_surface = pygame.Surface((self._kinect.color_frame_desc.Width, self._kinect.color_frame_desc.Height), 0, 32)
            # here we will store skeleton data
            self._bodies = None

        if camtype == "webcam":

            self.cap = cv2.VideoCapture(ID)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号