我试图使用opencv
调整函数的大小,该函数在套接字传输的连续循环中调用,我得到了这个错误
2017-04-10 15:46:47.200 python[1541:16193] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff8ce2b37b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffa1c1f48d objc_exception_throw + 48
2 CoreFoundation 0x00007fff8cd44b5c -[__NSArrayM objectAtIndex:] + 204
3 libopencv_highgui.2.4.dylib 0x0000000114d31280 _ZN13CvCaptureFileC2EPKc + 350
4 libopencv_highgui.2.4.dylib 0x0000000114d2fcf2 _Z32cvCreateFileCapture_AVFoundationPKc + 34
5 libopencv_highgui.2.4.dylib 0x0000000114d237ee cvCreateFileCapture + 14
6 libopencv_highgui.2.4.dylib 0x0000000114d23a9e _ZN2cv12VideoCapture4openERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 64
7 libopencv_highgui.2.4.dylib 0x0000000114d238fe _ZN2cv12VideoCaptureC2ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 42
8 cv2.so 0x00000001144ccbce _ZL34pyopencv_VideoCapture_VideoCaptureP7_objectS0_S0_ + 275
9 libpython2.7.dylib 0x000000010e6c61bd PyEval_EvalFrameEx + 30141
10 libpython2.7.dylib 0x000000010e6be8f2 PyEval_EvalCodeEx + 1538
11 libpython2.7.dylib 0x000000010e64943c function_call + 364
12 libpython2.7.dylib 0x000000010e623333 PyObject_Call + 99
13 libpython2.7.dylib 0x000000010e6305b6 instancemethod_call + 182
14 libpython2.7.dylib 0x000000010e623333 PyObject_Call + 99
15 libpython2.7.dylib 0x000000010e6ca80d PyEval_CallObjectWithKeywords + 93
16 libpython2.7.dylib 0x000000010e62e5c6 PyInstance_New + 134
17 libpython2.7.dylib 0x000000010e623333 PyObject_Call + 99
18 libpython2.7.dylib 0x000000010e6c5e8f PyEval_EvalFrameEx + 29327
19 libpython2.7.dylib 0x000000010e6cb0b2 fast_function + 274
20 libpython2.7.dylib 0x000000010e6c5db3 PyEval_EvalFrameEx + 29107
21 libpython2.7.dylib 0x000000010e6cb0b2 fast_function + 274
22 libpython2.7.dylib 0x000000010e6c5db3 PyEval_EvalFrameEx + 29107
23 libpython2.7.dylib 0x000000010e6be8f2 PyEval_EvalCodeEx + 1538
24 libpython2.7.dylib 0x000000010e6be2e6 PyEval_EvalCode + 54
25 libpython2.7.dylib 0x000000010e6ed254 PyRun_FileExFlags + 164
26 libpython2.7.dylib 0x000000010e6ecdd1 PyRun_SimpleFileExFlags + 769
27 libpython2.7.dylib 0x000000010e702a12 Py_Main + 3154
28 python 0x000000010e610f24 start + 52
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6
我使用的代码我假设生成此错误是
import numpy as np
import cv2
class video_read():
def __init__(self, filename):
self.cap = cv2.VideoCapture(filename)
def read_frames(self):
frame = self.cap.read()[1]
image = cv2.imencode('.png', frame)[1]
image_resized = cv2.resize(image, (width/10, height/10))
return image_resized
有人能指出我做错了什么叫做这个例外吗?