Skip to content

Fix samples#20326

Merged
opencv-pushbot merged 1 commit intoopencv:masterfrom
APrigarina:fix_samples
Jul 1, 2021
Merged

Fix samples#20326
opencv-pushbot merged 1 commit intoopencv:masterfrom
APrigarina:fix_samples

Conversation

@APrigarina
Copy link
Copy Markdown
Contributor

This PR fixes errors in some samples

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

hist = np.around(hist_item)
for x,y in enumerate(hist):
cv.line(h,(x,0),(x,y),(255,255,255))
cv.line(h,(int(x),0),(int(x),int(y)),(255,255,255))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was type of x here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what was wrong with type of y too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is numpy array of one float element

cv.namedWindow("Video")

convert_rgb = True
convert_rgb = 1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense to replace passing of convert_rgb argument instead of changing its type:

convert_rgb => 1 if convert_rgb else 0

fig = plt.figure()
ax = fig.gca(projection='3d')
ax.set_aspect("equal")
ax.set_aspect("auto")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@APrigarina

What is the reason of this change?

Before:

image

After:

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@catree, this is because of matplotlib bug in versions >=3.1.0 on Windows. The picture depends on window size, the graph is still valid. On latest versions of matlotlib the picture doesn't change with window resizing
image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@APrigarina

Ok, I will trust your change. Any possibility to make it looks good on any platform regardless of the Matplotlib version would be welcome.

@alalek alalek mentioned this pull request Jun 30, 2021
@alalek
Copy link
Copy Markdown
Member

alalek commented Jul 1, 2021

@APrigarina Please rebase patch on latest master branch (there was merged 3.4 variant of this patch)

hist = np.around(hist_item)
for x,y in enumerate(hist):
cv.line(h,(x,0),(x,y[0]),(255,255,255))
cv.line(h,(x,0),(x,int(y)),(255,255,255))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we should have different code on 3.4 and master branch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on 3.4 branch there was array of one integer element, on master branch - of one float

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was hist=np.int32(...) above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I missed it, thanks

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 👍

@opencv-pushbot opencv-pushbot merged commit 050ea97 into opencv:master Jul 1, 2021
@alalek alalek mentioned this pull request Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants