Ask Your Question
0

How do I correct this code?

asked 2015-05-14 11:47:05 -0600

Radha gravatar image

updated 2015-05-14 11:50:10 -0600

berak gravatar image

This is my code.

 import cv
 import numpy as np
 img=cv.imread("D:\OpenCV2.2\doc\logo.png",1)
 hsv=cv.CreateImage(cv.GetSize(img),8,3)
 cv.CvtColor(img,hsv,cv.CV_BGR2HSV)
 mas=cv.CreateImage(cv.GetSize(img),8,1)
 cv.InRangeS(hsv,(110,50,50),(130,255,255),mas)
 res=cv.CreateImage(cv.GetSize(img),8,1)
 cv.bitwise_and(img,img,res,mask=mas)

This is the error I get: Traceback (most recent call last): File "<pyshell#10>", line 1, in <module> cv.bitwise_and(img,img,res,mask=mas) TypeError: Scalar value for argument '<unknown>' is longer than 4

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-05-14 11:55:21 -0600

berak gravatar image

updated 2015-05-14 11:56:37 -0600

first of all, please use cv2, not the outdated cv module. (cv was completely removed in opencv3)

 import cv2
 import numpy as np
 img = cv2.imread("D:/OpenCV2.2/doc/logo.png", 1)
 hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
 mask = cv2.inRange(hsv, (110,50,50), (130,255,255))
 res = cv2.bitwise_and(img, img, mask=mas)
edit flag offensive delete link more

Comments

Thank You. Is there a way to download only cv2.pyd?

Radha gravatar imageRadha ( 2015-05-14 12:15:02 -0600 )edit

no real idea. you can try here .

berak gravatar imageberak ( 2015-05-14 13:17:39 -0600 )edit

Thanks I got it :)

Radha gravatar imageRadha ( 2015-05-14 22:52:58 -0600 )edit

Thanks for posting so I could get the solution also. Thank you again.

addseo1118 gravatar imageaddseo1118 ( 2015-05-16 04:19:38 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-05-14 11:43:14 -0600

Seen: 586 times

Last updated: May 16 '15