Repository: opencv
Issue: Cannot set 1600*1200 resolution via CAP_MSMF backend
Labels: category: videoio(camera),platform: win32,category: 3rdparty

<!--
If you have a question rather than reporting a bug please go to https://forum.opencv.org where you get much faster responses.
If you need further assistance please read [How To Contribute](https://github.com/opencv/opencv/wiki/How_to_contribute).

This is a template helping you to create an issue which can be processed as quickly as possible. This is the bug reporting section for the OpenCV library.
-->

##### System information (version)
<!-- Example
- OpenCV => 4.2
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2019
-->

- OpenCV => 4.5.2&4.5.3
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2019
- Camera model => [KS2A543](http://www.camera-module.com/product/globalshuttercameramodule/2mp-global-shutter-camera-module-color-images.html)

##### Detailed description

<!-- your description -->I am trying to set the camera to 1600x1200@100FPS via MSMF backend, but it would be eventually set to 1280*960. 
I have tried all other supported resolutions as described in this page of [KS2A543](http://www.camera-module.com/product/globalshuttercameramodule/2mp-global-shutter-camera-module-color-images.html) and it turns out that
1. this problem only occurs when setting camera to 1600x1200@100FPS via `CAP_MSMF` backend
2. everything goes well via `CAP_DSHOW` backend

Due to the FPS requirement of my work, I am not able to use `CAP_DSHOW` as an alternative.

Below are what I have tried.

1. Using `CAP_MSMF` backend to set 1600x1200@100FPS on `windows 10 64 Bit` with compiler visual studio 2019, problem occurs.
![MSMF wrong](https://user-images.githubusercontent.com/51251025/125001778-6803f600-e08e-11eb-870d-decdf9cdf901.png)

2. Using `CAP_DSHOW` backend to set 1600x1200@100FPS on `windows 10 64 Bit` with compiler visual studio 2019, works fine.
![DSHOW right](https://user-images.githubusercontent.com/51251025/125001754-59b5da00-e08e-11eb-9b01-f794edeee4ab.png)

3. Using `CAP_V4L2` backend to set 1600x1200@100FPS on `Ubuntu 21.04` with compiler gcc/g++, works fine.
![V4L2 right](https://user-images.githubusercontent.com/51251025/125001799-6f2b0400-e08e-11eb-878d-b1d329a15027.png)

4. By using apps like AMcap, it is clear that this camera can work under 1600x1200@100FPS.
![AMcap](https://user-images.githubusercontent.com/51251025/125002614-54f22580-e090-11eb-8d74-baf1f0ad3fcc.png)

##### Steps to reproduce

<!-- to add code example fence it with triple backticks and optional file extension
    ```.cpp
    // C++ code example
    ```
 or attach as .txt or .zip file
-->

Just a plain `imshow` program. And there is [another one who also encounters this problem](https://blog.csdn.net/a1356467/article/details/113571491?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-5.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-5.control) when setting resolution to 1600*1200.
```
#include <iostream>
#include "opencv2/highgui.hpp"

using namespace cv;
using namespace std;

#define FRAMEWIDTH 1600
#define FRAMEHEIGHT 1200
#define FPS 100
#define apiPreference CAP_MSMF//CAP_V4L2 CAP_DSHOW
#define CAM_INDEX 0

int main()
{
    VideoCapture camera(CAM_INDEX, apiPreference);
    if (!camera.isOpened()) {
        cout << "open camera fail" << endl;
        return -1;
    }
    else {
        cout << "API: " << camera.getBackendName() << endl;
        cout << "resolution before VideoCaptureProperties settings:" << camera.get(CAP_PROP_FRAME_WIDTH) << "*" << camera.get(CAP_PROP_FRAME_HEIGHT) << endl;
        //camera.set(CAP_PROP_FOURCC,VideoWriter::fourcc('M','J','P','G'));
        camera.set(CAP_PROP_FRAME_WIDTH, FRAMEWIDTH);
        camera.set(CAP_PROP_FRAME_HEIGHT, FRAMEHEIGHT);
        camera.set(CAP_PROP_FPS, FPS);
        cout << "resolution after VideoCaptureProperties settings:" << camera.get(CAP_PROP_FRAME_WIDTH) << "*" << camera.get(CAP_PROP_FRAME_HEIGHT) << endl; 
    }
    Mat inputframe;
    while (waitKey(1)!=27)
    {
        camera >> inputframe;
        imshow("frame", inputframe);
        if (waitKey(1) == 112)
        {
            waitKey(0);
        }
    }
    camera.release();
    return 0;
}
```

##### Issue submission checklist

 - [x] I report the issue, it's not a question
   <!--
   OpenCV team works with forum.opencv.org, Stack Overflow and other communities
   to discuss problems. Tickets with question without real issue statement will be
   closed.
   -->
 - [x] I checked the problem with documentation, FAQ, open issues,
       forum.opencv.org, Stack Overflow, etc and have not found solution
   <!--
   Places to check:
   * OpenCV documentation: https://docs.opencv.org
   * FAQ page: https://github.com/opencv/opencv/wiki/FAQ
   * OpenCV forum: https://forum.opencv.org
   * OpenCV issue tracker: https://github.com/opencv/opencv/issues?q=is%3Aissue
   * Stack Overflow branch: https://stackoverflow.com/questions/tagged/opencv
   -->
 - [x] I updated to latest OpenCV version and the issue is still there
   <!--
   master branch for OpenCV 4.x and 3.4 branch for OpenCV 3.x releases.
   OpenCV team supports only latest release for each branch.
   The ticket is closed, if the problem is not reproduced with modern version.
   -->
 - [x] There is reproducer code and related data files: videos, images, onnx, etc
   <!--
   The best reproducer -- test case for OpenCV that we can add to the library.
   Recommendations for media files and binary files:
   * Try to reproduce the issue with images and videos in opencv_extra repository
     to reduce attachment size
   * Use PNG for images, if you report some CV related bug, but not image reader
     issue
   * Attach the image as archive to the ticket, if you report some reader issue.
     Image hosting services compress images and it breaks the repro code.
   * Provide ONNX file for some public model or ONNX file with with random weights,
     if you report ONNX parsing or handling issue. Architecture details diagram
     from netron tool can be very useful too. See https://lutzroeder.github.io/netron/
   -->