Large update of videoio doc and samples following mshabunin comments
authorPkLab.net <github@pklab.net>
Wed, 24 Aug 2016 17:57:17 +0000 (19:57 +0200)
committerPkLab.net <github@pklab.net>
Fri, 9 Sep 2016 16:46:11 +0000 (18:46 +0200)
modules/core/doc/intro.markdown
modules/videoio/doc/pics/videoio_overview.svg [new file with mode: 0644]
modules/videoio/doc/videoio_overview.markdown [new file with mode: 0644]
modules/videoio/include/opencv2/videoio.hpp
modules/videoio/include/opencv2/videoio/videoio_c.h
samples/cpp/videocapture_basic.cpp [new file with mode: 0644]
samples/cpp/videocapture_starter.cpp [moved from samples/cpp/starter_video.cpp with 95% similarity]
samples/cpp/videowriter_basic.cpp [new file with mode: 0644]

index 964fb06..41d8078 100644 (file)
@@ -22,7 +22,7 @@ libraries. The following modules are available:
 -   **objdetect** - detection of objects and instances of the predefined classes (for example,
     faces, eyes, mugs, people, cars, and so on).
 -   **highgui** - an easy-to-use interface to simple UI capabilities.
--   **videoio** - an easy-to-use interface to video capturing and video codecs.
+-   @ref videoio - an easy-to-use interface to video capturing and video codecs.
 -   **gpu** - GPU-accelerated algorithms from different OpenCV modules.
 -   ... some other helper modules, such as FLANN and Google test wrappers, Python bindings, and
     others.
diff --git a/modules/videoio/doc/pics/videoio_overview.svg b/modules/videoio/doc/pics/videoio_overview.svg
new file mode 100644 (file)
index 0000000..f6b376e
--- /dev/null
@@ -0,0 +1,877 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="559.99994"
+   height="520"
+   viewBox="0 0 559.99993 520"
+   id="svg2"
+   version="1.1"
+   inkscape:version="0.91 r13725"
+   sodipodi:docname="opencv-videoio-structure.svg"
+   inkscape:export-filename="./opencv-videoio-structure.png"
+   inkscape:export-xdpi="90"
+   inkscape:export-ydpi="90">
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="1.3701928"
+     inkscape:cx="397.12938"
+     inkscape:cy="243.08432"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="true"
+     showguides="true"
+     inkscape:guide-bbox="true"
+     inkscape:snap-page="false"
+     inkscape:snap-bbox="true"
+     inkscape:bbox-nodes="true"
+     inkscape:snap-bbox-edge-midpoints="false"
+     inkscape:bbox-paths="false"
+     inkscape:object-nodes="true"
+     inkscape:snap-intersection-paths="true"
+     inkscape:snap-midpoints="true"
+     inkscape:object-paths="true"
+     inkscape:snap-object-midpoints="true"
+     inkscape:snap-bbox-midpoints="false"
+     inkscape:snap-center="true"
+     inkscape:snap-global="true"
+     inkscape:window-width="1920"
+     inkscape:window-height="1028"
+     inkscape:window-x="1912"
+     inkscape:window-y="-8"
+     inkscape:window-maximized="1"
+     inkscape:snap-nodes="false"
+     inkscape:snap-others="false"
+     inkscape:snap-grids="true"
+     fit-margin-top="10"
+     fit-margin-left="10"
+     fit-margin-right="10"
+     fit-margin-bottom="10"
+     units="px">
+    <inkscape:grid
+       originy="-179.99988"
+       originx="-1620"
+       visible="true"
+       empspacing="1"
+       spacingy="10"
+       spacingx="9.9999999"
+       dotted="false"
+       id="grid6826"
+       type="xygrid" />
+  </sodipodi:namedview>
+  <title
+     id="title7860">OpenCV video I/O Structure</title>
+  <defs
+     id="defs4" />
+  <metadata
+     id="metadata7">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title>OpenCV video I/O Structure</dc:title>
+        <cc:license
+           rdf:resource="http://creativecommons.org/licenses/by/3.0/" />
+        <dc:creator>
+          <cc:Agent>
+            <dc:title>PkLab.net</dc:title>
+          </cc:Agent>
+        </dc:creator>
+        <dc:language>English</dc:language>
+        <dc:subject>
+          <rdf:Bag>
+            <rdf:li>OpenCV</rdf:li>
+            <rdf:li>Video I/O</rdf:li>
+          </rdf:Bag>
+        </dc:subject>
+        <dc:description />
+      </cc:Work>
+      <cc:License
+         rdf:about="http://creativecommons.org/licenses/by/3.0/">
+        <cc:permits
+           rdf:resource="http://creativecommons.org/ns#Reproduction" />
+        <cc:permits
+           rdf:resource="http://creativecommons.org/ns#Distribution" />
+        <cc:requires
+           rdf:resource="http://creativecommons.org/ns#Notice" />
+        <cc:requires
+           rdf:resource="http://creativecommons.org/ns#Attribution" />
+        <cc:permits
+           rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
+      </cc:License>
+    </rdf:RDF>
+  </metadata>
+  <g
+     transform="translate(-1620.0001,-352.36227)"
+     id="layer1"
+     inkscape:groupmode="layer"
+     inkscape:label="Layer 1">
+    <rect
+       ry="10"
+       rx="10"
+       y="372.86224"
+       x="1640.5001"
+       height="79"
+       width="518.99982"
+       id="rect4136-9-7"
+       style="fill:#9aba59;fill-opacity:1;stroke:#6f00c7;stroke-width:1.00000012;stroke-miterlimit:4;stroke-dasharray:1.00000003, 1.00000003;stroke-dashoffset:0;stroke-opacity:1" />
+    <rect
+       ry="10"
+       rx="10"
+       y="402.86224"
+       x="1820.5001"
+       height="39"
+       width="99"
+       id="rect4615-2-7-5-2-1-4-4-6"
+       style="fill:#809f41;fill-opacity:1;stroke:#000000;stroke-width:0.99999994;stroke-miterlimit:4;stroke-dasharray:2.99999982, 2.99999982;stroke-dashoffset:0;stroke-opacity:1" />
+    <rect
+       ry="10"
+       rx="10"
+       y="772.86224"
+       x="1640.5001"
+       height="79"
+       width="519"
+       id="rect4136-8-5-3-3-3"
+       style="fill:#cccccc;fill-opacity:1;stroke:#6f00c7;stroke-width:0.99999994;stroke-miterlimit:4;stroke-dasharray:1.00000001, 1.00000001;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text5457-0-7-9"
+       y="792.29303"
+       x="1899.3917"
+       style="font-style:normal;font-weight:normal;font-size:15px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         style="font-size:15px"
+         y="792.29303"
+         x="1899.3917"
+         id="tspan5459-7-2-3"
+         sodipodi:role="line">MEDIA DEVICES</tspan></text>
+    <rect
+       ry="10"
+       rx="10"
+       y="682.86224"
+       x="1640.5001"
+       height="79"
+       width="519"
+       id="rect4136-8-5-3-8"
+       style="fill:#ffb380;fill-opacity:1;stroke:#6f00c7;stroke-width:0.99999994;stroke-miterlimit:4;stroke-dasharray:1.00000003, 1.00000003;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text5457-0-6"
+       y="702.27844"
+       x="1899.941"
+       style="font-style:normal;font-weight:normal;font-size:15px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         style="font-size:15px"
+         y="702.27844"
+         x="1899.941"
+         id="tspan5459-7-3"
+         sodipodi:role="line">SYSTEM</tspan></text>
+    <text
+       xml:space="preserve"
+       style="font-style:normal;font-weight:normal;font-size:17.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="1330.3986"
+       y="308.75192"
+       id="text5748"
+       sodipodi:linespacing="125%"><tspan
+         sodipodi:role="line"
+         id="tspan5750"
+         x="1330.3986"
+         y="308.75192" /></text>
+    <text
+       xml:space="preserve"
+       style="font-style:normal;font-weight:normal;font-size:17.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="1330.3986"
+       y="308.75192"
+       id="text5752"
+       sodipodi:linespacing="125%"><tspan
+         sodipodi:role="line"
+         id="tspan5754"
+         x="1330.3986"
+         y="308.75192" /></text>
+    <text
+       xml:space="preserve"
+       style="font-style:normal;font-weight:normal;font-size:17.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="1490.257"
+       y="308.75192"
+       id="text5748-3"
+       sodipodi:linespacing="125%"><tspan
+         sodipodi:role="line"
+         id="tspan5750-9"
+         x="1490.257"
+         y="308.75192" /></text>
+    <text
+       xml:space="preserve"
+       style="font-style:normal;font-weight:normal;font-size:17.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="1490.257"
+       y="308.75192"
+       id="text5752-1"
+       sodipodi:linespacing="125%"><tspan
+         sodipodi:role="line"
+         id="tspan5754-8"
+         x="1490.257"
+         y="308.75192" /></text>
+    <text
+       xml:space="preserve"
+       style="font-style:normal;font-weight:normal;font-size:17.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="1170.5402"
+       y="308.75192"
+       id="text5748-3-9"
+       sodipodi:linespacing="125%"><tspan
+         sodipodi:role="line"
+         id="tspan5750-9-4"
+         x="1170.5402"
+         y="308.75192" /></text>
+    <text
+       xml:space="preserve"
+       style="font-style:normal;font-weight:normal;font-size:17.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       x="1170.5402"
+       y="308.75192"
+       id="text5752-1-5"
+       sodipodi:linespacing="125%"><tspan
+         sodipodi:role="line"
+         id="tspan5754-8-4"
+         x="1170.5402"
+         y="308.75192" /></text>
+    <text
+       transform="scale(0.96032163,1.0413178)"
+       sodipodi:linespacing="125%"
+       id="text4165-3-0"
+       y="376.56689"
+       x="1978.5697"
+       style="font-style:normal;font-weight:normal;font-size:15px;line-height:125%;font-family:Verdana;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         y="376.56689"
+         x="1978.5697"
+         id="tspan4167-5-0"
+         sodipodi:role="line"
+         style="font-size:15px;text-align:center;text-anchor:middle">USER APPLICATION</tspan></text>
+    <rect
+       ry="10"
+       rx="10"
+       y="462.86221"
+       x="1820.5001"
+       height="209"
+       width="339"
+       id="rect4136-8-4-82-8"
+       style="fill:#80b3ff;fill-opacity:1;stroke:#6f00c7;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:0.99999996, 0.99999996;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4577-6-1"
+       y="478.42764"
+       x="2061.6013"
+       style="font-style:normal;font-weight:normal;font-size:15px;line-height:125%;font-family:Verdana;text-align:end;letter-spacing:0px;word-spacing:0px;text-anchor:end;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         style="font-size:15px"
+         id="tspan4581-0-0"
+         y="478.42764"
+         x="2061.6013"
+         sodipodi:role="line">OpenCV Video I/O</tspan></text>
+    <path
+       inkscape:connector-curvature="0"
+       id="path4789-4-4"
+       d="m 1820.0815,567.77306 340,0"
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.99999994;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:1.99999991, 0.99999995;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       transform="scale(1.0001622,0.99983783)"
+       sodipodi:linespacing="125%"
+       id="text4577-9-3-2"
+       y="581.95209"
+       x="1990.1963"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         id="tspan4581-2-5-1"
+         y="581.95209"
+         x="1990.1963"
+         sodipodi:role="line">OpenCV Video I/O API Backends</tspan></text>
+    <rect
+       ry="5"
+       rx="5"
+       y="592.86224"
+       x="1913.8334"
+       height="29.000002"
+       width="69"
+       id="rect4615-4-6-4"
+       style="fill:#999999;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-9-4"
+       y="612.11469"
+       x="1947.6696"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="612.11469"
+         x="1947.6696"
+         id="tspan4365-0-2"
+         sodipodi:role="line">DShow</tspan></text>
+    <rect
+       ry="5"
+       rx="5"
+       y="592.86224"
+       x="2080.5"
+       height="29.000002"
+       width="69"
+       id="rect4615-5-7-0"
+       style="fill:#999999;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-6-1-4"
+       y="612.00482"
+       x="2114.123"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="612.00482"
+         x="2114.123"
+         id="tspan4365-8-0-4"
+         sodipodi:role="line">MSMF</tspan></text>
+    <rect
+       ry="5"
+       rx="5"
+       y="592.86224"
+       x="1830.5001"
+       height="29"
+       width="69"
+       id="rect4615-11-0"
+       style="fill:#999999;fill-opacity:1;stroke:#000000;stroke-width:0.99999994;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       transform="scale(1.0001622,0.99983783)"
+       sodipodi:linespacing="125%"
+       id="text4363-5-6-4"
+       y="611.99872"
+       x="1864.5328"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         y="611.99872"
+         x="1864.5328"
+         id="tspan4365-6-9-6"
+         sodipodi:role="line">FFMPEG</tspan></text>
+    <rect
+       ry="5"
+       rx="5"
+       y="632.79645"
+       x="1913.8334"
+       height="29"
+       width="69"
+       id="rect4615-94-7-1"
+       style="fill:#999999;fill-opacity:1;stroke:#000000;stroke-width:0.99999988;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-4-8-8"
+       y="651.9455"
+       x="1947.932"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="651.9455"
+         x="1947.932"
+         id="tspan4365-7-09-1"
+         sodipodi:role="line">V4L</tspan></text>
+    <rect
+       ry="5"
+       rx="5"
+       y="592.86224"
+       x="1997.1666"
+       height="29.000002"
+       width="69"
+       id="rect4615-9-6-4"
+       style="fill:#999999;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-7-5-3"
+       y="612.00482"
+       x="2031.5355"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="612.00482"
+         x="2031.5355"
+         id="tspan4365-9-0-9"
+         sodipodi:role="line">VFW</tspan></text>
+    <rect
+       ry="5"
+       rx="5"
+       y="632.79645"
+       x="1830.5001"
+       height="29"
+       width="69"
+       id="rect4615-0-7-6"
+       style="fill:#999999;fill-opacity:1;stroke:#000000;stroke-width:0.99999988;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-4-6-1-7"
+       y="651.22223"
+       x="1864.9784"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="651.22223"
+         x="1864.9784"
+         id="tspan4365-7-0-4-1"
+         sodipodi:role="line">AVF/IOS</tspan></text>
+    <rect
+       ry="5"
+       rx="5"
+       y="632.79645"
+       x="2080.5"
+       height="29"
+       width="69"
+       id="rect4615-1-2-1"
+       style="fill:#999999;fill-opacity:1;stroke:#000000;stroke-width:0.99999988;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-4-6-7-6-2"
+       y="651.71051"
+       x="2115.1025"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="651.71051"
+         x="2115.1025"
+         id="tspan4365-7-0-1-8-6"
+         sodipodi:role="line">etc...</tspan></text>
+    <rect
+       ry="5"
+       rx="5"
+       y="632.79645"
+       x="1997.1666"
+       height="29"
+       width="69"
+       id="rect4615-6-6-4"
+       style="fill:#999999;fill-opacity:1;stroke:#000000;stroke-width:0.99999988;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4409-2-7"
+       y="651.9455"
+       x="2031.4104"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="651.9455"
+         x="2031.4104"
+         id="tspan4411-9-8"
+         sodipodi:role="line">OPENNI</tspan></text>
+    <rect
+       ry="10"
+       rx="10"
+       y="462.86221"
+       x="1640.5001"
+       height="209"
+       width="169"
+       id="rect4136-8-4-8-3-9"
+       style="fill:#e9afaf;fill-opacity:1;stroke:#6f00c7;stroke-width:0.99999964;stroke-miterlimit:4;stroke-dasharray:1.00000002, 1.00000002;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       transform="scale(1.0001622,0.99983783)"
+       sodipodi:linespacing="125%"
+       id="text4577-8-4-3"
+       y="479.85953"
+       x="1723.9659"
+       style="font-style:normal;font-weight:normal;font-size:15px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         style="font-size:15px;text-align:center;text-anchor:middle"
+         id="tspan4581-5-1-7"
+         y="479.85953"
+         x="1723.9659"
+         sodipodi:role="line">Manufacturer Driver</tspan></text>
+    <rect
+       ry="10"
+       rx="10"
+       y="557.86224"
+       x="1650.5001"
+       height="39"
+       width="149"
+       id="rect4615-2-7-1-9"
+       style="fill:#d35f5f;fill-opacity:1;stroke:#000000;stroke-width:0.99999982;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-5-2-2-8-9"
+       y="581.27667"
+       x="1724.7936"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="581.27667"
+         x="1724.7936"
+         id="tspan4365-6-3-6-7-2"
+         sodipodi:role="line">C / C++ / JAVA API</tspan></text>
+    <rect
+       ry="10"
+       rx="10"
+       y="402.86224"
+       x="1665.5001"
+       height="39"
+       width="119"
+       id="rect4615-2-7-5-2-0"
+       style="fill:#809f41;fill-opacity:1;stroke:#000000;stroke-width:0.99999994;stroke-miterlimit:4;stroke-dasharray:2.99999982, 2.99999982;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-5-2-2-7-3-4"
+       y="419.3027"
+       x="1724.9401"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="419.3027"
+         x="1724.9401"
+         id="tspan4365-6-3-6-2-2-2"
+         sodipodi:role="line"
+         style="font-size:12.5px;text-align:center;text-anchor:middle">cv::Mat from</tspan><tspan
+         y="434.9277"
+         x="1724.9401"
+         sodipodi:role="line"
+         id="tspan5401-7-0"
+         style="font-size:12.5px;text-align:center;text-anchor:middle">buffer</tspan></text>
+    <rect
+       ry="10"
+       rx="10"
+       y="712.86224"
+       x="1650.5001"
+       height="39"
+       width="149"
+       id="rect4615-2-7-0-6-8"
+       style="fill:#d35f5f;fill-opacity:1;stroke:#000000;stroke-width:0.99999994;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-5-2-2-6-5-7"
+       y="728.19025"
+       x="1724.0917"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="728.19025"
+         x="1724.0917"
+         id="tspan4365-6-3-6-6-1-0"
+         sodipodi:role="line"
+         style="font-size:12.5px;text-align:center;text-anchor:middle">Manufacturer</tspan><tspan
+         y="743.81525"
+         x="1724.0917"
+         sodipodi:role="line"
+         id="tspan5372-4-1">Library</tspan></text>
+    <rect
+       ry="10"
+       rx="10"
+       y="712.86224"
+       x="1825.5001"
+       height="39"
+       width="99"
+       id="rect4615-2-7-0-2-8-7"
+       style="fill:#c87137;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-5-2-2-6-7-2-5"
+       y="729.32245"
+       x="1874.3451"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="729.32245"
+         x="1874.3451"
+         id="tspan4365-6-3-6-6-8-7-6"
+         sodipodi:role="line"
+         style="font-size:12.5px;text-align:center;text-anchor:middle;fill:#ffffff">Backends</tspan><tspan
+         y="744.94745"
+         x="1874.3451"
+         sodipodi:role="line"
+         id="tspan5372-3-26-8">Libraries</tspan></text>
+    <rect
+       ry="10"
+       rx="10"
+       y="712.86224"
+       x="2050.5"
+       height="39"
+       width="99.000038"
+       id="rect4615-2-7-0-2-5-1-6"
+       style="fill:#c87137;fill-opacity:1;stroke:#000000;stroke-width:0.99999994;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-5-2-2-6-7-1-6-4"
+       y="729.21259"
+       x="2099.3086"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="729.21259"
+         x="2099.3086"
+         id="tspan4365-6-3-6-6-8-6-5-6"
+         sodipodi:role="line"
+         style="font-size:12.5px;text-align:center;text-anchor:middle;fill:#ffffff">O.S.</tspan><tspan
+         y="744.83759"
+         x="2099.3086"
+         sodipodi:role="line"
+         id="tspan5372-3-2-4-8">Libraries</tspan></text>
+    <rect
+       ry="10"
+       rx="10"
+       y="402.86224"
+       x="1935.5"
+       height="39"
+       width="99"
+       id="rect4615-2-7-5-2-1-2"
+       style="fill:#809f41;fill-opacity:1;stroke:#000000;stroke-width:0.99999994;stroke-miterlimit:4;stroke-dasharray:2.99999982, 2.99999982;stroke-dashoffset:0;stroke-opacity:1" />
+    <rect
+       ry="10"
+       rx="10"
+       y="402.86224"
+       x="2050.5"
+       height="39"
+       width="99"
+       id="rect4615-2-7-5-2-1-4-8"
+       style="fill:#809f41;fill-opacity:1;stroke:#000000;stroke-width:0.99999994;stroke-miterlimit:4;stroke-dasharray:2.99999982, 2.99999982;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-5-2-2-7-3-0-1-3"
+       y="423.06659"
+       x="1961.3533"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0118989,0.98824102)"><tspan
+         y="423.06659"
+         x="1961.3533"
+         id="tspan4365-6-3-6-2-2-1-7-5"
+         sodipodi:role="line"
+         style="font-size:12.5px;text-align:center;text-anchor:middle">set / get</tspan><tspan
+         y="438.69159"
+         x="1961.3533"
+         sodipodi:role="line"
+         id="tspan5401-7-6-4-7"
+         style="font-size:12.5px;text-align:center;text-anchor:middle">properties</tspan></text>
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-5-2-2-7-3-0-1-4-5"
+       y="419.27219"
+       x="2099.635"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="419.27219"
+         x="2099.635"
+         id="tspan4365-6-3-6-2-2-1-7-4-3"
+         sodipodi:role="line"
+         style="font-size:12.5px;text-align:center;text-anchor:middle">grab / write</tspan><tspan
+         y="434.89719"
+         x="2099.635"
+         sodipodi:role="line"
+         id="tspan5401-7-6-4-3-2"
+         style="font-size:12.5px;text-align:center;text-anchor:middle">frame</tspan></text>
+    <rect
+       ry="10"
+       rx="10"
+       y="802.86224"
+       x="1650.5001"
+       height="39"
+       width="149"
+       id="rect4615-2-7-0-6-6-5"
+       style="fill:#4d4d4d;fill-opacity:1;stroke:#000000;stroke-width:0.99999994;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-5-2-2-6-5-2-08"
+       y="827.02747"
+       x="1724.9156"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="827.02747"
+         x="1724.9156"
+         sodipodi:role="line"
+         id="tspan5372-4-2-73">Camera</tspan></text>
+    <rect
+       ry="10"
+       rx="10"
+       y="802.86224"
+       x="1825.5001"
+       height="39"
+       width="149"
+       id="rect4615-2-7-0-6-6-4-6"
+       style="fill:#4d4d4d;fill-opacity:1;stroke:#000000;stroke-width:0.99999994;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-5-2-2-6-5-2-0-1"
+       y="827.14954"
+       x="1899.9178"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="827.14954"
+         x="1899.9178"
+         sodipodi:role="line"
+         id="tspan5372-4-2-7-0">Video File</tspan></text>
+    <rect
+       ry="10"
+       rx="10"
+       y="802.86224"
+       x="2000.5001"
+       height="39"
+       width="149"
+       id="rect4615-2-7-0-6-6-6-6"
+       style="fill:#4d4d4d;fill-opacity:1;stroke:#000000;stroke-width:0.99999994;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-5-2-2-6-5-2-03-1"
+       y="827.14954"
+       x="2074.5935"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="827.14954"
+         x="2074.5935"
+         sodipodi:role="line"
+         id="tspan5372-4-2-6-7">Network Stream</tspan></text>
+    <rect
+       style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+       id="rect8223"
+       width="538.99994"
+       height="499.00003"
+       x="1630.5001"
+       y="362.86227"
+       rx="10"
+       ry="10" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-5-2-2-7-3-0-2"
+       y="419.27219"
+       x="1869.9166"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="419.27219"
+         x="1869.9166"
+         id="tspan4365-6-3-6-2-2-1-2"
+         sodipodi:role="line"
+         style="font-size:12.5px;text-align:center;text-anchor:middle">create / open</tspan><tspan
+         y="434.89719"
+         x="1869.9166"
+         sodipodi:role="line"
+         id="tspan5401-7-6-8"
+         style="font-size:12.5px;text-align:center;text-anchor:middle">device</tspan></text>
+    <rect
+       ry="10"
+       rx="10"
+       y="712.86224"
+       x="1938"
+       height="39"
+       width="99"
+       id="rect4615-2-7-0-2-8-7-8"
+       style="fill:#c87137;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-5-2-2-6-7-2-5-2"
+       y="729.32245"
+       x="1986.8268"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="729.32245"
+         x="1986.8268"
+         sodipodi:role="line"
+         id="tspan5372-3-26-8-5">CODECS</tspan><tspan
+         y="744.94745"
+         x="1986.8268"
+         sodipodi:role="line"
+         id="tspan4295">(fourcc)</tspan></text>
+    <rect
+       ry="10"
+       rx="9.3800001"
+       y="507.86713"
+       x="1841.6537"
+       height="43.995113"
+       width="90.999962"
+       id="rect4615-2-8-4-2"
+       style="fill:#6b98c9;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:1, 1;stroke-dashoffset:0;stroke-opacity:1" />
+    <rect
+       ry="10"
+       rx="9.3800011"
+       y="507.86713"
+       x="1945.6538"
+       height="43.995113"
+       width="198.99985"
+       id="rect4615-2-8-4-2-4"
+       style="fill:#6b98c9;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:1, 1;stroke-dashoffset:0;stroke-opacity:1" />
+    <rect
+       ry="10"
+       rx="9.3800001"
+       y="483.86713"
+       x="1833.6537"
+       height="29"
+       width="149"
+       id="rect4615-2-8-4"
+       style="fill:#4d82be;fill-opacity:1;stroke:#000000;stroke-width:0.99999988;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-5-2-3-3"
+       y="501.93918"
+       x="1908.0701"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="501.93918"
+         x="1908.0701"
+         id="tspan4365-6-3-90-7"
+         sodipodi:role="line">VideoCapture</tspan></text>
+    <rect
+       ry="10"
+       rx="9.3800001"
+       y="483.86713"
+       x="2003.6537"
+       height="29"
+       width="149"
+       id="rect4615-2-9-5-7"
+       style="fill:#4d82be;fill-opacity:1;stroke:#000000;stroke-width:0.99999982;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-5-2-8-1-8"
+       y="503.1019"
+       x="2077.719"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="503.1019"
+         x="2077.719"
+         id="tspan4365-6-3-9-0-6"
+         sodipodi:role="line">VideoWriter</tspan></text>
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-5-2-3-3-4"
+       y="534.48248"
+       x="1887.043"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="534.48248"
+         x="1887.043"
+         id="tspan4365-6-3-90-7-2"
+         sodipodi:role="line">Camera</tspan></text>
+    <text
+       sodipodi:linespacing="125%"
+       id="text4363-5-2-3-3-6"
+       y="526.79205"
+       x="2044.752"
+       style="font-style:normal;font-weight:normal;font-size:12.5px;line-height:125%;font-family:Verdana;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"
+       transform="scale(1.0001622,0.99983783)"><tspan
+         y="526.79205"
+         x="2044.752"
+         sodipodi:role="line"
+         id="tspan4367">File or URL stream</tspan><tspan
+         y="542.41705"
+         x="2044.752"
+         sodipodi:role="line"
+         id="tspan4371">+ fourcc codec</tspan></text>
+  </g>
+</svg>
diff --git a/modules/videoio/doc/videoio_overview.markdown b/modules/videoio/doc/videoio_overview.markdown
new file mode 100644 (file)
index 0000000..b96d060
--- /dev/null
@@ -0,0 +1,94 @@
+Video I/O with OpenCV Overview {#videoio_overview}
+===================================
+
+### See also:
+  - @ref videoio "Video I/O Code Reference"
+  - Tutorials: @ref tutorial_table_of_content_videoio
+
+General Information
+===================
+
+The OpenCV @ref videoio module is a set of classes and functions to read and write video or images sequence.
+
+Basically, the module provides the cv::VideoCapture and cv::VideoWriter classes as 2-layer interface to many video
+I/O APIs used as backend.
+
+![Video I/O with OpenCV](pics/videoio_overview.svg)
+
+Some backends such as (DSHOW) Direct Show, Video For Windows (VFW), Microsoft Media Foundation (MSMF),
+Video 4 Linux (V4L), etc... are interfaces to the video I/O library provided by the operating system.
+
+Some others backends like OpenNI2 for Kinect, Intel Perceptual Computing SDK, GStreamer,
+XIMEA Camera API, etc...  are interfaces to proprietary drivers or to external library.
+
+See the list of supported backends here: cv::VideoCaptureAPIs
+
+@warning Some backends are experimental use them at your own risk
+@note Each backend supports devices properties (cv::VideoCaptureProperties) in a different way or might not support any property at all.
+
+
+Select the backend at runtime
+-----------------------------
+
+OpenCV automatically selects and uses first available backend (`apiPreference=cv::CAP_ANY`).
+
+As advanced usage you can select the backend to use at runtime. Currently this option is
+available only with %VideoCapture.
+
+For example to grab from default camera using Direct Show as backend
+
+```cpp
+//declare a capture object
+cv::VideoCapture cap(0 + cv::CAP_DSHOW);
+
+//or specify the apiPreference with open
+cap.open(0 + cv::CAP_DSHOW);
+```
+
+If you want to grab from a file using the Direct Show as backend:
+
+```cpp
+//declare a capture object
+cv::VideoCapture cap(filename, cv::CAP_DSHOW);
+
+//or specify the apiPreference with open
+cap.open(filename, cv::CAP_DSHOW);
+```
+
+@sa cv::VideoCapture::open() , cv::VideoCapture::VideoCapture()
+
+#### Enable backends
+
+Backends are available only if they have been built with your OpenCV binaries.
+
+Check in `opencv2/cvconfig.h` to know which APIs are currently available
+(e.g. `HAVE_MSMF, HAVE_VFW, HAVE_LIBV4L`, etc...).
+
+To enable/disable APIs, you have to:
+  1. re-configure OpenCV using appropriates CMake switches
+     (e.g. `-DWITH_MSMF=ON -DWITH_VFW=ON ... `) or checking related switch in cmake-gui
+  2. rebuild OpenCV itself
+
+#### Use 3rd party drivers or cameras
+
+Many industrial cameras or some video I/O devices don't provide standard driver interfaces
+for the operating system. Thus you can't use  VideoCapture or VideoWriter with these devices.
+
+To get access to their devices, manufactures provide their own C++ API and library that you have to
+include and link with your OpenCV application.
+
+Is common case that this libraries read/write images from/to a memory buffer. If it so, it is
+possible to make a `Mat` header for memory buffer (user-allocated data) and process it
+in-place using OpenCV functions. See cv::Mat::Mat() for more details.
+
+The FFmpeg library
+------------------
+
+OpenCV can use the FFmpeg library (http://ffmpeg.org/) as backend to record, convert and stream audio and video.
+FFMpeg is a complete, cross-reference solution. If you enable FFmpeg while configuring OpenCV than
+CMake will download and install the binaries in `OPENCV_SOURCE_CODE/3rdparty/ffmpeg/`. To use
+FFMpeg at runtime, you must deploy the FFMepg binaries with your application.
+
+@note FFmpeg is licensed under the GNU Lesser General Public License (LGPL) version 2.1 or later.
+See `OPENCV_SOURCE_CODE/3rdparty/ffmpeg/readme.txt` and http://ffmpeg.org/legal.html for details and
+licensing information
index b769163..122f849 100644 (file)
 #include "opencv2/core.hpp"
 
 /**
-  @defgroup videoio Media I/O
+  @defgroup videoio Video I/O
+
+  @brief Read and write video or images sequence with OpenCV
+
+  ### See also:
+  - @ref videoio_overview
+  - Tutorials: @ref tutorial_table_of_content_videoio
   @{
     @defgroup videoio_flags_base Flags for video I/O
     @defgroup videoio_flags_others Additional flags for video I/O API backends
-    @defgroup videoio_c C API
-    @defgroup videoio_ios iOS glue
-    @defgroup videoio_winrt WinRT glue
+    @defgroup videoio_c C API for video I/O
+    @defgroup videoio_ios iOS glue for video I/O
+    @defgroup videoio_winrt WinRT glue for video I/O
   @}
 */
 
@@ -69,20 +75,18 @@ namespace cv
 
 //! @addtogroup videoio_flags_base
 //! @{
-/** @brief Capture API backends.
+
+
+/** @brief %VideoCapture API backends identifier.
 
 Select preferred API for a capture object.
-To be used in the constructor VideoCapture::VideoCapture or VideoCapture::open
-
-@note Backends are available only if they have been built with your OpenCV binaries.<br>
-Check in <tt>cvconfig.h</tt> to know which APIs are currently available (e.g. <tt>HAVE_MSMF, HAVE_VFW, HAVE_LIBV4L</tt>).
-To enable/disable APIs, you have to:
-  1. re-configure OpenCV using the appropriates CMake switches
-     (e.g. <tt>-DWITH_MSMF=ON -DWITH_VFW=ON ... </tt>) or checking related switch in cmake-gui
-  2. rebuild OpenCV itself
+To be used in the VideoCapture::VideoCapture() constructor or VideoCapture::open()
+
+@note Backends are available only if they have been built with your OpenCV binaries.
+See @ref videoio_overview for more information.
 */
 enum VideoCaptureAPIs {
-       CAP_ANY          = 0,            //!< Auto detect
+       CAP_ANY          = 0,            //!< Auto detect == 0
        CAP_VFW          = 200,          //!< Video For Windows (platform native)
        CAP_V4L          = 200,          //!< V4L/V4L2 capturing support via libv4l
        CAP_V4L2         = CAP_V4L,      //!< Same as CAP_V4L
@@ -108,11 +112,13 @@ enum VideoCaptureAPIs {
        CAP_OPENNI2_ASUS = 1610,         //!< OpenNI2 (for Asus Xtion and Occipital Structure sensors)
        CAP_GPHOTO2      = 1700,         //!< gPhoto2 connection
        CAP_GSTREAMER    = 1800,         //!< GStreamer
-       CAP_FFMPEG       = 1900,         //!< FFMPEG
+       CAP_FFMPEG       = 1900,         //!< Open and record video file or stream using the FFMPEG library
        CAP_IMAGES       = 2000          //!< OpenCV Image Sequence (e.g. img_%02d.jpg)
      };
 
-//! generic properties (based on DC1394 properties)
+/** @brief %VideoCapture generic properties identifier.
+ @sa videoio_flags_others, VideoCapture::get(), VideoCapture::set()
+*/
 enum VideoCaptureProperties {
        CAP_PROP_POS_MSEC       =0, //!< Current position of the video file in milliseconds.
        CAP_PROP_POS_FRAMES     =1, //!< 0-based index of the frame to be decoded/captured next.
@@ -150,13 +156,15 @@ enum VideoCaptureProperties {
        CAP_PROP_TILT          =34,
        CAP_PROP_ROLL          =35,
        CAP_PROP_IRIS          =36,
-       CAP_PROP_SETTINGS      =37,
+       CAP_PROP_SETTINGS      =37, //! Pop up video/camera filter dialog (note: only supported by DSHOW backend currently. Property value is ignored)
        CAP_PROP_BUFFERSIZE    =38,
        CAP_PROP_AUTOFOCUS     =39
      };
 
-//! @brief Generic camera output modes.
-//! @note Currently, these are supported through the libv4l interface only.
+
+/** @brief Generic camera output modes identifier.
+@note Currently, these are supported through the libv4l backend only.
+*/
 enum VideoCaptureModes {
        CAP_MODE_BGR  = 0, //!< BGR24 (default)
        CAP_MODE_RGB  = 1, //!< RGB24
@@ -164,7 +172,8 @@ enum VideoCaptureModes {
        CAP_MODE_YUYV = 3  //!< YUYV
      };
 
-/** @brief Generic properties identifier for VideoWriter
+/** @brief %VideoWriter generic properties identifier.
+ @sa VideoWriter::get(), VideoWriter::set()
 */
 enum VideoWriterProperties {
   VIDEOWRITER_PROP_QUALITY = 1,    //!< Current quality (0..100%) of the encoded videostream. Can be adjusted dynamically in some codecs.
@@ -177,9 +186,12 @@ enum VideoWriterProperties {
 //! @addtogroup videoio_flags_others
 //! @{
 
-/** @brief DC1394 only
+/** @name IEEE 1394 drivers
+    @{
+*/
 
-modes of the controlling registers (can be: auto, manual, auto single push, absolute Latter allowed with any other mode)
+/** @brief Modes of the IEEE 1394 controlling registers
+(can be: auto, manual, auto single push, absolute Latter allowed with any other mode)
 every feature can have only one mode turned on at a time
 */
 enum { CAP_PROP_DC1394_OFF                = -4, //!< turn the feature off (not controlled manually nor automatically).
@@ -189,6 +201,11 @@ enum { CAP_PROP_DC1394_OFF                = -4, //!< turn the feature off (not c
        CAP_PROP_DC1394_MAX                = 31
      };
 
+//! @} IEEE 1394 drivers
+
+/** @name OpenNI (for Kinect)
+    @{
+*/
 
 //! OpenNI map generators
 enum { CAP_OPENNI_DEPTH_GENERATOR = 1 << 31,
@@ -197,7 +214,7 @@ enum { CAP_OPENNI_DEPTH_GENERATOR = 1 << 31,
        CAP_OPENNI_GENERATORS_MASK = CAP_OPENNI_DEPTH_GENERATOR + CAP_OPENNI_IMAGE_GENERATOR + CAP_OPENNI_IR_GENERATOR
      };
 
-//! Properties of cameras available through OpenNI interfaces
+//! Properties of cameras available through OpenNI backend
 enum { CAP_PROP_OPENNI_OUTPUT_MODE       = 100,
        CAP_PROP_OPENNI_FRAME_MAX_DEPTH   = 101, //!< In mm
        CAP_PROP_OPENNI_BASELINE          = 102, //!< In mm
@@ -247,11 +264,20 @@ enum { CAP_OPENNI_VGA_30HZ  = 0,
        CAP_OPENNI_QVGA_60HZ = 4
      };
 
+//! @} OpenNI
+
+/** @name GStreamer
+    @{
+*/
 
-//! GStreamer
 enum { CAP_PROP_GSTREAMER_QUEUE_LENGTH = 200 //!< Default is 1
      };
 
+//! @} GStreamer
+
+/** @name PvAPI, Prosilica GigE SDK
+    @{
+*/
 
 //! PVAPI
 enum { CAP_PROP_PVAPI_MULTICASTIP           = 300, //!< IP for enable multicast master mode. 0 for disable multicast.
@@ -289,7 +315,13 @@ enum { CAP_PVAPI_PIXELFORMAT_MONO8    = 1,    //!< Mono8
        CAP_PVAPI_PIXELFORMAT_BGRA32   = 8,    //!< Bgra32
      };
 
-//! Properties of cameras available through XIMEA SDK interface
+//! @} PvAPI
+
+/** @name XIMEA Camera API
+    @{
+*/
+
+//! Properties of cameras available through XIMEA SDK backend
 enum { CAP_PROP_XI_DOWNSAMPLING                                 = 400, //!< Change image resolution by binning or skipping.
        CAP_PROP_XI_DATA_FORMAT                                  = 401, //!< Output data format.
        CAP_PROP_XI_OFFSET_X                                     = 402, //!< Horizontal offset from the origin to the area of interest (in pixels).
@@ -392,8 +424,8 @@ enum { CAP_PROP_XI_DOWNSAMPLING                                 = 400, //!< Chan
        CAP_PROP_XI_LENS_FOCAL_LENGTH                            = 516, //!< Lens focal distance in mm.
        CAP_PROP_XI_LENS_FEATURE_SELECTOR                        = 517, //!< Selects the current feature which is accessible by XI_PRM_LENS_FEATURE.
        CAP_PROP_XI_LENS_FEATURE                                 = 518, //!< Allows access to lens feature value currently selected by XI_PRM_LENS_FEATURE_SELECTOR.
-       CAP_PROP_XI_DEVICE_MODEL_ID                              = 521, //!< Return device model id.
-       CAP_PROP_XI_DEVICE_SN                                    = 522, //!< Return device serial number.
+       CAP_PROP_XI_DEVICE_MODEL_ID                              = 521, //!< Returns device model id.
+       CAP_PROP_XI_DEVICE_SN                                    = 522, //!< Returns device serial number.
        CAP_PROP_XI_IMAGE_DATA_FORMAT_RGB32_ALPHA                = 529, //!< The alpha channel of RGB32 output image format.
        CAP_PROP_XI_IMAGE_PAYLOAD_SIZE                           = 530, //!< Buffer size in bytes sufficient for output image returned by xiGetImage.
        CAP_PROP_XI_TRANSPORT_PIXEL_FORMAT                       = 531, //!< Current format of pixels on transport layer.
@@ -404,7 +436,7 @@ enum { CAP_PROP_XI_DOWNSAMPLING                                 = 400, //!< Chan
        CAP_PROP_XI_COUNTER_SELECTOR                             = 536, //!< Select counter.
        CAP_PROP_XI_COUNTER_VALUE                                = 537, //!< Counter status.
        CAP_PROP_XI_ACQ_TIMING_MODE                              = 538, //!< Type of sensor frames timing.
-       CAP_PROP_XI_AVAILABLE_BANDWIDTH                          = 539, //!< Calculate and return available interface bandwidth(int Megabits).
+       CAP_PROP_XI_AVAILABLE_BANDWIDTH                          = 539, //!< Calculate and returns available interface bandwidth(int Megabits).
        CAP_PROP_XI_BUFFER_POLICY                                = 540, //!< Data move policy.
        CAP_PROP_XI_LUT_EN                                       = 541, //!< Activates LUT.
        CAP_PROP_XI_LUT_INDEX                                    = 542, //!< Control the index (offset) of the coefficient to access in the LUT.
@@ -442,8 +474,14 @@ enum { CAP_PROP_XI_DOWNSAMPLING                                 = 400, //!< Chan
        CAP_PROP_XI_SENSOR_FEATURE_VALUE                         = 586, //!< Allows access to sensor feature value currently selected by XI_PRM_SENSOR_FEATURE_SELECTOR.
      };
 
+//! @} XIMEA
+
+/** @name AVFoundation framework for iOS
+    OS X Lion will have the same API
+    @{
+*/
 
-//! Properties of cameras available through AVFOUNDATION interface
+//! Properties of cameras available through AVFOUNDATION backend
 enum { CAP_PROP_IOS_DEVICE_FOCUS        = 9001,
        CAP_PROP_IOS_DEVICE_EXPOSURE     = 9002,
        CAP_PROP_IOS_DEVICE_FLASH        = 9003,
@@ -451,8 +489,11 @@ enum { CAP_PROP_IOS_DEVICE_FOCUS        = 9001,
        CAP_PROP_IOS_DEVICE_TORCH        = 9005
      };
 
+/** @name Smartek Giganetix GigEVisionSDK
+    @{
+*/
 
-//! Properties of cameras available through Smartek Giganetix Ethernet Vision interface
+//! Properties of cameras available through Smartek Giganetix Ethernet Vision backend
 /* --- Vladimir Litvinenko (litvinenko.vladimir@gmail.com) --- */
 enum { CAP_PROP_GIGA_FRAME_OFFSET_X   = 10001,
        CAP_PROP_GIGA_FRAME_OFFSET_Y   = 10002,
@@ -462,6 +503,11 @@ enum { CAP_PROP_GIGA_FRAME_OFFSET_X   = 10001,
        CAP_PROP_GIGA_FRAME_SENS_HEIGH = 10006
      };
 
+//! @} Smartek
+
+/** @name Intel Perceptual Computing SDK
+    @{
+*/
 enum { CAP_PROP_INTELPERC_PROFILE_COUNT               = 11001,
        CAP_PROP_INTELPERC_PROFILE_IDX                 = 11002,
        CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE  = 11003,
@@ -471,7 +517,7 @@ enum { CAP_PROP_INTELPERC_PROFILE_COUNT               = 11001,
        CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT     = 11007
      };
 
-//! Intel PerC streams
+//! Intel Perceptual Streams
 enum { CAP_INTELPERC_DEPTH_GENERATOR = 1 << 29,
        CAP_INTELPERC_IMAGE_GENERATOR = 1 << 28,
        CAP_INTELPERC_GENERATORS_MASK = CAP_INTELPERC_DEPTH_GENERATOR + CAP_INTELPERC_IMAGE_GENERATOR
@@ -483,9 +529,15 @@ enum { CAP_INTELPERC_DEPTH_MAP              = 0, //!< Each pixel is a 16-bit int
        CAP_INTELPERC_IMAGE                  = 3
      };
 
+//! @} Intel Perceptual
+
+/** @name gPhoto2 connection
+    @{
+*/
+
 /** @brief gPhoto2 properties
 
-if propertyId is less than 0 then work on widget with that __additive inversed__ camera setting ID
+If `propertyId` is less than 0 then work on widget with that __additive inversed__ camera setting ID
 Get IDs by using CAP_PROP_GPHOTO2_WIDGET_ENUMERATE.
 @see CvCaptureCAM_GPHOTO2 for more info
 */
@@ -501,114 +553,112 @@ enum { CAP_PROP_GPHOTO2_PREVIEW           = 17001, //!< Capture only preview fro
        CAP_PROP_VIEWFINDER                = 17010  //!< Enter liveview mode.
      };
 
-//enum {
+//! @} gPhoto2
 
 //! @} videoio_flags_others
 
+
 class IVideoCapture;
 
-/** @brief Class for video capturing from video files, image sequences or cameras. The class provides C++ API
-for capturing video from cameras or for reading video files and image sequences. Here is how the
-class can be used: :
-@code
-    #include "opencv2/opencv.hpp"
-
-    using namespace cv;
-
-    int main(int, char**)
-    {
-        VideoCapture cap(0); // open the default camera
-        if(!cap.isOpened())  // check if we succeeded
-            return -1;
-
-        Mat edges;
-        namedWindow("edges",1);
-        for(;;)
-        {
-            Mat frame;
-            cap >> frame; // get a new frame from camera
-            cvtColor(frame, edges, COLOR_BGR2GRAY);
-            GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
-            Canny(edges, edges, 0, 30, 3);
-            imshow("edges", edges);
-            if(waitKey(30) >= 0) break;
-        }
-        // the camera will be deinitialized automatically in VideoCapture destructor
-        return 0;
-    }
-@endcode
-@note In C API the black-box structure CvCapture is used instead of VideoCapture.
+/** @brief Class for video capturing from video files, image sequences or cameras.
+
+The class provides C++ API for capturing video from cameras or for reading video files and image sequences.
 
+Here is how the class can be used:
+@include samples/cpp/videocapture_basic.cpp
+
+@note In @ref videoio_c "C API" the black-box structure `CvCapture` is used instead of %VideoCapture.
 @note
--   A basic sample on using the VideoCapture interface can be found at
-    opencv_source_code/samples/cpp/starter_video.cpp
--   Another basic video processing sample can be found at
-    opencv_source_code/samples/cpp/video_dmtx.cpp
--   (Python) A basic sample on using the VideoCapture interface can be found at
-    opencv_source_code/samples/python/video.py
--   (Python) Another basic video processing sample can be found at
-    opencv_source_code/samples/python/video_dmtx.py
+-   (C++) A basic sample on using the %VideoCapture interface can be found at
+    `OPENCV_SOURCE_CODE/samples/cpp/videocapture_starter.cpp`
+-   (Python) A basic sample on using the %VideoCapture interface can be found at
+    `OPENCV_SOURCE_CODE/samples/python/video.py`
 -   (Python) A multi threaded video processing sample can be found at
-    opencv_source_code/samples/python/video_threaded.py
+    `OPENCV_SOURCE_CODE/samples/python/video_threaded.py`
+-   (Python) %VideoCapture sample showcasing some features of the Video4Linux2 backend
+    `OPENCV_SOURCE_CODE/samples/python/video_v4l2.py`
  */
 class CV_EXPORTS_W VideoCapture
 {
 public:
-    /** @brief
-    @note In C API, when you finished working with video, release CvCapture structure with
+    /** @brief Default constructor
+    @note In @ref videoio_c "C API", when you finished working with video, release CvCapture structure with
     cvReleaseCapture(), or use Ptr\<CvCapture\> that calls cvReleaseCapture() automatically in the
     destructor.
      */
     CV_WRAP VideoCapture();
 
     /** @overload
-    @param filename name of the opened video file (eg. video.avi) or image sequence (eg.
-    img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...)
+    @brief  Open video file or a capturing device or a IP video stream for video capturing
+
+    Same as VideoCapture(const String& filename, int apiPreference) but using default Capture API backends
     */
     CV_WRAP VideoCapture(const String& filename);
 
     /** @overload
-    @param filename name of the opened video file (eg. video.avi) or image sequence (eg.
-    img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...)
-
-    @param apiPreference preferred Capture API to use. Can be used to enforce a specific reader
-    implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES
+    @brief  Open video file or a capturing device or a IP video stream for video capturing with API Preference
+
+    @param filename it can be:
+    - name of video file (eg. `video.avi`)
+    - or image sequence (eg. `img_%02d.jpg`, which will read samples like `img_00.jpg, img_01.jpg, img_02.jpg, ...`)
+    - or URL of video stream (eg. `protocol://host:port/script_name?script_params|auth`).
+      Note that each video stream or IP camera feed has its own URL scheme. Please refer to the
+      documentation of source stream to know the right URL.
+    @param apiPreference preferred Capture API backends to use. Can be used to enforce a specific reader
+    implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.
+    @sa The list of supported API backends cv::VideoCaptureAPIs
     */
     CV_WRAP VideoCapture(const String& filename, int apiPreference);
 
     /** @overload
-    @param index = camera_id + domain_offset (CAP_*). id of the video capturing device to open. If there is a single
-    camera connected, just pass 0. Advanced Usage: to open Camera 1 using the MS Media Foundation API: index = 1 + cv::CAP_MSMF
+    @brief  Open a camera for video capturing
+
+    @param index camera_id + domain_offset (CAP_*) id of the video capturing device to open. To open default camera using default backend just pass 0.
+    Use a `domain_offset` to enforce a specific reader implementation if multiple are available like cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.
+    e.g. to open Camera 1 using the MS Media Foundation API use `index = 1 + cv::CAP_MSMF`
+
+    @sa The list of supported API backends cv::VideoCaptureAPIs
     */
     CV_WRAP VideoCapture(int index);
 
+    /** @brief Default destructor
+
+    The method first calls VideoCapture::release to close the already opened file or camera.
+    */
     virtual ~VideoCapture();
 
-    /** @brief Open video file or a capturing device for video capturing
+    /** @brief  Open video file or a capturing device or a IP video stream for video capturing
+
+    @overload
 
-    @param filename name of the opened video file (eg. video.avi) or image sequence (eg.
-    img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...)
+    Parameters are same as the constructor VideoCapture(const String& filename)
+    @return `true` if the file has been successfully opened
 
-    The methods first call VideoCapture::release to close the already opened file or camera.
+    The method first calls VideoCapture::release to close the already opened file or camera.
      */
     CV_WRAP virtual bool open(const String& filename);
 
-    /** @overload
-    @param index = camera_id + domain_offset (CAP_*). id of the video capturing device to open. If there is a single
-    camera connected, just pass 0. Advanced Usage: to open Camera 1 using the MS Media Foundation API: index = 1 + cv::CAP_MSMF
+    /** @brief  Open a camera for video capturing
+
+    @overload
+
+    Parameters are same as the constructor VideoCapture(int index)
+    @return `true` if the camera has been successfully opened.
+
+    The method first calls VideoCapture::release to close the already opened file or camera.
     */
     CV_WRAP virtual bool open(int index);
 
     /** @brief Returns true if video capturing has been initialized already.
 
-    If the previous call to VideoCapture constructor or VideoCapture::open succeeded, the method returns
+    If the previous call to VideoCapture constructor or VideoCapture::open() succeeded, the method returns
     true.
      */
     CV_WRAP virtual bool isOpened() const;
 
     /** @brief Closes video file or capturing device.
 
-    The methods are automatically called by subsequent VideoCapture::open and by VideoCapture
+    The method is automatically called by subsequent VideoCapture::open and by VideoCapture
     destructor.
 
     The C function also deallocates memory and clears \*capture pointer.
@@ -617,7 +667,9 @@ public:
 
     /** @brief Grabs the next frame from video file or capturing device.
 
-    The methods/functions grab the next frame from video file or camera and return true (non-zero) in
+    @return `true` (non-zero) in the case of success.
+
+    The method/function grabs the next frame from video file or camera and returns true (non-zero) in
     the case of success.
 
     The primary use of the function is in multi-camera environments, especially when the cameras do not
@@ -627,34 +679,52 @@ public:
     from different cameras will be closer in time.
 
     Also, when a connected camera is multi-head (for example, a stereo camera or a Kinect device), the
-    correct way of retrieving data from it is to call VideoCapture::grab first and then call
-    VideoCapture::retrieve one or more times with different values of the channel parameter. See
-    <https://github.com/opencv/opencv/tree/master/samples/cpp/openni_capture.cpp>
+    correct way of retrieving data from it is to call VideoCapture::grab() first and then call
+    VideoCapture::retrieve() one or more times with different values of the channel parameter.
+
+    @ref tutorial_kinect_openni
      */
     CV_WRAP virtual bool grab();
 
     /** @brief Decodes and returns the grabbed video frame.
 
-    The methods/functions decode and return the just grabbed frame. If no frames has been grabbed
-    (camera has been disconnected, or there are no more frames in video file), the methods return false
-    and the functions return NULL pointer.
+    @param [out] image the video frame is returned here. If no frames has been grabbed the image will be empty.
+    @param flag it could be a frame index or a driver specific flag
+    @return `false` if no frames has been grabbed
+
+    The method decodes and returns the just grabbed frame. If no frames has been grabbed
+    (camera has been disconnected, or there are no more frames in video file), the method returns false
+    and the function returns an empty image (with %cv::Mat, test it with Mat::empty()).
 
-    @note OpenCV 1.x functions cvRetrieveFrame and cv.RetrieveFrame return image stored inside the video
+    @sa read()
+
+    @note In @ref videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video
     capturing structure. It is not allowed to modify or release the image! You can copy the frame using
     :ocvcvCloneImage and then do whatever you want with the copy.
      */
     CV_WRAP virtual bool retrieve(OutputArray image, int flag = 0);
+
+    /** @brief Stream operator to read the next video frame.
+    @sa read()
+    */
     virtual VideoCapture& operator >> (CV_OUT Mat& image);
+
+    /** @overload
+    @sa read()
+    */
     virtual VideoCapture& operator >> (CV_OUT UMat& image);
 
     /** @brief Grabs, decodes and returns the next video frame.
 
-    The methods/functions combine VideoCapture::grab and VideoCapture::retrieve in one call. This is the
-    most convenient method for reading video files or capturing data from decode and return the just
+    @param [out] image the video frame is returned here. If no frames has been grabbed the image will be empty.
+    @return `false` if no frames has been grabbed
+
+    The method/function combines VideoCapture::grab() and VideoCapture::retrieve() in one call. This is the
+    most convenient method for reading video files or capturing data from decode and returns the just
     grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more
-    frames in video file), the methods return false and the functions return NULL pointer.
+    frames in video file), the method returns false and the function returns empty image (with %cv::Mat, test it with Mat::empty()).
 
-    @note OpenCV 1.x functions cvRetrieveFrame and cv.RetrieveFrame return image stored inside the video
+    @note In @ref videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video
     capturing structure. It is not allowed to modify or release the image! You can copy the frame using
     :ocvcvCloneImage and then do whatever you want with the copy.
      */
@@ -662,70 +732,43 @@ public:
 
     /** @brief Sets a property in the VideoCapture.
 
-    @param propId Property identifier. It can be one of the following:
-    -   cv::CAP_PROP_POS_MSEC @copydoc cv::CAP_PROP_POS_MSEC
-    -   cv::CAP_PROP_POS_FRAMES @copydoc CAP_PROP_POS_FRAMES
-    -   cv::CAP_PROP_POS_AVI_RATIO @copydoc cv::CAP_PROP_POS_AVI_RATIO
-    -   cv::CAP_PROP_FRAME_WIDTH @copydoc cv::CAP_PROP_FRAME_WIDTH
-    -   cv::CAP_PROP_FRAME_HEIGHT @copydoc cv::CAP_PROP_FRAME_HEIGHT
-    -   cv::CAP_PROP_FPS @copydoc cv::CAP_PROP_FPS
-    -   cv::CAP_PROP_FOURCC @copydoc cv::CAP_PROP_FOURCC
-    -   cv::CAP_PROP_FRAME_COUNT @copydoc cv::CAP_PROP_FRAME_COUNT
-    -   cv::CAP_PROP_FORMAT @copydoc cv::CAP_PROP_FORMAT
-    -   cv::CAP_PROP_MODE @copydoc cv::CAP_PROP_MODE
-    -   cv::CAP_PROP_BRIGHTNESS @copydoc cv::CAP_PROP_BRIGHTNESS
-    -   cv::CAP_PROP_CONTRAST @copydoc cv::CAP_PROP_CONTRAST
-    -   cv::CAP_PROP_SATURATION @copydoc cv::CAP_PROP_SATURATION
-    -   cv::CAP_PROP_HUE @copydoc cv::CAP_PROP_HUE
-    -   cv::CAP_PROP_GAIN @copydoc cv::CAP_PROP_GAIN
-    -   cv::CAP_PROP_EXPOSURE @copydoc cv::CAP_PROP_EXPOSURE
-    -   cv::CAP_PROP_CONVERT_RGB @copydoc cv::CAP_PROP_CONVERT_RGB
-    -   cv::CAP_PROP_WHITE_BALANCE_BLUE_U @copydoc cv::CAP_PROP_WHITE_BALANCE_BLUE_U
-    -   cv::CAP_PROP_WHITE_BALANCE_RED_V @copydoc cv::CAP_PROP_WHITE_BALANCE_RED_V
-    -   cv::CAP_PROP_RECTIFICATION @copydoc cv::CAP_PROP_RECTIFICATION
+    @param propId Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...)
+    or one from @ref videoio_flags_others
     @param value Value of the property.
+    @return `true` if the property is supported by backend used by the VideoCapture instance.
+    @note Even if it returns `true` this doesn't ensure that the property
+    value has been accepted by the capture device. See note in VideoCapture::get()
      */
     CV_WRAP virtual bool set(int propId, double value);
 
     /** @brief Returns the specified VideoCapture property
 
-    @param propId Property identifier. It can be one of the following:
-    -   cv::CAP_PROP_POS_MSEC @copydoc cv::CAP_PROP_POS_MSEC
-    -   cv::CAP_PROP_POS_FRAMES @copydoc CAP_PROP_POS_FRAMES
-    -   cv::CAP_PROP_POS_AVI_RATIO @copydoc cv::CAP_PROP_POS_AVI_RATIO
-    -   cv::CAP_PROP_FRAME_WIDTH @copydoc cv::CAP_PROP_FRAME_WIDTH
-    -   cv::CAP_PROP_FRAME_HEIGHT @copydoc cv::CAP_PROP_FRAME_HEIGHT
-    -   cv::CAP_PROP_FPS @copydoc cv::CAP_PROP_FPS
-    -   cv::CAP_PROP_FOURCC @copydoc cv::CAP_PROP_FOURCC
-    -   cv::CAP_PROP_FRAME_COUNT @copydoc cv::CAP_PROP_FRAME_COUNT
-    -   cv::CAP_PROP_FORMAT @copydoc cv::CAP_PROP_FORMAT
-    -   cv::CAP_PROP_MODE @copydoc cv::CAP_PROP_MODE
-    -   cv::CAP_PROP_BRIGHTNESS @copydoc cv::CAP_PROP_BRIGHTNESS
-    -   cv::CAP_PROP_CONTRAST @copydoc cv::CAP_PROP_CONTRAST
-    -   cv::CAP_PROP_SATURATION @copydoc cv::CAP_PROP_SATURATION
-    -   cv::CAP_PROP_HUE @copydoc cv::CAP_PROP_HUE
-    -   cv::CAP_PROP_GAIN @copydoc cv::CAP_PROP_GAIN
-    -   cv::CAP_PROP_EXPOSURE @copydoc cv::CAP_PROP_EXPOSURE
-    -   cv::CAP_PROP_CONVERT_RGB @copydoc cv::CAP_PROP_CONVERT_RGB
-    -   cv::CAP_PROP_WHITE_BALANCE_BLUE_U @copydoc cv::CAP_PROP_WHITE_BALANCE_BLUE_U
-    -   cv::CAP_PROP_WHITE_BALANCE_RED_V @copydoc cv::CAP_PROP_WHITE_BALANCE_RED_V
-    -   cv::CAP_PROP_RECTIFICATION @copydoc cv::CAP_PROP_RECTIFICATION
-
-    @note When querying a property that is not supported by the backend used by the VideoCapture
-    class, value 0 is returned.
-     */
+    @param propId Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...)
+    or one from @ref videoio_flags_others
+    @return Value for the specified property. Value 0 is returned when querying a property that is
+    not supported by the backend used by the VideoCapture instance.
+
+    @note Reading / writing properties involves many layers. Some unexpected result might happens
+    along this chain.
+    @code {.txt}
+    `VideoCapture -> API Backend -> Operating System -> Device Driver -> Device Hardware`
+    @endcode
+    The returned value might be different from what really used by the device or it could be encoded
+    using device dependant rules (eg. steps or percentage). Effective behaviour depends from device
+    driver and API Backend
+
+    */
     CV_WRAP virtual double get(int propId) const;
 
-    /** @overload
+    /** @brief Open video file or a capturing device or a IP video stream for video capturing with API Preference
 
-    @param filename name of the opened video file (eg. video.avi) or image sequence (eg.
-    img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...)
+    @overload
 
-    @param apiPreference preferred Capture API to use. Can be used to enforce a specific reader
-    implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES
+    Parameters are same as the constructor VideoCapture(const String& filename, int apiPreference)
+    @return `true` if the file has been successfully opened
 
-    The methods first call VideoCapture::release to close the already opened file or camera.
-     */
+    The method first calls VideoCapture::release to close the already opened file or camera.
+    */
     CV_WRAP virtual bool open(const String& filename, int apiPreference);
 
 protected:
@@ -736,14 +779,21 @@ protected:
 class IVideoWriter;
 
 /** @brief Video writer class.
+
+The class provides C++ API for writing video files or image sequences.
+
+Here is how the class can be used:
+@include samples/cpp/videowriter_basic.cpp
  */
 class CV_EXPORTS_W VideoWriter
 {
 public:
-    /** @brief VideoWriter constructors
+    /** @brief Default constructors
 
-    The constructors/functions initialize video writers. On Linux FFMPEG is used to write videos; on
-    Windows FFMPEG or VFW is used; on MacOSX QTKit is used.
+    The constructors/functions initialize video writers.
+    -   On Linux FFMPEG is used to write videos;
+    -   On Windows FFMPEG or VFW is used;
+    -   On MacOSX QTKit is used.
      */
     CV_WRAP VideoWriter();
 
@@ -759,16 +809,31 @@ public:
     @param frameSize Size of the video frames.
     @param isColor If it is not zero, the encoder will expect and encode color frames, otherwise it
     will work with grayscale frames (the flag is currently supported on Windows only).
+
+    @b Tips:
+    - With some backends `fourcc=-1` pops up the codec selection dialog from the system.
+    - To save image sequence use a proper filename (eg. `img_%02d.jpg`) and `fourcc=0`
+      OR `fps=0`. Use uncompressed image format (eg. `img_%02d.BMP`) to save raw frames.
+    - Most codecs are lossy. If you want lossless video file you need to use a lossless codecs
+      (eg. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc...)
+    - If FFMPEG is enabled, using `codec=0; fps=0;` you can create an uncompressed (raw) video file.
     */
     CV_WRAP VideoWriter(const String& filename, int fourcc, double fps,
                 Size frameSize, bool isColor = true);
 
+    /** @brief Default destructor
+
+    The method first calls VideoWriter::release to close the already opened file.
+    */
     virtual ~VideoWriter();
 
     /** @brief Initializes or reinitializes video writer.
 
     The method opens video writer. Parameters are the same as in the constructor
     VideoWriter::VideoWriter.
+    @return `true` if video writer has been successfully initialized
+
+    The method first calls VideoWriter::release to close the already opened file.
      */
     CV_WRAP virtual bool open(const String& filename, int fourcc, double fps,
                       Size frameSize, bool isColor = true);
@@ -779,44 +844,49 @@ public:
 
     /** @brief Closes the video writer.
 
-    The methods are automatically called by subsequent VideoWriter::open and by the VideoWriter
+    The method is automatically called by subsequent VideoWriter::open and by the VideoWriter
     destructor.
      */
     CV_WRAP virtual void release();
+
+    /** @brief Stream operator to write the next video frame.
+    @sa write
+    */
     virtual VideoWriter& operator << (const Mat& image);
 
     /** @brief Writes the next video frame
 
     @param image The written frame
 
-    The functions/methods write the specified image to video file. It must have the same size as has
+    The function/method writes the specified image to video file. It must have the same size as has
     been specified when opening the video writer.
      */
     CV_WRAP virtual void write(const Mat& image);
 
     /** @brief Sets a property in the VideoWriter.
 
-     @param propId Property identifier. It can be one of the following:
-     -   cv::VIDEOWRITER_PROP_QUALITY @copydoc cv::VIDEOWRITER_PROP_QUALITY
-     -   cv::VIDEOWRITER_PROP_NSTRIPES @copydoc cv::VIDEOWRITER_PROP_NSTRIPES
+     @param propId Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY)
+     or one of @ref videoio_flags_others
+
      @param value Value of the property.
+     @return  `true` if the property is supported by the backend used by the VideoWriter instance.
      */
     CV_WRAP virtual bool set(int propId, double value);
 
     /** @brief Returns the specified VideoWriter property
 
-     @param propId Property identifier. It can be one of the following:
-     -   cv::VIDEOWRITER_PROP_QUALITY @copydoc cv::VIDEOWRITER_PROP_QUALITY
-     -   cv::VIDEOWRITER_PROP_FRAMEBYTES @copydoc VIDEOWRITER_PROP_FRAMEBYTES
-     -   cv::VIDEOWRITER_PROP_NSTRIPES @copydoc cv::VIDEOWRITER_PROP_NSTRIPES
+     @param propId Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY)
+     or one of @ref videoio_flags_others
 
-     @note When querying a property that is not supported by the backend used by the VideoWriter
-     class, value 0 is returned.
+     @return Value for the specified property. Value 0 is returned when querying a property that is
+     not supported by the backend used by the VideoWriter instance.
      */
     CV_WRAP virtual double get(int propId) const;
 
     /** @brief Concatenates 4 chars to a fourcc code
 
+    @return a fourcc code
+
     This static method constructs the fourcc code of the codec to be used in the constructor
     VideoWriter::VideoWriter or VideoWriter::open.
      */
index e502c7b..63aef7d 100644 (file)
@@ -57,13 +57,18 @@ extern "C" {
 *                         Working with Video Files and Cameras                           *
 \****************************************************************************************/
 
-/* "black box" capture structure */
+/** @brief "black box" capture structure
+
+In C++ use cv::VideoCapture
+*/
 typedef struct CvCapture CvCapture;
 
-/* start capturing frames from video file */
+/** @brief start capturing frames from video file
+*/
 CVAPI(CvCapture*) cvCreateFileCapture( const char* filename );
 
-/* start capturing frames from video file. allows specifying a preferred API to use */
+/** @brief start capturing frames from video file. allows specifying a preferred API to use
+*/
 CVAPI(CvCapture*) cvCreateFileCaptureWithPreference( const char* filename , int apiPreference);
 
 enum
@@ -120,24 +125,32 @@ enum
     CV_CAP_IMAGES = 2000     // OpenCV Image Sequence (e.g. img_%02d.jpg)
 };
 
-/* start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*) */
+/** @brief start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*)
+*/
 CVAPI(CvCapture*) cvCreateCameraCapture( int index );
 
-/* grab a frame, return 1 on success, 0 on fail.
-  this function is thought to be fast               */
+/** @brief grab a frame, return 1 on success, 0 on fail.
+
+  this function is thought to be fast
+*/
 CVAPI(int) cvGrabFrame( CvCapture* capture );
 
-/* get the frame grabbed with cvGrabFrame(..)
+/** @brief get the frame grabbed with cvGrabFrame(..)
+
   This function may apply some frame processing like
   frame decompression, flipping etc.
-  !!!DO NOT RELEASE or MODIFY the retrieved frame!!! */
+  @warning !!!DO NOT RELEASE or MODIFY the retrieved frame!!!
+*/
 CVAPI(IplImage*) cvRetrieveFrame( CvCapture* capture, int streamIdx CV_DEFAULT(0) );
 
-/* Just a combination of cvGrabFrame and cvRetrieveFrame
-   !!!DO NOT RELEASE or MODIFY the retrieved frame!!!      */
+/** @brief Just a combination of cvGrabFrame and cvRetrieveFrame
+
+  @warning !!!DO NOT RELEASE or MODIFY the retrieved frame!!!
+*/
 CVAPI(IplImage*) cvQueryFrame( CvCapture* capture );
 
-/* stop capturing/reading and free resources */
+/** @brief stop capturing/reading and free resources
+*/
 CVAPI(void) cvReleaseCapture( CvCapture** capture );
 
 enum
@@ -498,48 +511,71 @@ enum
     CV_CAP_PROP_VIEWFINDER                = 17010  // Enter liveview mode.
 };
 
-/* retrieve or set capture properties */
+/** @brief retrieve capture properties
+*/
 CVAPI(double) cvGetCaptureProperty( CvCapture* capture, int property_id );
+/** @brief set capture properties
+*/
 CVAPI(int)    cvSetCaptureProperty( CvCapture* capture, int property_id, double value );
 
-// Return the type of the capturer (eg, CV_CAP_V4W, CV_CAP_UNICAP), which is unknown if created with CV_CAP_ANY
+/** @brief Return the type of the capturer (eg, ::CV_CAP_VFW, ::CV_CAP_UNICAP)
+
+It is unknown if created with ::CV_CAP_ANY
+*/
 CVAPI(int)    cvGetCaptureDomain( CvCapture* capture);
 
-/* "black box" video file writer structure */
+/** @brief "black box" video file writer structure
+
+In C++ use cv::VideoWriter
+*/
 typedef struct CvVideoWriter CvVideoWriter;
 
+//! Macro to construct the fourcc code of the codec. Same as CV_FOURCC()
 #define CV_FOURCC_MACRO(c1, c2, c3, c4) (((c1) & 255) + (((c2) & 255) << 8) + (((c3) & 255) << 16) + (((c4) & 255) << 24))
 
+/** @brief Constructs the fourcc code of the codec function
+
+Simply call it with 4 chars fourcc code like `CV_FOURCC('I', 'Y', 'U', 'V')`
+
+List of codes can be obtained at [Video Codecs by FOURCC](http://www.fourcc.org/codecs.php) page.
+FFMPEG backend with MP4 container natively uses other values as fourcc code:
+see [ObjectType](http://www.mp4ra.org/codecs.html).
+*/
 CV_INLINE int CV_FOURCC(char c1, char c2, char c3, char c4)
 {
     return CV_FOURCC_MACRO(c1, c2, c3, c4);
 }
 
-#define CV_FOURCC_PROMPT -1  /* Open Codec Selection Dialog (Windows only) */
-#define CV_FOURCC_DEFAULT CV_FOURCC('I', 'Y', 'U', 'V') /* Use default codec for specified filename (Linux only) */
+//! (Windows only) Open Codec Selection Dialog
+#define CV_FOURCC_PROMPT -1
+//! (Linux only) Use default codec for specified filename
+#define CV_FOURCC_DEFAULT CV_FOURCC('I', 'Y', 'U', 'V')
 
-/* initialize video file writer */
+/** @brief initialize video file writer
+*/
 CVAPI(CvVideoWriter*) cvCreateVideoWriter( const char* filename, int fourcc,
                                            double fps, CvSize frame_size,
                                            int is_color CV_DEFAULT(1));
 
-/* write frame to video file */
+/** @brief write frame to video file
+*/
 CVAPI(int) cvWriteFrame( CvVideoWriter* writer, const IplImage* image );
 
-/* close video file writer */
+/** @brief close video file writer
+*/
 CVAPI(void) cvReleaseVideoWriter( CvVideoWriter** writer );
 
-/****************************************************************************************\
-*                              Obsolete functions/synonyms                               *
-\****************************************************************************************/
-
-#define cvCaptureFromFile cvCreateFileCapture
-#define cvCaptureFromCAM cvCreateCameraCapture
-#define cvCaptureFromAVI cvCaptureFromFile
-#define cvCreateAVIWriter cvCreateVideoWriter
-#define cvWriteToAVI cvWriteFrame
-
-/** @} videoio_c */
+// ***************************************************************************************
+//! @name Obsolete functions/synonyms
+//! @{
+#define cvCaptureFromCAM cvCreateCameraCapture //!< @deprecated use cvCreateCameraCapture() instead
+#define cvCaptureFromFile cvCreateFileCapture  //!< @deprecated use cvCreateFileCapture() instead
+#define cvCaptureFromAVI cvCaptureFromFile     //!< @deprecated use cvCreateFileCapture() instead
+#define cvCreateAVIWriter cvCreateVideoWriter  //!< @deprecated use cvCreateVideoWriter() instead
+#define cvWriteToAVI cvWriteFrame              //!< @deprecated use cvWriteFrame() instead
+//!  @} Obsolete...
+
+//! @} videoio_c
 
 #ifdef __cplusplus
 }
diff --git a/samples/cpp/videocapture_basic.cpp b/samples/cpp/videocapture_basic.cpp
new file mode 100644 (file)
index 0000000..ae77b05
--- /dev/null
@@ -0,0 +1,52 @@
+/**
+  @file videocapture_basic.cpp
+  @brief A very basic sample for using VideoCapture and VideoWriter
+  @author PkLab.net
+  @date Aug 24, 2016
+*/
+
+#include <opencv2/opencv.hpp>
+#include <iostream>
+#include <stdio.h>
+
+using namespace cv;
+using namespace std;
+
+int main(int, char**)
+{
+    Mat frame;
+    //--- INITIALIZE VIDEOCAPTURE
+    VideoCapture cap;
+    // open the default camera using default API
+    cap.open(0);
+    // OR advance usage: select any API backend
+    int deviceID = 0;             // 0 = open default camera
+    int apiID = cv::CAP_ANY;      // 0 = autodetect default API
+    // open selected camera using selected API
+    cap.open(deviceID + apiID);
+    // check if we succeeded
+    if (!cap.isOpened()) {
+        cerr << "ERROR! Unable to open camera\n";
+        return -1;
+    }
+
+    //--- GRAB AND WRITE LOOP
+    cout << "Start grabbing" << endl
+        << "Press any key to terminate" << endl;
+    for (;;)
+    {
+        // wait for a new frame from camera and store it into 'frame'
+        cap.read(frame);
+        // check if we succeeded
+        if (frame.empty()) {
+            cerr << "ERROR! blank frame grabbed\n";
+            break;
+        }
+        // show live and wait for a key with timeout long enough to show images
+        imshow("Live", frame);
+        if (waitKey(5) >= 0)
+            break;
+    }
+    // the camera will be deinitialized automatically in VideoCapture destructor
+    return 0;
+}
\ No newline at end of file
similarity index 95%
rename from samples/cpp/starter_video.cpp
rename to samples/cpp/videocapture_starter.cpp
index 2839b03..58f1145 100644 (file)
@@ -1,14 +1,13 @@
-/*
-* starter_video.cpp
+/**
+* @file videocapture_starter.cpp
+* @brief A starter sample for using OpenCV VideoCapture with capture devices, video files or image sequences
+* easy as CV_PI right?
 *
 *  Created on: Nov 23, 2010
 *      Author: Ethan Rublee
 *
 *  Modified on: April 17, 2013
 *      Author: Kevin Hughes
-*
-* A starter sample for using OpenCV VideoCapture with capture devices, video files or image sequences
-* easy as CV_PI right?
 */
 
 #include <opencv2/imgcodecs.hpp>
diff --git a/samples/cpp/videowriter_basic.cpp b/samples/cpp/videowriter_basic.cpp
new file mode 100644 (file)
index 0000000..9ab4efc
--- /dev/null
@@ -0,0 +1,65 @@
+/**
+  @file videowriter_basic.cpp
+  @brief A very basic sample for using VideoWriter and VideoCapture
+  @author PkLab.net
+  @date Aug 24, 2016
+*/
+
+#include <opencv2/opencv.hpp>
+#include <iostream>
+#include <stdio.h>
+
+using namespace cv;
+using namespace std;
+
+int main(int, char**)
+{
+    Mat src;
+    // use default camera as video source
+    VideoCapture cap(0);
+    // check if we succeeded
+    if (!cap.isOpened()) {
+        cerr << "ERROR! Unable to open camera\n";
+        return -1;
+    }
+    // get one frame from camera to know frame size and type
+    cap >> src;
+    // check if we succeeded
+    if (src.empty()) {
+        cerr << "ERROR! blank frame grabbed\n";
+        return -1;
+    }
+    bool isColor = (src.type() == CV_8UC3);
+
+    //--- INITIALIZE VIDEOWRITER
+    VideoWriter writer;
+    int codec = CV_FOURCC('M', 'J', 'P', 'G');  // select desired codec (must be available at runtime)
+    double fps = 25.0;                          // framerate of the created video stream
+    string filename = "./live.avi";             // name of the output video file
+    writer.open(filename, codec, fps, src.size(), isColor);
+    // check if we succeeded
+    if (!writer.isOpened()) {
+        cerr << "Could not open the output video file for write\n";
+        return -1;
+    }
+
+    //--- GRAB AND WRITE LOOP
+    cout << "Writing videofile: " << filename << endl
+         << "Press any key to terminate" << endl;
+    for (;;)
+    {
+        // check if we succeeded
+        if (!cap.read(src)) {
+            cerr << "ERROR! blank frame grabbed\n";
+            break;
+        }
+        // encode the frame into the videofile stream
+        writer.write(src);
+        // show live and wait for a key with timeout long enough to show images
+        imshow("Live", src);
+        if (waitKey(5) >= 0)
+            break;
+    }
+    // the videofile will be closed and released automatically in VideoWriter destructor
+    return 0;
+}
\ No newline at end of file