'Open CV shows a gray window
Open CV just shows a gray window when i execute my python code. Think it might Open CV not detecting my camera.
Full Code
from cProfile import label
import cv2
import os
import time
import uuid
IMAGES_PATH = 'Tensorflow/workspace/images/collectedimages'
labels = ['hello', 'thanks', 'yes', 'no', 'iloveyou']
number_imgs = 15
for label in labels:
cap = cv2.VideoCapture(0)
cv2.namedWindow("Window")
print('Detecting for {}...'.format(label))
time.sleep(5)
for imgnum in range(number_imgs):
ret, frame = cap.read()
imgname = os.path.join(IMAGES_PATH, label, label +'.''+' '{}.jpg' .format (set(uuid.uuid1())))
cv2.imwrite(imgname, frame)
cv2.imshow ('frame', frame)
time.sleep(2)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
Solution 1:[1]
How can I determine that
baris typecast toObjectat runtime?
You cannot determine that at runtime, since type casting has no effect on the reference in the bar variable or the object that it refers to1.
Calling getClass() on the object returns the object's actual type.
Solution: There is no solution for the problem as you stated it. If you explained what you were trying to achieve (e.g. with a larger example), maybe we could suggest an alternative approach.
1 - This is analogous to real world classification. Suppose that I show you a cat. Can you tell just by looking at the cat if I am currently (in my mind) classifying it as a Felis Catus or a member of the family Felidae, of the order Carnivora, of the class Mammalia and so on? No. The cat is all of those things and you can't tell what I am thinking by looking at the cat. What I am thinking does not alter it one iota.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
