错误:(-2:未指定的错误)该功能未实现.使用 Windows、GTK+ 2.x 或 Cocoa 支持重建库 [英] error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support
问题描述
我在 jupyter notebook 上做一个手语检测项目.运行实时检测代码时遇到如下错误:
I was working on a sign language detection project on jupyter notebook. While running the code for live detection I encountered an error as shown below:
OpenCV(4.5.1) C:UsersappveyorAppDataLocalTemp1pip-req-build-1drr4hl0opencvmoduleshighguisrcwindow.cpp:651:错误:(-2:Unspecified error) 功能未实现.使用 Windows、GTK+ 2.x 或 Cocoa 支持重建库.如果您在 Ubuntu 或 Debian 上,请安装 libgtk2.0-dev 和 pkg-config,然后重新运行 cmake 或在函数 'cvShowImage' 中配置脚本
OpenCV(4.5.1) C:UsersappveyorAppDataLocalTemp1pip-req-build-1drr4hl0opencvmoduleshighguisrcwindow.cpp:651: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'
尽管尝试了很多我在网上找到的解决方案,但我仍然遇到同样的错误.
Despite of trying many solutions that I found online I'm still getting the same error.
遇到错误的代码是:而真:ret, frame = cap.read()image_np = np.array(frame)
The code that encountered error is : while True: ret, frame = cap.read() image_np = np.array(frame)
input_tensor = tf.convert_to_tensor(np.expand_dims(image_np, 0), dtype=tf.float32)
detections = detect_fn(input_tensor)
num_detections = int(detections.pop('num_detections'))
detections = {key: value[0, :num_detections].numpy()
for key, value in detections.items()}
detections['num_detections'] = num_detections
# detection_classes should be ints.
detections['detection_classes'] = detections['detection_classes'].astype(np.int64)
label_id_offset = 1
image_np_with_detections = image_np.copy()
viz_utils.visualize_boxes_and_labels_on_image_array(
image_np_with_detections,
detections['detection_boxes'],
detections['detection_classes']+label_id_offset,
detections['detection_scores'],
category_index,
use_normalized_coordinates=True,
max_boxes_to_draw=5,
min_score_thresh=.5,
agnostic_mode=False)
cv2.imshow('object detection', cv2.resize(image_np_with_detections, (800, 600)))
if cv2.waitKey(1) & 0xFF == ord('q'):
cap.release()
break
请帮帮我!
推荐答案
我在 windows 10 上使用 yolov5 时遇到了完全相同的错误.通过键入重新构建库
I had the exact same error using yolov5, on windows 10. Rebuilding the library by typing
pip uninstall opencv-python
然后
pip install opencv-python
为我工作.
这篇关于错误:(-2:未指定的错误)该功能未实现.使用 Windows、GTK+ 2.x 或 Cocoa 支持重建库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!