The Opencv problem with OpenCV Error: Bad argument (Array should be CvMat or IplImage) in cvGetSize

asked 2014-04-22 11:27:17 -0500

ianymu gravatar image

updated 2014-04-23 01:49:13 -0500

berak gravatar image

Recently, I do my final project for my bachelor degree with Beaglebone Black.

I got problems is: 1: when I run python program like following command with pyhton using the Ubuntu (XFCE Desktop) connect with Beaglebone Black

!/usr/bin/python

import cv2.cv as cv iport time

cv.NamedWindow("camera", 1)

capture = cv.CaptureFromCAM(0) cv.SetCaptureProperty(capture, 3, 360) cv.SetCaptureProperty(capture, 4, 240)

while True: img = cv.QueryFrame(capture)

 cv.Smooth(img,img,cv.CV_BLURK,3)
 hue_img = cv.CreateImage(cv.GetSize(img), 8, 3)
 cv.CvtColor(img,hue_img, cv.CV_BGR2HSV)

 threshold_img = cv.CreateImage(cv.GetSize(hue_img), 8, 1)
 cv.InRangeS(hue_img, (38, 120, 60), (75, 255, 255), threshold_img)

 cv.ShowImage("Color Tracking", img)
 cv.ShowImage("threshold", threshold_img)

 if cv.WaitKey(10) == 27:
        break

and then, I run this python file use "./name.py"

**it show : init done OpenCV Error: Bad argument (Array should be CvMat or IplImage) in cvGetSize, file /home/ubuntu/finalproject/(this is my opencv directory)

opencv-2.4.7/modules/core/src/array.cpp, line 1238 Traceback (most recent call last): File “./example.py”, line 16, in <module> hug_img = cv.CreateImage(cv.Getsize(img), 8, 3) cv2.erro: Array should be CvMat or IplImage**

Should I re-install OpenCV on my Beaglebone Black Board, or reset something?

Thank you

edit retag flag offensive close merge delete

Comments

just a sidenote, - you probably should be using the cv2 api, not the arcane cv one (which won't be available in the future)

berak gravatar imageberak ( 2014-04-23 00:35:07 -0500 )edit