Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion error #18

Open
Zumbalamambo opened this issue Aug 21, 2017 · 4 comments
Open

Conversion error #18

Zumbalamambo opened this issue Aug 21, 2017 · 4 comments

Comments

@Zumbalamambo
Copy link

Im getting the following error while conversion

File "cvs_to_numpy.py", line 71, in <module>
    image = data_to_image(row['pixels'])
  File "cvs_to_numpy.py", line 59, in data_to_image
    data_image = format_image(data_image)
  File "cvs_to_numpy.py", line 16, in format_image
    gray_border[((150 / 2) - (SIZE_FACE/2)):((150/2)+(SIZE_FACE/2)), ((150/2)-(SIZE_FACE/2)):((150/2)+(SIZE_FACE/2))] = image
TypeError: slice indices must be integers or None or have an __index__ method
@AdrienPlayerium
Copy link

you need to give integers to reach indices of gray_border.
use a int(float f) to make sure you get it right.

@mrinal18
Copy link

mrinal18 commented Feb 8, 2018

@AdrienPlayerium i didn't get it. can you tell how to solve this problem?

@AdrienPlayerium
Copy link

@mrinal18 In this code sample, he got a numpy array which contains pixel information, to pick the region of interest you got to pick a part of this matrix, that's what he tried above.
It's almost correct, the error is raised because the slices:
((150 / 2) - (SIZE_FACE/2)):((150/2)+(SIZE_FACE/2)):((150/2)-(SIZE_FACE/2)):((150/2)+(SIZE_FACE/2))
"select square of SIZE_FACE around (150/2,150/2) position"
is not well defined since the type of those numbers are floats... therefore a quick fix would be to cast to integers:
int((150 / 2) - (SIZE_FACE/2)):int((150/2)+(SIZE_FACE/2)):int((150/2)-(SIZE_FACE/2)):int((150/2)+(SIZE_FACE/2))

@mrinal18
Copy link

mrinal18 commented Feb 9, 2018

Got it. Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants