I am developing a neural.network with python opencv. It works when I turn on the laptop's own camera. When I plug in an external usb camera, I don't get any response. Independent of the program, only if I write opencv camera opening codes, it hangs. The program does not close, it seems to be running, but nothing happens. Why could it be?
Opening usb camera for opencv python
My Source Code:
img_height = 128
img_width = 128
model = tf.keras.models.load_model("modelson.h5")
camera_id = 1
camera_width = 1920
camera_height = 1080
camera_frame_rate = 30
camera_fourcc = cv2.VideoWriter_fourcc(*"MJPG")
auto_percent = 0.2
auto_threshold = 127
auto_blur = 5
norm_alpha = 0
norm_beta = 255
The device index is just a number to determine which camera. Usually one camera will be connected (as in my case my camera id is 0). You can choose a second camera by changing camera id: 1
to camera id: 0
or camera id: 2
. Camera id can be changed to index 0 - 9.
hope this can help you
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.