def connectToOtherClient(self, ip_addr="127.0.0.1"): # global win, video_win, panel, root, videofeed client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # the other guy/gal client_socket.connect((ip_addr, 6000)) master.connWindow.withdraw() # Hide the Connect To window tkMessageBox.showinfo("Info", "Connection successful!") vsock = videosocket.videosocket( client_socket) # establish a video connection try: master.vidWindow.deiconify() while (True): frame = master.videofeed.get_frame() vsock.vsend(frame) frame = vsock.vreceive() if (frame == None): raise Exception # Timeout image = ImageTk.PhotoImage( Image.fromarray(master.videofeed.set_frame(frame))) if master.vidPanel is None: # first frame master.vidPanel = tk.Label(master.vidWindow, image=image) master.vidPanel.image = image master.vidPanel.pack(side="left", padx=10, pady=10) master.vidWindow.update() else: master.vidPanel.configure(image=image) master.vidPanel.image = image master.vidWindow.update() except Exception as e: print(e) print('Some issue!') master.onClose()
def __init__(self): self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #self.client_socket.connect(("10.3.42.55", 6000)) #self.client_socket.connect(("127.0.0.1", 6000)) self.client_socket.connect((socket.gethostname(), 1243)) self.vsock = videosocket.videosocket(self.client_socket) self.videofeed = VideoFeed(1, "client", 1)
def connect(self): # global haveConnection, U_client_socket, U_address client_socket, address = master.U_client_socket, master.U_address # retrieve info from global variables (changes made by Daemon) vsock = videosocket.videosocket( client_socket) # establish a video connection master.connWindow.withdraw() # Hide the Connect To window try: master.vidWindow.deiconify() while (True): if (master.acceptFlag == 2): frame = None else: frame = vsock.vreceive() if (frame == None): raise Exception image = ImageTk.PhotoImage( Image.fromarray(master.videofeed.set_frame(frame))) if master.vidPanel is None: master.vidPanel = tk.Label(master.vidWindow, image=image) master.vidPanel.image = image master.vidPanel.pack(side="left", padx=10, pady=10) master.vidWindow.update() else: master.vidPanel.configure(image=image) master.vidPanel.image = image master.vidWindow.update() frame = master.videofeed.get_frame() vsock.vsend(frame) except Exception as e: print(e) print('Some issue!') master.onClose()
def connect(self): global haveConnection, U_client_socket, U_address, root, video_win, panel, videofeed client_socket, address = U_client_socket, U_address # retrieve info from global variables (changes made by Daemon) vsock = videosocket.videosocket(client_socket) # establish a video connection tkMessageBox.showerror("Info", "Press \'q\' to quit!") try: video_win.deiconify() while (True): frame = vsock.vreceive() if (frame == None): print ('ppppp') raise Exception image = ImageTk.PhotoImage(Image.fromarray(videofeed.set_frame(frame))) if panel is None: panel = tk.Label(video_win,image=image) panel.image = image panel.pack(side="left", padx=10, pady=10) video_win.update() else: panel.configure(image=image) panel.image = image; video_win.update() frame = videofeed.get_frame() vsock.vsend(frame) except Exception as e: print (e) print ('Some issue!') onClose() win.deiconify() panel = None
def connect(self, ip_addr = "127.0.0.1"): global win, video_win, panel, root, videofeed client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: client_socket.connect((ip_addr, 6000)) except: return ('Unavailable') # if Client can't get a connection to that IP win.withdraw() # Hide the Connect To window tkMessageBox.showerror("Info", "Press \'q\' to quit!") vsock = videosocket.videosocket(client_socket) # establish a video connection try: video_win.deiconify() while (True): frame = videofeed.get_frame() vsock.vsend(frame) frame = vsock.vreceive() if (frame == None): raise Exception image = ImageTk.PhotoImage(Image.fromarray(videofeed.set_frame(frame))) if panel is None: panel = tk.Label(video_win,image=image) panel.image = image panel.pack(side="left", padx=10, pady=10); video_win.update() else: panel.configure(image=image) panel.image = image; video_win.update() except Exception as e: print (e) print ('Some issue!') onClose() win.deiconify() panel = None
def connect(self, name, ip_addr = "127.0.0.1"): global win dummmySocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: dummySocket.connect((ip_addr, 6001)) except: return ('Unavailable') # if Client can't get a connection to that IP # Call function to obtain IP from dummy server targetIP = sendConnReq(dummySocket, myName='CLIENTA' ,target=name) client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: client_socket.connect((targetIP[0], int(targetIP[1]))) except: return ('Unavailable') # if Client can't get a connection to that IP win.withdraw() # Hide the Connect To window tkMessageBox.showerror("Info", "Press \'q\' to quit!") vsock = videosocket.videosocket(client_socket) # establish a video connection videofeed = VideoFeed(1,"Client",1) try: while (True): key=cv2.waitKey(1) & 0xFF if key == ord('q'): win.deiconify() break frame = videofeed.get_frame() vsock.vsend(frame) frame = vsock.vreceive() videofeed.set_frame(frame) except: print ('Expcetion occurred') cv2.destroyAllWindows()
def __init__(self, ip_addr="172.20.10.10"): self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.client_socket.connect((ip_addr, 6000)) self.vsock = videosocket.videosocket(self.client_socket) self.videofeed = VideoFeed(1, "client", 1) self.data = StringIO.StringIO()
def start(self): while 1: client_socket, address = self.server_socket.accept() print "I got a connection from ", address vsock = videosocket.videosocket(client_socket) while True: frame=vsock.vreceive() self.videofeed.set_frame(frame) frame=self.videofeed.get_frame() vsock.vsend(frame)
def start(self): while 1: client_socket, address = self.server_socket.accept() print "I got a connection from " + address vsock = videosocket.videosocket(client_socket) while True: frame = vsock.vreceive() self.videofeed.set_frame(frame) frame = self.videofeed.get_frame() vsock.vsend(frame)
def connect(self, ip_addr="127.0.0.1"): client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: client_socket.connect((ip_addr, 6000)) except: return ('Unavailable' ) # if Client can't get a connection to that IP win.withdraw() # Hide the Connect To window self.vsock = videosocket.videosocket( client_socket) # establish a video connection self.videofeed = VideoFeed(1, "A2", 1)
def start(self): while 1: client_socket, address = self.server_socket.accept() print "I got a connection from ", address vsock = videosocket.videosocket(client_socket) i = 0 while True: frame_bytes = vsock.vreceive() #print(frame_bytes) pil_bytes = io.BytesIO(frame_bytes) pil_image = Image.open(pil_bytes) cv_image = cv2.cvtColor(numpy.array(pil_image), cv2.COLOR_RGB2BGR) cv2.imshow('preview', cv_image) if cv2.waitKey(1) & 0xFF == ord('q'): break
class Client: def __init__(self): self.client_socket = socket.socket( socket.AF_INET, socket.SOCK_STREAM) #create socket object try: self.client_socket.connect( ("127.0.0.1", 5000)) #local machine address # self.client_socket.connect(("192.168.43.41", 5000))#chris's address address except socket.error, exc: #catch socket exception print("Caught exception socket.error: %s" % exc) sys.exit() print("Connected to server\n") self.vsock = videosocket.videosocket( self.client_socket) #create videosocket object self.videofeed = VideoFeed("client", 1) #create videofeed object
def connect(self): global haveConnection, U_client_socket, U_address client_socket, address = U_client_socket, U_address # retrieve info from global variables (changes made by Daemon) vsock = videosocket.videosocket(client_socket) # establish a video connection videofeed = VideoFeed(1,"Server",1) tkMessageBox.showerror("Info", "Press \'q\' to quit!") try: while (True): key=cv2.waitKey(1) & 0xFF if key == ord('q'): win.deiconify() break frame = vsock.vreceive() videofeed.set_frame(frame) frame = videofeed.get_frame() vsock.vsend(frame) except: print ('Exception occurred') cv2.destroyAllWindows()
def __init__(self): self.server_socket = socket.socket( socket.AF_INET, socket.SOCK_STREAM) #create socket object port = 5000 self.server_socket.bind(("", port)) #bind socket to port self.server_socket.listen(0) #enable server to accept connections self.videofeed = VideoFeed("server", 0) #create videofeed object print("Waiting for client on port: %d", port) #display port that the socket is listening on client_socket, address = self.server_socket.accept() print("I got a connection from ", address) #display ip address of connected client self.vsock = videosocket.videosocket( client_socket) #create videosocket object self.p1 = threading.Thread(target=self.display_video) self.p2 = threading.Thread(target=self.vidSend)
def connect(self): tkMessageBox.showinfo("Info", "Connection accepted!") # global haveConnection, U_client_socket, U_address client_socket, address = master.U_client_socket, master.U_address # retrieve info from global variables (changes made by Daemon) vsock = videosocket.videosocket( client_socket) # establish a video connection master.connWindow.withdraw() # Hide the Connect To window try: master.vidWindow.deiconify() while (True): frame = vsock.vreceive() if (frame == None): raise Exception frame = master.videofeed.set_frame(frame) # Specify choice for Filter here if master.videoMode != 0: frame = get_Frame(frame, master.videoMode) image = ImageTk.PhotoImage(Image.fromarray(frame)) if master.vidPanel is None: master.vidPanel = tk.Label(master.vidWindow, image=image) master.vidPanel.image = image master.vidPanel.pack(side="left", padx=10, pady=10) master.vidWindow.update() else: master.vidPanel.configure(image=image) master.vidPanel.image = image master.vidWindow.update() frame = master.videofeed.get_frame() vsock.vsend(frame) except Exception as e: pass # print (e) # print ('Some issue!') master.onClose() master.connWindow.deiconify() self.connectExitTrigger()
def __init__(self, ip_addr, port): self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.client_socket.connect((ip_addr, port)) self.vsock = videosocket.videosocket(self.client_socket) self.videofeed = VideoFeed(1, "client", 1)
if not hahaha.empty(): hahaha.get() qflag = True wflag = True print("finish") #print(1111) def myreceive(self, vsock): while True: #print(2222) frame = vsock.vreceive() self.videofeed.set_frame(frame, startflag, out) if __name__ == "__main__": server = Server() client_socket, address = server.server_socket.accept() print("I got a connection from ", address) vsock = videosocket.videosocket(client_socket) t1 = threading.Thread(target=server.mysend, args=[vsock]) t2 = threading.Thread(target=server.myreceive, args=[vsock]) t3 = threading.Thread(target=server.keyBoard) t2.start() t1.start() #t3.start() #t3.join() t2.join() t1.join()
def __init__(self): self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.client_socket.connect(("127.0.0.1", 6000)) self.vsock = videosocket.videosocket(self.client_socket) self.videofeed = VideoFeed(1, "client", 1) self.data = StringIO.StringIO()
def __init__(self): self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.client_socket.connect(("10.3.42.55", 6000)) self.vsock = videosocket.videosocket(self.client_socket) self.videofeed = VideoFeed(1, "client", 1) self.data = StringIO.StringIO()
def connect(self): client_socket, address = U_client_socket, U_address # retrieve info from global variables (changes made by Daemon) self.vsock = videosocket.videosocket( client_socket) # establish a video self.videofeed = VideoFeed(1, "A1", 1) self.show()