<h5 dir="auto">System information (version)</h5>
<ul dir="auto">
<li>OpenCV =&gt; 3.4</li>
<li>Operating System / Platform =&gt; Windows 7 64 Bit</li>
<li>Compiler =&gt; python 3.5.5 / IPyhton 6.5</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">I am reading videostream from a webcam and that works fine for raw YUY2 format, the default.<br>
But i want to do some testing between YUY2 and MJPG and try to reconfigure camera to send my MJPG, but i still only get YUY2.</p>
<p dir="auto">The camera and system can do both as i can see it with AMCap / e-CAMViewer.</p>
<p dir="auto">Might be related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="168456455" data-permission-text="Title is private" data-url="https://github.com/opencv/opencv/issues/7013" data-hovercard-type="issue" data-hovercard-url="/opencv/opencv/issues/7013/hovercard" href="https://github.com/opencv/opencv/issues/7013">#7013</a></p>
<h5 dir="auto">Steps to reproduce</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="def decode_fourcc(v):
        v = int(v)
        return &quot;&quot;.join([chr((v &gt;&gt; 8 * i) &amp; 0xFF) for i in range(4)])


def do(self):
        print(&quot;Testing fps performance with 2592x1944&quot;)       
        self.cv2_cap.set(cv2.CAP_PROP_FRAME_WIDTH, 2592)
        self.cv2_cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1944)
        
        str = &quot;actual forcc format: &quot; + decode_fourcc(self.cv2_cap.get(cv2.CAP_PROP_FOURCC))               
        print (str)
        self.file.write(str + '\n')
        
#        self.measureFps()
        
        print(&quot;setting to MJPEG and doing FPS measurement again&quot;)
        ret = self.cv2_cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*'MJPG'))
        time.sleep(1)
        print (ret)
        str = &quot;actual forcc format: &quot; + decode_fourcc(self.cv2_cap.get(cv2.CAP_PROP_FOURCC))               
        print (str)
        
        self.measureFps()"><pre class="notranslate"><code class="notranslate">def decode_fourcc(v):
        v = int(v)
        return "".join([chr((v &gt;&gt; 8 * i) &amp; 0xFF) for i in range(4)])


def do(self):
        print("Testing fps performance with 2592x1944")       
        self.cv2_cap.set(cv2.CAP_PROP_FRAME_WIDTH, 2592)
        self.cv2_cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1944)
        
        str = "actual forcc format: " + decode_fourcc(self.cv2_cap.get(cv2.CAP_PROP_FOURCC))               
        print (str)
        self.file.write(str + '\n')
        
#        self.measureFps()
        
        print("setting to MJPEG and doing FPS measurement again")
        ret = self.cv2_cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*'MJPG'))
        time.sleep(1)
        print (ret)
        str = "actual forcc format: " + decode_fourcc(self.cv2_cap.get(cv2.CAP_PROP_FOURCC))               
        print (str)
        
        self.measureFps()
</code></pre></div>
<p dir="auto">the output generated is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Testing fps performance with 2592x1944
actual forcc format: YUY2
setting to MJPEG and doing FPS measurement again
True
actual forcc format: YUY2
Time taken : 2.484999895095825 seconds
Estimated frames per second : 2.012072519547206"><pre class="notranslate"><code class="notranslate">Testing fps performance with 2592x1944
actual forcc format: YUY2
setting to MJPEG and doing FPS measurement again
True
actual forcc format: YUY2
Time taken : 2.484999895095825 seconds
Estimated frames per second : 2.012072519547206
</code></pre></div>
<p dir="auto">AMCap working with YUY2:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/42960704/45022450-8de23400-b034-11e8-9560-8657c24333e4.jpg"><img src="https://user-images.githubusercontent.com/42960704/45022450-8de23400-b034-11e8-9560-8657c24333e4.jpg" alt="amcap_03_yuy2" style="max-width: 100%;"></a></p>
<p dir="auto">AMCap Settings:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/42960704/45022451-8de23400-b034-11e8-83f9-c704a9802d8d.jpg"><img src="https://user-images.githubusercontent.com/42960704/45022451-8de23400-b034-11e8-83f9-c704a9802d8d.jpg" alt="amcap_02_settings" style="max-width: 100%;"></a></p>
<p dir="auto">AMCap working with MJPG:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/42960704/45022452-8de23400-b034-11e8-84ca-d53eb12d7e05.jpg"><img src="https://user-images.githubusercontent.com/42960704/45022452-8de23400-b034-11e8-84ca-d53eb12d7e05.jpg" alt="amcap_01_mjpg" style="max-width: 100%;"></a></p>
<h5 dir="auto">System information (version)</h5>
<ul dir="auto">
<li>OpenCV =&gt; 3.1.0</li>
<li>Operating System / Platform =&gt; Windows 7 64 Bit</li>
<li>Compiler =&gt; Python</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">Trying to switch camera output from YUY2 to MJPG but it does not work. MJPG mode is working in other software packages.</p>
<h5 dir="auto">Steps to reproduce</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import cv2
import sys
import numpy as np
import time

fourcc_names = ['CAP_PROP_POS_MSEC', 'CAP_PROP_POS_FRAMES', 'CAP_PROP_POS_AVI_RATIO', 'CAP_PROP_FRAME_WIDTH', 'CAP_PROP_FRAME_HEIGHT', 'CAP_PROP_FPS', 'CAP_PROP_FOURCC', 'CAP_PROP_FRAME_COUNT', 'CAP_PROP_FORMAT', 'CAP_PROP_MODE', 'CAP_PROP_BRIGHTNESS', 'CAP_PROP_CONTRAST', 'CAP_PROP_SATURATION', 'CAP_PROP_HUE', 'CAP_PROP_GAIN', 'CAP_PROP_EXPOSURE', 'CAP_PROP_CONVERT_RGB', 'CAP_PROP_WHITE_BALANCE_BLUE_U', 'CAP_PROP_RECTIFICATION', 'CAP_PROP_MONOCHROME', 'CAP_PROP_SHARPNESS', 'CAP_PROP_AUTO_EXPOSURE', 'CAP_PROP_GAMMA', 'CAP_PROP_TEMPERATURE', 'CAP_PROP_TRIGGER', 'CAP_PROP_TRIGGER_DELAY', 'CAP_PROP_WHITE_BALANCE_RED_V', 'CAP_PROP_ZOOM', 'CAP_PROP_FOCUS', 'CAP_PROP_GUID', 'CAP_PROP_ISO_SPEED', 'CAP_PROP_BACKLIGHT', 'CAP_PROP_PAN', 'CAP_PROP_TILT', 'CAP_PROP_ROLL', 'CAP_PROP_IRIS', 'CAP_PROP_SETTINGS', 'CAP_PROP_BUFFERSIZE', 'CAP_PROP_AUTOFOCUS']

def decode_fourcc(v):
  v = int(v)
  return &quot;&quot;.join([chr((v &gt;&gt; 8 * i) &amp; 0xFF) for i in range(4)])

print cv2.__version__

camera = cv2.VideoCapture()
camera.open(0)
print 'Camera open:', camera.isOpened()
# print camera.get(cv2.CAP_PROP_FOURCC)
# C = camera.get(cv2.CAP_PROP_FOURCC)
# print 'fourcc original:', decode_fourcc(C)
# codec = 0x47504A4D # MJPG
# codec = 844715353.0 # YUY2

codec = 1196444237.0 # MJPG
# print 'fourcc:', decode_fourcc(codec)

camera.set(cv2.CAP_PROP_FOURCC, codec)

camera.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
camera.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
camera.set(cv2.CAP_PROP_FPS, 30.0)

print camera.get(cv2.CAP_PROP_FRAME_WIDTH)
print camera.get(cv2.CAP_PROP_FRAME_HEIGHT)
print camera.get(cv2.CAP_PROP_FPS)
C = camera.get(cv2.CAP_PROP_FOURCC)
print 'fourcc:', decode_fourcc(C)

print
for i in xrange(38):
    print i, fourcc_names[i], camera.get(i)

while(1):
    camera.grab()
    retval, im = camera.retrieve(0)
    cv2.imshow(&quot;image&quot;, im)
    k = cv2.waitKey(1) &amp; 0xff
    if k == 27:
        break

camera.release()
cv2.destroyAllWindows()"><pre class="notranslate"><code class="notranslate">import cv2
import sys
import numpy as np
import time

fourcc_names = ['CAP_PROP_POS_MSEC', 'CAP_PROP_POS_FRAMES', 'CAP_PROP_POS_AVI_RATIO', 'CAP_PROP_FRAME_WIDTH', 'CAP_PROP_FRAME_HEIGHT', 'CAP_PROP_FPS', 'CAP_PROP_FOURCC', 'CAP_PROP_FRAME_COUNT', 'CAP_PROP_FORMAT', 'CAP_PROP_MODE', 'CAP_PROP_BRIGHTNESS', 'CAP_PROP_CONTRAST', 'CAP_PROP_SATURATION', 'CAP_PROP_HUE', 'CAP_PROP_GAIN', 'CAP_PROP_EXPOSURE', 'CAP_PROP_CONVERT_RGB', 'CAP_PROP_WHITE_BALANCE_BLUE_U', 'CAP_PROP_RECTIFICATION', 'CAP_PROP_MONOCHROME', 'CAP_PROP_SHARPNESS', 'CAP_PROP_AUTO_EXPOSURE', 'CAP_PROP_GAMMA', 'CAP_PROP_TEMPERATURE', 'CAP_PROP_TRIGGER', 'CAP_PROP_TRIGGER_DELAY', 'CAP_PROP_WHITE_BALANCE_RED_V', 'CAP_PROP_ZOOM', 'CAP_PROP_FOCUS', 'CAP_PROP_GUID', 'CAP_PROP_ISO_SPEED', 'CAP_PROP_BACKLIGHT', 'CAP_PROP_PAN', 'CAP_PROP_TILT', 'CAP_PROP_ROLL', 'CAP_PROP_IRIS', 'CAP_PROP_SETTINGS', 'CAP_PROP_BUFFERSIZE', 'CAP_PROP_AUTOFOCUS']

def decode_fourcc(v):
  v = int(v)
  return "".join([chr((v &gt;&gt; 8 * i) &amp; 0xFF) for i in range(4)])

print cv2.__version__

camera = cv2.VideoCapture()
camera.open(0)
print 'Camera open:', camera.isOpened()
# print camera.get(cv2.CAP_PROP_FOURCC)
# C = camera.get(cv2.CAP_PROP_FOURCC)
# print 'fourcc original:', decode_fourcc(C)
# codec = 0x47504A4D # MJPG
# codec = 844715353.0 # YUY2

codec = 1196444237.0 # MJPG
# print 'fourcc:', decode_fourcc(codec)

camera.set(cv2.CAP_PROP_FOURCC, codec)

camera.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
camera.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
camera.set(cv2.CAP_PROP_FPS, 30.0)

print camera.get(cv2.CAP_PROP_FRAME_WIDTH)
print camera.get(cv2.CAP_PROP_FRAME_HEIGHT)
print camera.get(cv2.CAP_PROP_FPS)
C = camera.get(cv2.CAP_PROP_FOURCC)
print 'fourcc:', decode_fourcc(C)

print
for i in xrange(38):
    print i, fourcc_names[i], camera.get(i)

while(1):
    camera.grab()
    retval, im = camera.retrieve(0)
    cv2.imshow("image", im)
    k = cv2.waitKey(1) &amp; 0xff
    if k == 27:
        break

camera.release()
cv2.destroyAllWindows()
</code></pre></div>
<h5 dir="auto">Output</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="3.1.0
Camera open: True
1280.0
720.0
30.00003
fourcc: YUY2

0 CAP_PROP_POS_MSEC -1.0
1 CAP_PROP_POS_FRAMES -1.0
2 CAP_PROP_POS_AVI_RATIO -1.0
3 CAP_PROP_FRAME_WIDTH 1280.0
4 CAP_PROP_FRAME_HEIGHT 720.0
5 CAP_PROP_FPS 30.00003
6 CAP_PROP_FOURCC 844715353.0
7 CAP_PROP_FRAME_COUNT -1.0
8 CAP_PROP_FORMAT -1.0
9 CAP_PROP_MODE -1.0
10 CAP_PROP_BRIGHTNESS 0.0
11 CAP_PROP_CONTRAST 32.0
12 CAP_PROP_SATURATION 64.0
13 CAP_PROP_HUE 0.0
14 CAP_PROP_GAIN 0.0
15 CAP_PROP_EXPOSURE -6.0
16 CAP_PROP_CONVERT_RGB -1.0
17 CAP_PROP_WHITE_BALANCE_BLUE_U 4600.0
18 CAP_PROP_RECTIFICATION -1.0
19 CAP_PROP_MONOCHROME 19.0
20 CAP_PROP_SHARPNESS 3.0
21 CAP_PROP_AUTO_EXPOSURE -1.0
22 CAP_PROP_GAMMA 100.0
23 CAP_PROP_TEMPERATURE -1.0
24 CAP_PROP_TRIGGER -1.0
25 CAP_PROP_TRIGGER_DELAY -1.0
26 CAP_PROP_WHITE_BALANCE_RED_V -1.0
27 CAP_PROP_ZOOM 27.0
28 CAP_PROP_FOCUS 28.0
29 CAP_PROP_GUID -1.0
30 CAP_PROP_ISO_SPEED -1.0
31 CAP_PROP_BACKLIGHT -1.0
32 CAP_PROP_PAN 1.0
33 CAP_PROP_TILT 33.0
34 CAP_PROP_ROLL 34.0
35 CAP_PROP_IRIS 35.0
36 CAP_PROP_SETTINGS 36.0
37 CAP_PROP_BUFFERSIZE -1.0"><pre class="notranslate"><code class="notranslate">3.1.0
Camera open: True
1280.0
720.0
30.00003
fourcc: YUY2

0 CAP_PROP_POS_MSEC -1.0
1 CAP_PROP_POS_FRAMES -1.0
2 CAP_PROP_POS_AVI_RATIO -1.0
3 CAP_PROP_FRAME_WIDTH 1280.0
4 CAP_PROP_FRAME_HEIGHT 720.0
5 CAP_PROP_FPS 30.00003
6 CAP_PROP_FOURCC 844715353.0
7 CAP_PROP_FRAME_COUNT -1.0
8 CAP_PROP_FORMAT -1.0
9 CAP_PROP_MODE -1.0
10 CAP_PROP_BRIGHTNESS 0.0
11 CAP_PROP_CONTRAST 32.0
12 CAP_PROP_SATURATION 64.0
13 CAP_PROP_HUE 0.0
14 CAP_PROP_GAIN 0.0
15 CAP_PROP_EXPOSURE -6.0
16 CAP_PROP_CONVERT_RGB -1.0
17 CAP_PROP_WHITE_BALANCE_BLUE_U 4600.0
18 CAP_PROP_RECTIFICATION -1.0
19 CAP_PROP_MONOCHROME 19.0
20 CAP_PROP_SHARPNESS 3.0
21 CAP_PROP_AUTO_EXPOSURE -1.0
22 CAP_PROP_GAMMA 100.0
23 CAP_PROP_TEMPERATURE -1.0
24 CAP_PROP_TRIGGER -1.0
25 CAP_PROP_TRIGGER_DELAY -1.0
26 CAP_PROP_WHITE_BALANCE_RED_V -1.0
27 CAP_PROP_ZOOM 27.0
28 CAP_PROP_FOCUS 28.0
29 CAP_PROP_GUID -1.0
30 CAP_PROP_ISO_SPEED -1.0
31 CAP_PROP_BACKLIGHT -1.0
32 CAP_PROP_PAN 1.0
33 CAP_PROP_TILT 33.0
34 CAP_PROP_ROLL 34.0
35 CAP_PROP_IRIS 35.0
36 CAP_PROP_SETTINGS 36.0
37 CAP_PROP_BUFFERSIZE -1.0
</code></pre></div>