You are on page 1of 2

import threading

import numpy as np

import cv2

from yolo_opencv import*

def task1():

i = 0

cap = cv2.VideoCapture(1)

while(True):
# Capture frame-by-frame
ret, frame = cap.read()

# Our operations on the frame come here


gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

# Display the resulting frame


cv2.imshow('frame',frame)

i=i+1

# print(i)

if(i == 5):

cv2.imwrite("input.jpg", gray)
i=0

if cv2.waitKey(1) & 0xFF == ord('q'):


break

# When everything done, release the capture


cap.release()
cv2.destroyAllWindows()

###################################################################################
##########

def task2():

while(True):
try:
image_read_recoginition()
except:
print("camera opening")
###############################################################################

if __name__ == "__main__":

#******************************************************#
try:

t1 = threading.Thread(target=task1)

except:

t1 = threading.Thread(target=task1)
time.sleep(2)

#******************************************************#
try:

t2 = threading.Thread(target=task2)

except:

t2 = threading.Thread(target=task2)
time.sleep(2)

t1.start()

t2.start()

t1.join()

t2.join()

#both threads completely executed


print("Done!")

You might also like