change frame size of video Capture
See original GitHub issueSummary of your issue
I have 5MP camera, and I can use opencvsharp to capture(or liveview ) at 2 resolution 2592x1944 and 1280x1024, but I want to make liveview at 1280 and capture single image at 2592, it return black image at size 2592, how to do that, I stop camera and re-init it but it does not work.
Environment
window 7, opencv sharp 4.1.0 Write your environment.
What did you do when you faced the problem?
//write here
Example code:
bool InitCamCapture()
{
_capture = new VideoCapture();
_nCamIndex = CheckCamID();
if (_nCamIndex <= -1) return false;
if (_capture.IsOpened())
_capture.Release();
_capture.Open(_nCamIndex);
_capture.FrameWidth = 1280;
_capture.FrameHeight = 1044;
_capture.Read(_framePreview);
if (_framePreview.Height > 0)
{
timerWebCam.Enabled = true;
_bmpCam = _framePreview.ToBitmap();
//_bmpCam.RotateFlip(RotateFlipType.Rotate90FlipNone);
picCamera.Image = _bmpCam;
return true;
}
return false;
}
private void btCapture_Click(object sender, EventArgs e)
{
_nCamIndex = 1;
timerWebCam.Enabled = false;
Thread.Sleep(100);
if (_capture.IsOpened())
{
_capture.Release();
}
_capture = new VideoCapture();
_capture.FrameWidth = 2592;
_capture.FrameHeight = 1944;
_frameCapture = new Mat();
_capture.Open(_nCamIndex);
_capture.Read(_frameCapture);
_frameCapture.SaveImage("cap.bmp");
InitCamCapture();
}
Output:
paste your output
What did you intend to be?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Can't set frame width and height with [OpenCV] cv2. ...
The idea is to resize the frame without having to worry about setting the default frame size. Instead of using cv2.VideoCapture().set() ...
Read more >OpenCV & Python: How to Change Resolution or Rescale ...
OpenCV makes it easy to change resolution of your video. ... VideoCapture(0) def rescale_frame(frame, percent=75): width ...
Read more >How to change video resolution in OpenCV in Python
Step 1: Importing the libraries Step 2: Define a video capture object Step 3: Capture video frame by frame Step 4: Declare the...
Read more >How to set cv2.VideoCapture() image size in Python
Use cv2.CAP_PROP_FRAME_WIDTH and cv2.CAP_PROP_FRAME_HEIGHT in order to tell OpenCV which image size you would like.
Read more >Manually Resize Height and Width of Display Capture
Right Click on the Source, Transform -> Edit Transform ... am resizing (and/or cropping) lots of pre-recorded videos from different sources.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
“Open” BEFORE “FrameHeight” and “FrameWidth” did the job for me. Thanks a lot.
After lots of searching, I discovered that there’s a way to reduce the resolution but you have to structure your code in a specific way.
capture.Open(deviceIndex);
outputVideo = new VideoWriter("video.mp4", FourCC.AVC, 29, new OpenCvSharp.Size(capture.FrameWidth, capture.FrameHeight));