20065320rp commited on
Commit
7ae5ffc
1 Parent(s): 2ede220

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -31,37 +31,39 @@ def take_photo(filename='photo.jpg', quality=0.8):
31
  # current device, assign a value in cam_port
32
  # variable according to that
33
  cam_port = 0
34
- cam = VideoCapture(cam_port)
35
 
36
  # reading the input using the camera
37
  result, filename = cam.read()
38
 
39
  # If image will detected without any error,
40
  # show result
41
- # if result:
42
 
43
  # showing result, it take frame name and image
44
  # output
45
- imshow("photo.jpg", filename)
46
 
47
  # saving image in local storage
48
- imwrite("photo.jpg", filename)
49
 
50
  # If keyboard interrupt occurs, destroy image
51
  # window
52
- waitKey(0)
53
- destroyWindow("photo.jpg")
 
 
54
 
55
  # If captured image is corrupted, moving to else part
56
- # else:
57
- # print("No image detected. Please! try again")
58
 
59
 
60
  #with open(filename, 'wb') as f:
61
  # f.write(binary)
62
  return filename
63
 
64
-
65
 
66
  #from ultralyticsplus import YOLO, render_result
67
 
 
31
  # current device, assign a value in cam_port
32
  # variable according to that
33
  cam_port = 0
34
+ cam = cv2.VideoCapture(cam_port)
35
 
36
  # reading the input using the camera
37
  result, filename = cam.read()
38
 
39
  # If image will detected without any error,
40
  # show result
41
+ if result:
42
 
43
  # showing result, it take frame name and image
44
  # output
45
+ imshow("photo.jpg", filename)
46
 
47
  # saving image in local storage
48
+ imwrite("photo.jpg", filename)
49
 
50
  # If keyboard interrupt occurs, destroy image
51
  # window
52
+ cv2.waitKey(0)
53
+ cv2.destroyAllWindows()
54
+ # cv2.destroyWindow("photo.jpg")
55
+
56
 
57
  # If captured image is corrupted, moving to else part
58
+ else:
59
+ print("No image detected. Please! try again")
60
 
61
 
62
  #with open(filename, 'wb') as f:
63
  # f.write(binary)
64
  return filename
65
 
66
+ #take_photo()
67
 
68
  #from ultralyticsplus import YOLO, render_result
69