0
タスクは、カメラから写真を撮り、cnnsを使用して写真を処理し、その結果を写真に表示します。cv2.imshow()を使用しているときにエラーが発生しました
while(1):
test_data = []
ret, frame = cap.read()
frame = cv2.imread('hello.jpg')
h, w, _ = frame.shape
img = copy.deepcopy(frame)
img = pre_process(img)
test_data.append([img])
ret_res = _infer(inferer, test_data, threshold)
draw_result(frame, ret_res, h, w)
cv2.imshow("hellocapture", frame)
次のエラーが発生しました::しかし、私は、画像を表示するためにOpenCVのPythonインタフェースを使用してエラーがある(OSは、Mac OSです)
PC: @ 0x0 (unknown)
*** SIGFPE (@0x7fffc5186d01) received by PID 36436 (TID 0x7fffe38773c0) stack
trace: ***
@ 0x7fffdab7bb3a _sigtramp
@ 0x7fffc5186d02 CFNumberCreate
@ 0x7fffc6c027b5 -[NSPlaceholderNumber initWithDouble:]
@ 0x7fffcae3b594 +[CALayer defaultValueForKey:]
@ 0x7fffcaebd489 classDescription_locked()
@ 0x7fffcaebc9fe classDescription_locked()
@ 0x7fffcaebc9fe classDescription_locked()
@ 0x7fffcaeb8292 classDescription()
@ 0x7fffcaeb8495 CAObject_classInfo
@ 0x7fffcae3bdf4 CA::Layer::class_state()
@ 0x7fffcae3e081 -[CALayer init]
@ 0x7fffc2d07854 -[NSView makeBackingLayer]
@ 0x7fffc2d076db -[NSView(NSInternal) _createLayerAndInitialize]
@ 0x7fffc2d06d4d -[NSView _doSetWantsLayerYES]
@ 0x7fffc2d069da -[NSView setWantsLayer:]
@ 0x7fffc2d142b6 __49-[NSThemeFrame _floatTitlebarAndToolbarFromInit:]_block_invoke
@ 0x7fffc364b8b6 +[NSAnimationContext runAnimationGroup:]
@ 0x7fffc2d13f23 -[NSThemeFrame _floatTitlebarAndToolbarFromInit:]
@ 0x7fffc2d11a9c -[NSThemeFrame initWithFrame:styleMask:owner:]
@ 0x7fffc2d10522 -[NSWindow _commonInitFrame:styleMask:backing:defer:]
@ 0x7fffc2d0ec03 -[NSWindow _initContent:styleMask:backing:defer:contentView:]
@ 0x7fffc2d0e65f -[NSWindow initWithContentRect:styleMask:backing:defer:]
@ 0x1171ddebd -[QCocoaWindow initWithContentRect:styleMask:backing:defer:]
@ 0x1171dddb1 -[NSWindow(QWidgetIntegration) qt_initWithQWidget:contentRect:styleMask:]
@ 0x1171cee19 qt_mac_create_window()
@ 0x1171ce119 QWidgetPrivate::createWindow_sys()
@ 0x1171ce073 qt_mac_window_for()
@ 0x1171d3b13 QWidgetPrivate::setModal_sys()
@ 0x1172637c8 QWidget::create()
@ 0x1175d5431 QToolBarPrivate::init()
@ 0x1175d631c QToolBar::QToolBar()
@ 0x111ca9c98 CvWindow::createToolBar()
Floating point exception: 8
と私はそれに配置しましたcv2.imshowに問題がありますが、私はどのようにわからないのですか?
私はちょうどfolloingコードを使用する場合は、あなたが正常にwaitKeyを設定して解放する必要がOpenCVの中に画像を表示すると、それは
#!/usr/bin/env python
# coding=utf-8
import cv2
import numpy
import matplotlib.pyplot as plot
cap = cv2.VideoCapture(0)
while(1):
# get a frame
ret, frame = cap.read()
# show a frame
print frame.shape
cv2.imshow("capture", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
'H'を何と'w'には?あなたはそれらを印刷できますか? – Sunreef
hは720、wは1280 –
です。['imshow'](https://docs.opencv.org/2.4/modules/highgui/doc/user_interface.html#imshow)のドキュメント、特にそのメモを読むべきでしょう終わり近く。 –