gpt4 book ai didi

python - int()参数必须是字符串,类似字节的对象或数字,而不是 'NoneType'

转载 作者:行者123 更新时间:2023-12-02 17:36:13 26 4
gpt4 key购买 nike

我尝试开发对象检测API,在实现过程中发生错误,

import cv2
cap = cv2.VideoCapture(0)

with detection_graph.as_default():
with tf.Session(graph=detection_graph) as sess:
while(True):
ret,image_np =cap.read()
image_np_expanded = np.expand_dims(image_np,axis=0)
image_tensor =detection_graph.get_tensor_by_name('image_tensor:0')
boxes = detection_graph.get_tensor_by_name('detection_boxes:0')
scores = detection_graph.get_tensor_by_name('detection_scores:0')
classes = detection_graph.get_tensor_by_name('detection_classes:0')
num_detections = detection_graph.get_tensor_by_name('num_detections:0')

(boxes,scores,classes,num_detections) = sess.run(
[boxes,scores,classes,num_detections],
feed_dict={ image_tensor:image_np_expanded})
vis_util.visualize_boxes_and_labels_on_image_array(
image_np,
np.squeeze(boxes),
np.squeeze(classes).astype(np.int32),
np.squeeze(scores),
category_index,
use_normalized_coordinates=True,
line_thickness=8)

cv2.imshow('image',cv2.resize(image_np,(1280,960)))
if cv2.waitkey(25) & 0xFF == ord('q'):
break
cv2.destroyAllWindows()
cap.release()

最佳答案

您是否检查流是否正确打开。您可以使用下面的行来尝试。

cap.isOpened()

如果上述方法返回true,则表示读取文件没有问题。然后,您需要在下面的行中设置要读取的帧。

cap.set(cv2.CAP_PROP_POS_MSEC,frameNumber)

您可以在直播时将frameNumber设置为1000(以millisec为单位)!

关于python - int()参数必须是字符串,类似字节的对象或数字,而不是 'NoneType',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50659698/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com