Ask Your Question
0

Another "new style getargs format but argument is not a tuple" question.

asked 2016-09-01 17:36:10 -0600

interstar gravatar image

updated 2016-09-02 07:31:18 -0600

For me, I'm getting it with

blank = cv2.line(blank,focus1,focus2,(255,0,0),5)

I know this is something to do with a mismatch of types with the underlying library. But what should I be using exactly? I've tried with focus1 and focus2 being both lists (defined with square-brackets) and tuples (defined with just commas). Both seem to trigger the same error.

I'm in Python 2.7 and opencv 2.4.9.1

Update: for anyone else struggling with this. I was mystified because I WAS generating the points as tuples (and so thought this wasn't the problem). But I found somewhere else in my code which was processing them and turning them back into lists on the way to the draw function.

Something to watch out for if you hit this problem.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-09-02 01:47:31 -0600

berak gravatar image

try with tuples :

focus1=0,20 # works even w/o braces !
focus2=(80,20)

cv2.line(ocv,focus1,focus2,(255,0,0),5)

image description

also please note, that the 2.4 version does not return a new image, see docs

edit flag offensive delete link more

Comments

1

# works even w/o braces ! is one of the main things why Python scares the hell out of me :D

StevenPuttemans gravatar imageStevenPuttemans ( 2016-09-02 02:53:17 -0600 )edit
1

^^ hell, yea..

berak gravatar imageberak ( 2016-09-02 02:54:40 -0600 )edit

That's funny. If I put it your example directly it works fine. In my code, I AM generating my two focus points as tuples, but they must be getting converted to a list somewhere along the line. Thanks.

interstar gravatar imageinterstar ( 2016-09-02 07:25:27 -0600 )edit

Yes. That's what was happening. I was generating the points as tuples but processing them in another function that turned them back into lists along the way. Cheers.

interstar gravatar imageinterstar ( 2016-09-02 07:29:42 -0600 )edit
1

@interstar, oh, sorry forgot to make that more clear: having a list there triggers the getargs error.

berak gravatar imageberak ( 2016-09-02 07:30:21 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-09-01 17:36:10 -0600

Seen: 11,860 times

Last updated: Sep 02 '16