Created
March 25, 2017 03:53
-
-
Save harveyslash/c8000d431665a0d8bb3ccef3a0c2ba4d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import print_function | |
| import cv2 | |
| import json | |
| import numpy as np | |
| import socket | |
| import sys | |
| import pickle | |
| import os | |
| from time import sleep | |
| import struct ### new code | |
| cap=cv2.VideoCapture(0) | |
| cap.set(3,224) | |
| cap.set(4,224) | |
| clientsocket=socket.socket(socket.AF_INET,socket.SOCK_STREAM) | |
| clientsocket.connect(('ai.student.rit.edu',8083)) | |
| while True: | |
| ret,frame=cap.read() | |
| data = pickle.dumps(frame) ### new code | |
| clientsocket.sendall(struct.pack("Q", len(data))+data) ### new code | |
| # sleep(1) | |
| data = clientsocket.recv(4096) | |
| # print(data) | |
| # data= json.loads(data) | |
| os.system('clear') | |
| # regResult = data['None'][-1] | |
| # regResult = [int(i) for i in regResult] | |
| print (data) | |
| # # continue; | |
| # cv2.rectangle(frame,(regResult[0],regResult[1]),(regResult[2],regResult[3]),(0,255,0),3) | |
| points = json.loads(data)['points'] | |
| #print(x['points']) | |
| cv2.circle(frame,(points[0],points[1]),25,(0,0,255),-1) | |
| cv2.imshow('frame',frame) | |
| if cv2.waitKey(1) & 0xFF == ord('s'): | |
| exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment