0

I take an image from webcam in python, it is an array so I convert it to string using numpy.array_str(), now after doing that I need to convert that string back to an array as efficiently as possible. I have already tried it using for statements but it takes around half a second, which is just too slow for my use-case. I have even searched the web for numpy's built-in function to do the task but did not find any solution.

3

1 Answer 1

1

The numpy.array_str() function returns a string with a whitespace separator between the array elements as https://numpy.org/doc/stable/reference/generated/numpy.array_str.html

To convert it back to an array, you can use str.split() without specifying the delimiter because it considers whitespace as default.

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

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.