错误:( - 209)该操作既不是'数组操作数组'....-(Python 3.4,opencv,picamera)

时间:2017-11-22 08:45:56

标签: arrays opencv python-3.4 video-processing raspberry-pi3

我想提供一个输入,一个从picamera(.h264)拍摄的视频到我的电脑中的python代码,[因为opencv-python没有安装在我的raspbian OS中]。

我将.h264中的视频转换为mp4并将其作为输入视频文件,我收到以下错误。

OpenCV Error: Sizes of input arguments do not match (The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array') in arithm_op, file /io/opencv/modules/core/src/arithm.cpp, line 659

Traceback (most recent call last):

  File "/home/ramakrishna/PycharmProjects/Lanedect/driving-lane-departure-warning-master/main.py", line 36, in <module>

    clip = clip1.fl_image(process_frame) #NOTE: it should be in BGR format

  File "/home/ramakrishna/.local/lib/python3.4/site-packages/moviepy/video/VideoClip.py", line 533, in fl_image

    return self.fl(lambda gf, t: image_func(gf(t)), apply_to)

  File "/home/ramakrishna/.local/lib/python3.4/site-packages/moviepy/Clip.py", line 136, in fl

    newclip = self.set_make_frame(lambda t: fun(self.get_frame, t))

  File "<decorator-gen-57>", line 2, in set_make_frame
 File "/home/ramakrishna/.local/lib/python3.4/site-packages/moviepy/decorators.py", line 14, in outplace

    f(newclip, *a, **k)

  File "/home/ramakrishna/.local/lib/python3.4/site-packages/moviepy/video/VideoClip.py", line 694, in set_make_frame

    self.size = self.get_frame(0).shape[:2][::-1]

  File "<decorator-gen-14>", line 2, in get_frame
  File "/home/ramakrishna/.local/lib/python3.4/site-packages/moviepy/decorators.py", line 89, in wrapper

    return f(*new_a, **new_kw)

  File "/home/ramakrishna/.local/lib/python3.4/site-packages/moviepy/Clip.py", line 95, in get_frame

    return self.make_frame(t)

  File "/home/ramakrishna/.local/lib/python3.4/site-packages/moviepy/Clip.py", line 136, in <lambda>

    newclip = self.set_make_frame(lambda t: fun(self.get_frame, t))

  File "/home/ramakrishna/.local/lib/python3.4/site-packages/moviepy/video/VideoClip.py", line 533, in <lambda>

    return self.fl(lambda gf, t: image_func(gf(t)), apply_to)

  File "/home/ramakrishna/PycharmProjects/Lanedect/driving-lane-departure-warning-master/lane.py", line 619, in process_frame

    output = create_output_frame(offcenter, pts, img_undist_, fps, curvature, curve_direction, binary_sub)

  File "/home/ramakrishna/PycharmProjects/Lanedect/driving-lane-departure-warning-master/lane.py", line 486, in create_output_frame

    output = cv2.addWeighted(undist_ori, 1, newwarp_, 0.3, 0)

cv2.error: /io/opencv/modules/core/src/arithm.cpp:659: error: (-209) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function arithm_op

Process finished with exit code 1

请帮我解决这个错误。

以下是代码中已设置的输入文件的大小。但我的视频文件大小为20.5 MB,尺寸为1920 x 1080.如果必须,我该如何更改尺寸?

left_lane = Lane()

right_lane = Lane()

frame_width = 1280

frame_height = 720

LANEWIDTH = 3.7  # highway lane width in US: 3.7 meters

input_scale = 4

output_frame_scale = 4

N = 4 # buffer previous N lines

# fullsize:1280x720

x = [194, 1117, 705, 575]

y = [719, 719, 461, 461]

X = [290, 990, 990, 290]

Y = [719, 719, 0, 0]

0 个答案:

没有答案