OpenCV capturing imagem with black side bars
I'm try to capture photos and videos using cv2.VideoCapture and cameras with ratio 16:9. But all image is returned by OpenCV with black side, cropping the image. In my example, instead of return an image with 1280 x 720, it return a 960 x 720 image. The same occurs using a webcam C920 (1920 x 1080).
What I´m doing wrong?
import cv2
video = cv2.VideoCapture(0)
video.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
video.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
while True:
conected, frame = video.read()
cv2.imshow("Video", frame)
if cv2.waitKey(1) == ord('s'):
video.release()
break
cv2.destroyAllWindows()
Using OpenCV:
Using Windows Camera:
python opencv
|
show 1 more comment
I'm try to capture photos and videos using cv2.VideoCapture and cameras with ratio 16:9. But all image is returned by OpenCV with black side, cropping the image. In my example, instead of return an image with 1280 x 720, it return a 960 x 720 image. The same occurs using a webcam C920 (1920 x 1080).
What I´m doing wrong?
import cv2
video = cv2.VideoCapture(0)
video.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
video.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
while True:
conected, frame = video.read()
cv2.imshow("Video", frame)
if cv2.waitKey(1) == ord('s'):
video.release()
break
cv2.destroyAllWindows()
Using OpenCV:
Using Windows Camera:
python opencv
maybe you should upgrade OpenCV version to 3 latest
– seokrae.kim
Aug 28 '18 at 1:18
Im using OpenCV 3.4.2
– MarceloSouza
Aug 28 '18 at 9:51
Maybe your camera isn't capable of 1280x720, not all cameras shoot all resolutions.
– Mark Setchell
Aug 28 '18 at 10:40
When I use Sarxos library or use Windows Camera application, the image is shown correctly.
– MarceloSouza
Aug 28 '18 at 13:00
Just for fun, try setting the height first, then the width - I mean swap the order of the two lines setting the height and width.
– Mark Setchell
Aug 29 '18 at 12:48
|
show 1 more comment
I'm try to capture photos and videos using cv2.VideoCapture and cameras with ratio 16:9. But all image is returned by OpenCV with black side, cropping the image. In my example, instead of return an image with 1280 x 720, it return a 960 x 720 image. The same occurs using a webcam C920 (1920 x 1080).
What I´m doing wrong?
import cv2
video = cv2.VideoCapture(0)
video.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
video.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
while True:
conected, frame = video.read()
cv2.imshow("Video", frame)
if cv2.waitKey(1) == ord('s'):
video.release()
break
cv2.destroyAllWindows()
Using OpenCV:
Using Windows Camera:
python opencv
I'm try to capture photos and videos using cv2.VideoCapture and cameras with ratio 16:9. But all image is returned by OpenCV with black side, cropping the image. In my example, instead of return an image with 1280 x 720, it return a 960 x 720 image. The same occurs using a webcam C920 (1920 x 1080).
What I´m doing wrong?
import cv2
video = cv2.VideoCapture(0)
video.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
video.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
while True:
conected, frame = video.read()
cv2.imshow("Video", frame)
if cv2.waitKey(1) == ord('s'):
video.release()
break
cv2.destroyAllWindows()
Using OpenCV:
Using Windows Camera:
python opencv
python opencv
edited Aug 28 '18 at 13:06
MarceloSouza
asked Aug 27 '18 at 16:44
MarceloSouzaMarceloSouza
15817
15817
maybe you should upgrade OpenCV version to 3 latest
– seokrae.kim
Aug 28 '18 at 1:18
Im using OpenCV 3.4.2
– MarceloSouza
Aug 28 '18 at 9:51
Maybe your camera isn't capable of 1280x720, not all cameras shoot all resolutions.
– Mark Setchell
Aug 28 '18 at 10:40
When I use Sarxos library or use Windows Camera application, the image is shown correctly.
– MarceloSouza
Aug 28 '18 at 13:00
Just for fun, try setting the height first, then the width - I mean swap the order of the two lines setting the height and width.
– Mark Setchell
Aug 29 '18 at 12:48
|
show 1 more comment
maybe you should upgrade OpenCV version to 3 latest
– seokrae.kim
Aug 28 '18 at 1:18
Im using OpenCV 3.4.2
– MarceloSouza
Aug 28 '18 at 9:51
Maybe your camera isn't capable of 1280x720, not all cameras shoot all resolutions.
– Mark Setchell
Aug 28 '18 at 10:40
When I use Sarxos library or use Windows Camera application, the image is shown correctly.
– MarceloSouza
Aug 28 '18 at 13:00
Just for fun, try setting the height first, then the width - I mean swap the order of the two lines setting the height and width.
– Mark Setchell
Aug 29 '18 at 12:48
maybe you should upgrade OpenCV version to 3 latest
– seokrae.kim
Aug 28 '18 at 1:18
maybe you should upgrade OpenCV version to 3 latest
– seokrae.kim
Aug 28 '18 at 1:18
Im using OpenCV 3.4.2
– MarceloSouza
Aug 28 '18 at 9:51
Im using OpenCV 3.4.2
– MarceloSouza
Aug 28 '18 at 9:51
Maybe your camera isn't capable of 1280x720, not all cameras shoot all resolutions.
– Mark Setchell
Aug 28 '18 at 10:40
Maybe your camera isn't capable of 1280x720, not all cameras shoot all resolutions.
– Mark Setchell
Aug 28 '18 at 10:40
When I use Sarxos library or use Windows Camera application, the image is shown correctly.
– MarceloSouza
Aug 28 '18 at 13:00
When I use Sarxos library or use Windows Camera application, the image is shown correctly.
– MarceloSouza
Aug 28 '18 at 13:00
Just for fun, try setting the height first, then the width - I mean swap the order of the two lines setting the height and width.
– Mark Setchell
Aug 29 '18 at 12:48
Just for fun, try setting the height first, then the width - I mean swap the order of the two lines setting the height and width.
– Mark Setchell
Aug 29 '18 at 12:48
|
show 1 more comment
3 Answers
3
active
oldest
votes
I had the same issue too, but only on Windows 10, OpenCV 3.4 and Python 3.7.
I get the full resolution without the black side bars on a Mac OS.
I used PyGame to capture the webcam input and got the full resolution of 1920x1080 on Windows.
add a comment |
Just resize the received frame:
cv::Mat dst;
cv:resize(frame,dst,cv::Size(1280,720));
cv::imshow("Video",dst);
Check it!
That will just distort the image to fill the size, but it still won't capture the information in the wider field of view.
– Mark Setchell
Aug 29 '18 at 12:47
I tried it, but didn't work. Thank you
– MarceloSouza
Aug 29 '18 at 15:46
add a comment |
I had this exact issue with a Logitech wide angle in windows camera and I was wondering about a driver problem.
So I solved it using the DirectShow driver instead of the native driver using this:
cv2.VideoCapture(cv2.CAP_DSHOW)
If you have more than one camera add the index to that value like this
cv2.VideoCapture(cv2.CAP_DSHOW + camera_index)
It will accept the desired resolution by applying the right aspect ratio without having the sidebars.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52043671%2fopencv-capturing-imagem-with-black-side-bars%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I had the same issue too, but only on Windows 10, OpenCV 3.4 and Python 3.7.
I get the full resolution without the black side bars on a Mac OS.
I used PyGame to capture the webcam input and got the full resolution of 1920x1080 on Windows.
add a comment |
I had the same issue too, but only on Windows 10, OpenCV 3.4 and Python 3.7.
I get the full resolution without the black side bars on a Mac OS.
I used PyGame to capture the webcam input and got the full resolution of 1920x1080 on Windows.
add a comment |
I had the same issue too, but only on Windows 10, OpenCV 3.4 and Python 3.7.
I get the full resolution without the black side bars on a Mac OS.
I used PyGame to capture the webcam input and got the full resolution of 1920x1080 on Windows.
I had the same issue too, but only on Windows 10, OpenCV 3.4 and Python 3.7.
I get the full resolution without the black side bars on a Mac OS.
I used PyGame to capture the webcam input and got the full resolution of 1920x1080 on Windows.
answered Sep 24 '18 at 1:59
kmocherlakmocherla
211
211
add a comment |
add a comment |
Just resize the received frame:
cv::Mat dst;
cv:resize(frame,dst,cv::Size(1280,720));
cv::imshow("Video",dst);
Check it!
That will just distort the image to fill the size, but it still won't capture the information in the wider field of view.
– Mark Setchell
Aug 29 '18 at 12:47
I tried it, but didn't work. Thank you
– MarceloSouza
Aug 29 '18 at 15:46
add a comment |
Just resize the received frame:
cv::Mat dst;
cv:resize(frame,dst,cv::Size(1280,720));
cv::imshow("Video",dst);
Check it!
That will just distort the image to fill the size, but it still won't capture the information in the wider field of view.
– Mark Setchell
Aug 29 '18 at 12:47
I tried it, but didn't work. Thank you
– MarceloSouza
Aug 29 '18 at 15:46
add a comment |
Just resize the received frame:
cv::Mat dst;
cv:resize(frame,dst,cv::Size(1280,720));
cv::imshow("Video",dst);
Check it!
Just resize the received frame:
cv::Mat dst;
cv:resize(frame,dst,cv::Size(1280,720));
cv::imshow("Video",dst);
Check it!
answered Aug 29 '18 at 11:29


Igor ZavistovichIgor Zavistovich
173
173
That will just distort the image to fill the size, but it still won't capture the information in the wider field of view.
– Mark Setchell
Aug 29 '18 at 12:47
I tried it, but didn't work. Thank you
– MarceloSouza
Aug 29 '18 at 15:46
add a comment |
That will just distort the image to fill the size, but it still won't capture the information in the wider field of view.
– Mark Setchell
Aug 29 '18 at 12:47
I tried it, but didn't work. Thank you
– MarceloSouza
Aug 29 '18 at 15:46
That will just distort the image to fill the size, but it still won't capture the information in the wider field of view.
– Mark Setchell
Aug 29 '18 at 12:47
That will just distort the image to fill the size, but it still won't capture the information in the wider field of view.
– Mark Setchell
Aug 29 '18 at 12:47
I tried it, but didn't work. Thank you
– MarceloSouza
Aug 29 '18 at 15:46
I tried it, but didn't work. Thank you
– MarceloSouza
Aug 29 '18 at 15:46
add a comment |
I had this exact issue with a Logitech wide angle in windows camera and I was wondering about a driver problem.
So I solved it using the DirectShow driver instead of the native driver using this:
cv2.VideoCapture(cv2.CAP_DSHOW)
If you have more than one camera add the index to that value like this
cv2.VideoCapture(cv2.CAP_DSHOW + camera_index)
It will accept the desired resolution by applying the right aspect ratio without having the sidebars.
add a comment |
I had this exact issue with a Logitech wide angle in windows camera and I was wondering about a driver problem.
So I solved it using the DirectShow driver instead of the native driver using this:
cv2.VideoCapture(cv2.CAP_DSHOW)
If you have more than one camera add the index to that value like this
cv2.VideoCapture(cv2.CAP_DSHOW + camera_index)
It will accept the desired resolution by applying the right aspect ratio without having the sidebars.
add a comment |
I had this exact issue with a Logitech wide angle in windows camera and I was wondering about a driver problem.
So I solved it using the DirectShow driver instead of the native driver using this:
cv2.VideoCapture(cv2.CAP_DSHOW)
If you have more than one camera add the index to that value like this
cv2.VideoCapture(cv2.CAP_DSHOW + camera_index)
It will accept the desired resolution by applying the right aspect ratio without having the sidebars.
I had this exact issue with a Logitech wide angle in windows camera and I was wondering about a driver problem.
So I solved it using the DirectShow driver instead of the native driver using this:
cv2.VideoCapture(cv2.CAP_DSHOW)
If you have more than one camera add the index to that value like this
cv2.VideoCapture(cv2.CAP_DSHOW + camera_index)
It will accept the desired resolution by applying the right aspect ratio without having the sidebars.
answered Nov 21 '18 at 5:25
luismesasluismesas
12824
12824
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52043671%2fopencv-capturing-imagem-with-black-side-bars%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
maybe you should upgrade OpenCV version to 3 latest
– seokrae.kim
Aug 28 '18 at 1:18
Im using OpenCV 3.4.2
– MarceloSouza
Aug 28 '18 at 9:51
Maybe your camera isn't capable of 1280x720, not all cameras shoot all resolutions.
– Mark Setchell
Aug 28 '18 at 10:40
When I use Sarxos library or use Windows Camera application, the image is shown correctly.
– MarceloSouza
Aug 28 '18 at 13:00
Just for fun, try setting the height first, then the width - I mean swap the order of the two lines setting the height and width.
– Mark Setchell
Aug 29 '18 at 12:48