Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to change the video resolution from landscape to portrait mode for output from my inbuilt webcam on the laptop (cv2.VideoCapture(0)). I tried rescaling the frames to get it to work, it does go to portrait mode ( height bigger than width) but the video is skewed/stretched. Is there a way around this ? please help. I am using opencv with python.

question from:https://stackoverflow.com/questions/65561020/how-to-alter-resolution-to-portrait-mode-values-with-opencv-python

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
101 views
Welcome To Ask or Share your Answers For Others

1 Answer

Welcome to Stackoverflow. What you want to achieve depends on the webcam you use. The Resolution you want need to be supported by your cam. this small tutorial explains it very good.

If your camera does not support the Resolution you want, you have two possibilites:

  1. You Crop the Image to the Resolution you want.
  2. If your max resolution does not allow your resolution you can crop it to the biggest resultion possible with your wanted ratio and after that upscale it.

Careful with upscaling. You have different interpolation methods available.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...