0

I'm getting the following error:

Traceback (most recent call last):
  File "calibrating.py", line 160, in <module>
    intrinsic = calibrate2(corners, cb_points, (640,480))
  File "calibrating.py", line 100, in calibrate2
    valid_corners = filter(itemgetter(0), image_corners)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

image_corners is a list of numpy arrays, i.e.,

[array([[ 261.45239258,  140.88212585],
   [ 301.11242676,  156.306427  ],
   [ 343.38937378,  168.20132446],
   [ 382.79559326,  180.48405457],...
   [ 392.16989136,  338.6171875 ],
   [ 439.97772217,  337.2124939 ]], dtype=float32), ... ]

What I want to do is to take the matrices without the dtype=float32, what am I doing wrong?

7
  • Could you clarify what you mean by "take the matrices without the dtype=float32"? Commented Apr 29, 2013 at 9:13
  • What is a "valid corner"? Is it any point other than [0,0]? (What are you trying to eliminate with filter?) Commented Apr 29, 2013 at 9:21
  • With "take the matrices without the dtype=float32" I mean that I want to take out the second element of the numpy array tupple, in other words, get a "traditional" array. Commented Apr 29, 2013 at 9:45
  • Valid corners is the name I gave to the list which contains matrices that I can operate with. Commented Apr 29, 2013 at 9:46
  • 1
    See Convert 2d numpy array into list of lists Commented Apr 29, 2013 at 9:51

2 Answers 2

1

The dtype attribute isn't accessible by itemgetter.

Try this filter instead:

filter(lambda arr: arr.dtype != float32, image_corners)

That will give you all the matricies without dtype==float32.

Sign up to request clarification or add additional context in comments.

Comments

0

Or with list comprehensions:

[a for a in image_corners if a.dtype is not float32]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.