Ask Your Question
0

Under Mac OSX Yosemite 10.10.1, the image I want to display is too large and too long for the window. I would like it to adjust to the window.

asked 2015-11-25 11:32:36 -0600

Del gravatar image

updated 2015-11-25 11:38:54 -0600

berak gravatar image

Here is my code :

import cv2 import sys

image = cv2.imread(fname)

if image is None: print 'Failed to load image file:', fname sys.exit(1)

cv2.namedWindow("Trial")

cv2.imshow("Trial",image)

I'm a beginner in opencv, so please, be patient.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-11-25 11:46:11 -0600

berak gravatar image

updated 2015-11-25 11:58:28 -0600

no, it's not related to your os. (well, apple users always think it is so...)

cv2.namedWindow("Trial") # here's the problem

if you open a namedWindow with default args, it will use cv2.WINDOW_AUTOSIZE , meaning: the window will get adjusted to the image size

what you want instead is:

 cv2.namedWindow("Trial", cv2.WINDOW_NORMAL)

this will do the opposite, resizing the image to your windowsize (you can also resize it now manually(or from code))

edit flag offensive delete link more

Comments

My previous post was not accurate enough.

I have already tested :

cv2.namedWindow("Trial", cv2.WINDOW_NORMAL)

And it doesn't work either.

I do not want to resize my image form the code, because I have a lot of images to process, and their size can vary.

Del gravatar imageDel ( 2015-11-26 01:55:04 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-11-25 11:32:36 -0600

Seen: 708 times

Last updated: Nov 25 '15