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

Fix the bug with rasterize landmarks with matplotlib backend. #703

Merged
merged 6 commits into from Jun 1, 2016

Conversation

Projects
None yet
3 participants
@grigorisg9gr
Member

grigorisg9gr commented May 30, 2016

The matplotlib backend was causing errors in python 3.
The following code crashed with ValueError:

im = mio.import_builtin_asset.lenna_png()
im1 = rasterize_landmarks_2d(im, 'LJSON')

In my machine it works now (python 2.7 and 3.4).

@jabooth jabooth added the in progress label May 30, 2016

@@ -80,7 +80,8 @@ def _rasterize_matplotlib(image, pclouds, render_lines=True, line_style='-',
# Get the pixels directly from the canvas buffer which is fast
c_buffer, shape = f.canvas.print_to_buffer()
# Turn buffer into numpy array and reshape to image
pixels_buffer = np.array(c_buffer).reshape(shape[::-1] + (-1,))
pixels_buffer = np.fromstring(c_buffer, dtype=np.int8).reshape(shape[::-1] + (-1,))
pixels_buffer = pixels_buffer.astype(np.uint8)

This comment has been minimized.

@patricksnape

patricksnape May 31, 2016

Contributor

No need to cast twice - can just do it once:

    # Turn buffer into numpy array and reshape to image
    pixels_buffer = np.fromstring(c_buffer,
                                  dtype=np.uint8).reshape(shape[::-1] + (-1,))

@patricksnape patricksnape merged commit 803c7d9 into menpo:master Jun 1, 2016

3 checks passed

OS X MenpoBot Jenkins build passed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@grigorisg9gr grigorisg9gr deleted the grigorisg9gr:bug_rasterize_matplotlib branch Jun 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment