Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python window.cpp:366:错误:(-215:断言失败)size.width>;0&&;尺寸、高度>;函数'中的0;cv::imshow';_Python_Opencv_Tensorflow - Fatal编程技术网

Python window.cpp:366:错误:(-215:断言失败)size.width>;0&&;尺寸、高度>;函数'中的0;cv::imshow';

Python window.cpp:366:错误:(-215:断言失败)size.width>;0&&;尺寸、高度>;函数'中的0;cv::imshow';,python,opencv,tensorflow,Python,Opencv,Tensorflow,我使用tensorflow api进行手部检测,但当我提取溺水盒中的手时,会出现此错误 args = parser.parse_args() print(args.video_source) cap = cv2.VideoCapture(0) #cap.set(cv2.CAP_PROP_FRAME_WIDTH, args.width) #cap.set(cv2.CAP_PROP_FRAME_HEIGHT, args.height) start_time = datetime.datetime.

我使用tensorflow api进行手部检测,但当我提取溺水盒中的手时,会出现此错误

args = parser.parse_args()
print(args.video_source)
cap = cv2.VideoCapture(0)
#cap.set(cv2.CAP_PROP_FRAME_WIDTH, args.width)
#cap.set(cv2.CAP_PROP_FRAME_HEIGHT, args.height)

start_time = datetime.datetime.now()
num_frames = 0
im_width, im_height = (cap.get(3), cap.get(4))
# max number of hands we want to detect/track
num_hands_detect = 2

cv2.namedWindow('Single-Threaded Detection', cv2.WINDOW_NORMAL)

while True:
    # Expand dimensions since the model expects images to have shape: [1, None, None, 3]
    ret, image_np = cap.read()
    image_np = cv2.flip(image_np, 1)
    try:
        image_np = cv2.cvtColor(image_np, cv2.COLOR_BGR2RGB)
    except:
        print("Error converting to RGB")

    # actual detection
    boxes, scores = detector_utils.detect_objects(
        image_np, detection_graph, sess)
    
    res= detector_utils.get_box_image(
        num_hands_detect, args.score_thresh, scores, boxes, im_width, im_height, image_np)

    # draw bounding boxes
    detector_utils.draw_box_on_image(
        num_hands_detect, args.score_thresh, scores, boxes, im_width, im_height, image_np)

    # Calculate Frames per second (FPS)
    num_frames += 1
    elapsed_time = (datetime.datetime.now() -
                    start_time).total_seconds()
    fps = num_frames / elapsed_time

    if (args.display > 0):
        # Display FPS on frame
        if (args.fps > 0):
            detector_utils.draw_fps_on_image(
                "FPS : " + str(int(fps)), image_np)

        cv2.imshow('Single-Threaded Detection', cv2.cvtColor(
            image_np, cv2.COLOR_RGB2BGR))
        cv2.imshow("b",res)
        if cv2.waitKey(25) & 0xFF == ord('q'):
            cv2.destroyAllWindows()
            break
    else:
        print("frames processed: ",  num_frames,
              "elapsed time: ", elapsed_time, "fps: ", str(int(fps)))
cv2.imshow(“b”,res)

错误:OpenCV(3.4.6)D:\Build\OpenCV\OpenCV-

3.4.6\modules\highgui\src\window.cpp:366:错误:(-215:断言失败)


函数“cv::imshow”中的size.width>0&&size.height>0

OpenCV中的此错误通常意味着您发送到cv2.imshow的“res”变量出于某种原因是无的,是这样吗?

是的,我如何解决它的图像\u np也无?不,它会运行并在手周围形成矩形,但当我写这行cv.imshow(“b”,res)时错误似乎是存在的,但它是由于res为None,现在我想知道image\u np是否也是None,如果不是这样,那么detector\u utils.get\u box\u image很可能会把一切都搞糟