€•@¢Œsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ0/translations/zh_CN/userspace-api/media/v4l/crop”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ0/translations/zh_TW/userspace-api/media/v4l/crop”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ0/translations/it_IT/userspace-api/media/v4l/crop”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ0/translations/ja_JP/userspace-api/media/v4l/crop”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ0/translations/ko_KR/userspace-api/media/v4l/crop”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ0/translations/sp_SP/userspace-api/media/v4l/crop”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒcomment”“”)”}”(hŒ8SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later”h]”hŒ8SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later”…””}”hh£sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1h¡hhhžhhŸŒJ/var/lib/git/docbuild/linux/Documentation/userspace-api/media/v4l/crop.rst”h KubhŒtarget”“”)”}”(hŒ .. _crop:”h]”h}”(h]”h ]”h"]”h$]”h&]”Œrefid”Œcrop”uh1h´h KhhhžhhŸh³ubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒ5Image Cropping, Insertion and Scaling -- the CROP API”h]”hŒ5Image Cropping, Insertion and Scaling -- the CROP API”…””}”(hhÉhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÇhhÄhžhhŸh³h KubhŒnote”“”)”}”(hXaThe CROP API is mostly superseded by the newer :ref:`SELECTION API `. The new API should be preferred in most cases, with the exception of pixel aspect ratio detection, which is implemented by :ref:`VIDIOC_CROPCAP ` and has no equivalent in the SELECTION API. See :ref:`selection-vs-crop` for a comparison of the two APIs.”h]”hŒ paragraph”“”)”}”(hXaThe CROP API is mostly superseded by the newer :ref:`SELECTION API `. The new API should be preferred in most cases, with the exception of pixel aspect ratio detection, which is implemented by :ref:`VIDIOC_CROPCAP ` and has no equivalent in the SELECTION API. See :ref:`selection-vs-crop` for a comparison of the two APIs.”h]”(hŒ/The CROP API is mostly superseded by the newer ”…””}”(hhßhžhhŸNh Nubh)”}”(hŒ$:ref:`SELECTION API `”h]”hŒinline”“”)”}”(hhéh]”hŒ SELECTION API”…””}”(hhíhžhhŸNh Nubah}”(h]”h ]”(Œxref”Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhhçubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”Œuserspace-api/media/v4l/crop”Œ refdomain”høŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆŒ reftarget”Œ selection-api”uh1hhŸh³h K hhßubhŒ}. The new API should be preferred in most cases, with the exception of pixel aspect ratio detection, which is implemented by ”…””}”(hhßhžhhŸNh Nubh)”}”(hŒ&:ref:`VIDIOC_CROPCAP `”h]”hì)”}”(hjh]”hŒVIDIOC_CROPCAP”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhjubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj Œvidioc_cropcap”uh1hhŸh³h K hhßubhŒ1 and has no equivalent in the SELECTION API. See ”…””}”(hhßhžhhŸNh Nubh)”}”(hŒ:ref:`selection-vs-crop`”h]”hì)”}”(hj6h]”hŒselection-vs-crop”…””}”(hj8hžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhj4ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jBŒreftype”Œref”Œ refexplicit”‰Œrefwarn”ˆj Œselection-vs-crop”uh1hhŸh³h K hhßubhŒ" for a comparison of the two APIs.”…””}”(hhßhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h K hhÙubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hhÄhžhhŸh³h NubhÞ)”}”(hX2Some video capture devices can sample a subsection of the picture and shrink or enlarge it to an image of arbitrary size. We call these abilities cropping and scaling. Some video output devices can scale an image up or down and insert it at an arbitrary scan line and horizontal offset into a video signal.”h]”hX2Some video capture devices can sample a subsection of the picture and shrink or enlarge it to an image of arbitrary size. We call these abilities cropping and scaling. Some video output devices can scale an image up or down and insert it at an arbitrary scan line and horizontal offset into a video signal.”…””}”(hjdhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h KhhÄhžhubhÞ)”}”(hŒ}Applications can use the following API to select an area in the video signal, query the default area and the hardware limits.”h]”hŒ}Applications can use the following API to select an area in the video signal, query the default area and the hardware limits.”…””}”(hjrhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h KhhÄhžhubhØ)”}”(hŒ¾Despite their name, the :ref:`VIDIOC_CROPCAP `, :ref:`VIDIOC_G_CROP ` and :ref:`VIDIOC_S_CROP ` ioctls apply to input as well as output devices.”h]”hÞ)”}”(hŒ¾Despite their name, the :ref:`VIDIOC_CROPCAP `, :ref:`VIDIOC_G_CROP ` and :ref:`VIDIOC_S_CROP ` ioctls apply to input as well as output devices.”h]”(hŒDespite their name, the ”…””}”(hj„hžhhŸNh Nubh)”}”(hŒ&:ref:`VIDIOC_CROPCAP `”h]”hì)”}”(hjŽh]”hŒVIDIOC_CROPCAP”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhjŒubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jšŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj Œvidioc_cropcap”uh1hhŸh³h Khj„ubhŒ, ”…””}”(hj„hžhhŸNh Nubh)”}”(hŒ$:ref:`VIDIOC_G_CROP `”h]”hì)”}”(hj²h]”hŒ VIDIOC_G_CROP”…””}”(hj´hžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhj°ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”j¾Œreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj Œ vidioc_g_crop”uh1hhŸh³h Khj„ubhŒ and ”…””}”(hj„hžhhŸNh Nubh)”}”(hŒ$:ref:`VIDIOC_S_CROP `”h]”hì)”}”(hjÖh]”hŒ VIDIOC_S_CROP”…””}”(hjØhžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhjÔubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jâŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj Œ vidioc_g_crop”uh1hhŸh³h Khj„ubhŒ1 ioctls apply to input as well as output devices.”…””}”(hj„hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h Khj€ubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hhÄhžhhŸh³h NubhÞ)”}”(hXScaling requires a source and a target. On a video capture or overlay device the source is the video signal, and the cropping ioctls determine the area actually sampled. The target are images read by the application or overlaid onto the graphics screen. Their size (and position for an overlay) is negotiated with the :ref:`VIDIOC_G_FMT ` and :ref:`VIDIOC_S_FMT ` ioctls.”h]”(hX>Scaling requires a source and a target. On a video capture or overlay device the source is the video signal, and the cropping ioctls determine the area actually sampled. The target are images read by the application or overlaid onto the graphics screen. Their size (and position for an overlay) is negotiated with the ”…””}”(hjhžhhŸNh Nubh)”}”(hŒ":ref:`VIDIOC_G_FMT `”h]”hì)”}”(hjh]”hŒ VIDIOC_G_FMT”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhj ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj Œ vidioc_g_fmt”uh1hhŸh³h K!hjubhŒ and ”…””}”(hjhžhhŸNh Nubh)”}”(hŒ":ref:`VIDIOC_S_FMT `”h]”hì)”}”(hj2h]”hŒ VIDIOC_S_FMT”…””}”(hj4hžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhj0ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”j>Œreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj Œ vidioc_g_fmt”uh1hhŸh³h K!hjubhŒ ioctls.”…””}”(hjhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h K!hhÄhžhubhÞ)”}”(hXhOn a video output device the source are the images passed in by the application, and their size is again negotiated with the :ref:`VIDIOC_G_FMT ` and :ref:`VIDIOC_S_FMT ` ioctls, or may be encoded in a compressed video stream. The target is the video signal, and the cropping ioctls determine the area where the images are inserted.”h]”(hŒ}On a video output device the source are the images passed in by the application, and their size is again negotiated with the ”…””}”(hjZhžhhŸNh Nubh)”}”(hŒ":ref:`VIDIOC_G_FMT `”h]”hì)”}”(hjdh]”hŒ VIDIOC_G_FMT”…””}”(hjfhžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhjbubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jpŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj Œ vidioc_g_fmt”uh1hhŸh³h K(hjZubhŒ and ”…””}”(hjZhžhhŸNh Nubh)”}”(hŒ":ref:`VIDIOC_S_FMT `”h]”hì)”}”(hjˆh]”hŒ VIDIOC_S_FMT”…””}”(hjŠhžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhj†ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”j”Œreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj Œ vidioc_g_fmt”uh1hhŸh³h K(hjZubhŒ¢ ioctls, or may be encoded in a compressed video stream. The target is the video signal, and the cropping ioctls determine the area where the images are inserted.”…””}”(hjZhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h K(hhÄhžhubhÞ)”}”(hŒøSource and target rectangles are defined even if the device does not support scaling or the :ref:`VIDIOC_G_CROP ` and :ref:`VIDIOC_S_CROP ` ioctls. Their size (and position where applicable) will be fixed in this case.”h]”(hŒ\Source and target rectangles are defined even if the device does not support scaling or the ”…””}”(hj°hžhhŸNh Nubh)”}”(hŒ$:ref:`VIDIOC_G_CROP `”h]”hì)”}”(hjºh]”hŒ VIDIOC_G_CROP”…””}”(hj¼hžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhj¸ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jÆŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj Œ vidioc_g_crop”uh1hhŸh³h K/hj°ubhŒ and ”…””}”(hj°hžhhŸNh Nubh)”}”(hŒ$:ref:`VIDIOC_S_CROP `”h]”hì)”}”(hjÞh]”hŒ VIDIOC_S_CROP”…””}”(hjàhžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhjÜubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jêŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj Œ vidioc_g_crop”uh1hhŸh³h K/hj°ubhŒO ioctls. Their size (and position where applicable) will be fixed in this case.”…””}”(hj°hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h K/hhÄhžhubhØ)”}”(hŒ‰All capture and output devices that support the CROP or SELECTION API will also support the :ref:`VIDIOC_CROPCAP ` ioctl.”h]”hÞ)”}”(hŒ‰All capture and output devices that support the CROP or SELECTION API will also support the :ref:`VIDIOC_CROPCAP ` ioctl.”h]”(hŒ\All capture and output devices that support the CROP or SELECTION API will also support the ”…””}”(hj hžhhŸNh Nubh)”}”(hŒ&:ref:`VIDIOC_CROPCAP `”h]”hì)”}”(hjh]”hŒVIDIOC_CROPCAP”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhjubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”j Œreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj Œvidioc_cropcap”uh1hhŸh³h K6hj ubhŒ ioctl.”…””}”(hj hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h K6hjubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hhÄhžhhŸh³h NubhÃ)”}”(hhh]”(hÈ)”}”(hŒCropping Structures”h]”hŒCropping Structures”…””}”(hjEhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÇhjBhžhhŸh³h K;ubhµ)”}”(hŒ.. _crop-scale:”h]”h}”(h]”h ]”h"]”h$]”h&]”hÀŒ crop-scale”uh1h´h K>hjBhžhhŸh³ubŒkfigure”Œ kernel_figure”“”)”}”(hhh]”hŒfigure”“”)”}”(hhh]”(hŒimage”“”)”}”(hŒ¤.. kernel-figure:: crop.svg :alt: crop.svg :align: center Image Cropping, Insertion and Scaling The cropping, insertion and scaling process ”h]”h}”(h]”h ]”h"]”h$]”h&]”Œalt”Œcrop.svg”Œuri”Œ userspace-api/media/v4l/crop.svg”Œ candidates”}”Œ*”jxsuh1jihjfhŸh³h KubhŒcaption”“”)”}”(hŒ%Image Cropping, Insertion and Scaling”h]”hŒ%Image Cropping, Insertion and Scaling”…””}”(hj~hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j|hŸh³h KDhjfubhŒlegend”“”)”}”(hhh]”hÞ)”}”(hŒ+The cropping, insertion and scaling process”h]”hŒ+The cropping, insertion and scaling process”…””}”(hj‘hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h KFhjŽubah}”(h]”h ]”h"]”h$]”h&]”uh1jŒhjfubeh}”(h]”Œid1”ah ]”h"]”h$]”h&]”Œalign”Œcenter”uh1jdhjaubah}”(h]”j]ah ]”h"]”Œ crop-scale”ah$]”h&]”uh1j_hjBhžhhŸh³h NŒexpect_referenced_by_name”}”j²jSsŒexpect_referenced_by_id”}”j]jSsubhÞ)”}”(hX¾For capture devices the coordinates of the top left corner, width and height of the area which can be sampled is given by the ``bounds`` substructure of the struct :c:type:`v4l2_cropcap` returned by the :ref:`VIDIOC_CROPCAP ` ioctl. To support a wide range of hardware this specification does not define an origin or units. However by convention drivers should horizontally count unscaled samples relative to 0H (the leading edge of the horizontal sync pulse, see :ref:`vbi-hsync`). Vertically ITU-R line numbers of the first field (see ITU R-525 line numbering for :ref:`525 lines ` and for :ref:`625 lines `), multiplied by two if the driver can capture both fields.”h]”(hŒ~For capture devices the coordinates of the top left corner, width and height of the area which can be sampled is given by the ”…””}”(hj¹hžhhŸNh NubhŒliteral”“”)”}”(hŒ ``bounds``”h]”hŒbounds”…””}”(hjÃhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÁhj¹ubhŒ substructure of the struct ”…””}”(hj¹hžhhŸNh Nubh)”}”(hŒ:c:type:`v4l2_cropcap`”h]”jÂ)”}”(hj×h]”hŒ v4l2_cropcap”…””}”(hjÙhžhhŸNh Nubah}”(h]”h ]”(h÷Œc”Œc-type”eh"]”h$]”h&]”uh1jÁhjÕubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jãŒreftype”Œtype”Œ refexplicit”‰Œrefwarn”‰j Œ v4l2_cropcap”uh1hhŸh³h KJhj¹ubhŒ returned by the ”…””}”(hj¹hžhhŸNh Nubh)”}”(hŒ&:ref:`VIDIOC_CROPCAP `”h]”hì)”}”(hjûh]”hŒVIDIOC_CROPCAP”…””}”(hjýhžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhjùubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj Œvidioc_cropcap”uh1hhŸh³h KJhj¹ubhŒï ioctl. To support a wide range of hardware this specification does not define an origin or units. However by convention drivers should horizontally count unscaled samples relative to 0H (the leading edge of the horizontal sync pulse, see ”…””}”(hj¹hžhhŸNh Nubh)”}”(hŒ:ref:`vbi-hsync`”h]”hì)”}”(hjh]”hŒ vbi-hsync”…””}”(hj!hžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhjubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”j+Œreftype”Œref”Œ refexplicit”‰Œrefwarn”ˆj Œ vbi-hsync”uh1hhŸh³h KJhj¹ubhŒV). Vertically ITU-R line numbers of the first field (see ITU R-525 line numbering for ”…””}”(hj¹hžhhŸNh Nubh)”}”(hŒ:ref:`525 lines `”h]”hì)”}”(hjCh]”hŒ 525 lines”…””}”(hjEhžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhjAubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jOŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj Œvbi-525”uh1hhŸh³h KJhj¹ubhŒ and for ”…””}”(hj¹hžhhŸNh Nubh)”}”(hŒ:ref:`625 lines `”h]”hì)”}”(hjgh]”hŒ 625 lines”…””}”(hjihžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhjeubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jsŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj Œvbi-625”uh1hhŸh³h KJhj¹ubhŒ;), multiplied by two if the driver can capture both fields.”…””}”(hj¹hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h KJhjBhžhubhÞ)”}”(hXõThe top left corner, width and height of the source rectangle, that is the area actually sampled, is given by struct :c:type:`v4l2_crop` using the same coordinate system as struct :c:type:`v4l2_cropcap`. Applications can use the :ref:`VIDIOC_G_CROP ` and :ref:`VIDIOC_S_CROP ` ioctls to get and set this rectangle. It must lie completely within the capture boundaries and the driver may further adjust the requested size and/or position according to hardware limitations.”h]”(hŒuThe top left corner, width and height of the source rectangle, that is the area actually sampled, is given by struct ”…””}”(hjhžhhŸNh Nubh)”}”(hŒ:c:type:`v4l2_crop`”h]”jÂ)”}”(hj™h]”hŒ v4l2_crop”…””}”(hj›hžhhŸNh Nubah}”(h]”h ]”(h÷jãŒc-type”eh"]”h$]”h&]”uh1jÁhj—ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jãŒreftype”Œtype”Œ refexplicit”‰Œrefwarn”‰j Œ v4l2_crop”uh1hhŸh³h KVhjubhŒ, using the same coordinate system as struct ”…””}”(hjhžhhŸNh Nubh)”}”(hŒ:c:type:`v4l2_cropcap`”h]”jÂ)”}”(hj¼h]”hŒ v4l2_cropcap”…””}”(hj¾hžhhŸNh Nubah}”(h]”h ]”(h÷jãŒc-type”eh"]”h$]”h&]”uh1jÁhjºubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jãŒreftype”Œtype”Œ refexplicit”‰Œrefwarn”‰j Œ v4l2_cropcap”uh1hhŸh³h KVhjubhŒ. Applications can use the ”…””}”(hjhžhhŸNh Nubh)”}”(hŒ$:ref:`VIDIOC_G_CROP `”h]”hì)”}”(hjßh]”hŒ VIDIOC_G_CROP”…””}”(hjáhžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhjÝubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jëŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj Œ vidioc_g_crop”uh1hhŸh³h KVhjubhŒ and ”…””}”(hjhžhhŸNh Nubh)”}”(hŒ$:ref:`VIDIOC_S_CROP `”h]”hì)”}”(hjh]”hŒ VIDIOC_S_CROP”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhjubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj Œ vidioc_g_crop”uh1hhŸh³h KVhjubhŒÃ ioctls to get and set this rectangle. It must lie completely within the capture boundaries and the driver may further adjust the requested size and/or position according to hardware limitations.”…””}”(hjhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h KVhjBhžhubhÞ)”}”(hXEach capture device has a default source rectangle, given by the ``defrect`` substructure of struct :c:type:`v4l2_cropcap`. The center of this rectangle shall align with the center of the active picture area of the video signal, and cover what the driver writer considers the complete picture. Drivers shall reset the source rectangle to the default when the driver is first loaded, but not later.”h]”(hŒAEach capture device has a default source rectangle, given by the ”…””}”(hj+hžhhŸNh NubjÂ)”}”(hŒ ``defrect``”h]”hŒdefrect”…””}”(hj3hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÁhj+ubhŒ substructure of struct ”…””}”(hj+hžhhŸNh Nubh)”}”(hŒ:c:type:`v4l2_cropcap`”h]”jÂ)”}”(hjGh]”hŒ v4l2_cropcap”…””}”(hjIhžhhŸNh Nubah}”(h]”h ]”(h÷jãŒc-type”eh"]”h$]”h&]”uh1jÁhjEubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jãŒreftype”Œtype”Œ refexplicit”‰Œrefwarn”‰j Œ v4l2_cropcap”uh1hhŸh³h K_hj+ubhX. The center of this rectangle shall align with the center of the active picture area of the video signal, and cover what the driver writer considers the complete picture. Drivers shall reset the source rectangle to the default when the driver is first loaded, but not later.”…””}”(hj+hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h K_hjBhžhubhÞ)”}”(hŒFor output devices these structures and ioctls are used accordingly, defining the *target* rectangle where the images will be inserted into the video signal.”h]”(hŒRFor output devices these structures and ioctls are used accordingly, defining the ”…””}”(hjnhžhhŸNh NubhŒemphasis”“”)”}”(hŒ*target*”h]”hŒtarget”…””}”(hjxhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jvhjnubhŒC rectangle where the images will be inserted into the video signal.”…””}”(hjnhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h KghjBhžhubeh}”(h]”Œcropping-structures”ah ]”h"]”Œcropping structures”ah$]”h&]”uh1hÂhhÄhžhhŸh³h K;ubhÃ)”}”(hhh]”(hÈ)”}”(hŒScaling Adjustments”h]”hŒScaling Adjustments”…””}”(hj›hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÇhj˜hžhhŸh³h KmubhÞ)”}”(hX¼Video hardware can have various cropping, insertion and scaling limitations. It may only scale up or down, support only discrete scaling factors, or have different scaling abilities in horizontal and vertical direction. Also it may not support scaling at all. At the same time the struct :c:type:`v4l2_crop` rectangle may have to be aligned, and both the source and target rectangles may have arbitrary upper and lower size limits. In particular the maximum ``width`` and ``height`` in struct :c:type:`v4l2_crop` may be smaller than the struct :c:type:`v4l2_cropcap`. ``bounds`` area. Therefore, as usual, drivers are expected to adjust the requested parameters and return the actual values selected.”h]”(hX Video hardware can have various cropping, insertion and scaling limitations. It may only scale up or down, support only discrete scaling factors, or have different scaling abilities in horizontal and vertical direction. Also it may not support scaling at all. At the same time the struct ”…””}”(hj©hžhhŸNh Nubh)”}”(hŒ:c:type:`v4l2_crop`”h]”jÂ)”}”(hj³h]”hŒ v4l2_crop”…””}”(hjµhžhhŸNh Nubah}”(h]”h ]”(h÷jãŒc-type”eh"]”h$]”h&]”uh1jÁhj±ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jãŒreftype”Œtype”Œ refexplicit”‰Œrefwarn”‰j Œ v4l2_crop”uh1hhŸh³h Kohj©ubhŒ— rectangle may have to be aligned, and both the source and target rectangles may have arbitrary upper and lower size limits. In particular the maximum ”…””}”(hj©hžhhŸNh NubjÂ)”}”(hŒ ``width``”h]”hŒwidth”…””}”(hjÔhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÁhj©ubhŒ and ”…””}”(hj©hžhhŸNh NubjÂ)”}”(hŒ ``height``”h]”hŒheight”…””}”(hjæhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÁhj©ubhŒ in struct ”…””}”(hj©hžhhŸNh Nubh)”}”(hŒ:c:type:`v4l2_crop`”h]”jÂ)”}”(hjúh]”hŒ v4l2_crop”…””}”(hjühžhhŸNh Nubah}”(h]”h ]”(h÷jãŒc-type”eh"]”h$]”h&]”uh1jÁhjøubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jãŒreftype”Œtype”Œ refexplicit”‰Œrefwarn”‰j Œ v4l2_crop”uh1hhŸh³h Kohj©ubhŒ may be smaller than the struct ”…””}”(hj©hžhhŸNh Nubh)”}”(hŒ:c:type:`v4l2_cropcap`”h]”jÂ)”}”(hjh]”hŒ v4l2_cropcap”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”(h÷jãŒc-type”eh"]”h$]”h&]”uh1jÁhjubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jãŒreftype”Œtype”Œ refexplicit”‰Œrefwarn”‰j Œ v4l2_cropcap”uh1hhŸh³h Kohj©ubhŒ. ”…””}”(hj©hžhhŸNh NubjÂ)”}”(hŒ ``bounds``”h]”hŒbounds”…””}”(hj>hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÁhj©ubhŒz area. Therefore, as usual, drivers are expected to adjust the requested parameters and return the actual values selected.”…””}”(hj©hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h Kohj˜hžhubhÞ)”}”(hXÍApplications can change the source or the target rectangle first, as they may prefer a particular image size or a certain area in the video signal. If the driver has to adjust both to satisfy hardware limitations, the last requested rectangle shall take priority, and the driver should preferably adjust the opposite one. The :ref:`VIDIOC_TRY_FMT ` ioctl however shall not change the driver state and therefore only adjust the requested rectangle.”h]”(hXFApplications can change the source or the target rectangle first, as they may prefer a particular image size or a certain area in the video signal. If the driver has to adjust both to satisfy hardware limitations, the last requested rectangle shall take priority, and the driver should preferably adjust the opposite one. The ”…””}”(hjVhžhhŸNh Nubh)”}”(hŒ$:ref:`VIDIOC_TRY_FMT `”h]”hì)”}”(hj`h]”hŒVIDIOC_TRY_FMT”…””}”(hjbhžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhj^ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jlŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj Œ vidioc_g_fmt”uh1hhŸh³h K{hjVubhŒc ioctl however shall not change the driver state and therefore only adjust the requested rectangle.”…””}”(hjVhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h K{hj˜hžhubhÞ)”}”(hXTSuppose scaling on a video capture device is restricted to a factor 1:1 or 2:1 in either direction and the target image size must be a multiple of 16 × 16 pixels. The source cropping rectangle is set to defaults, which are also the upper limit in this example, of 640 × 400 pixels at offset 0, 0. An application requests an image size of 300 × 225 pixels, assuming video will be scaled down from the "full picture" accordingly. The driver sets the image size to the closest possible values 304 × 224, then chooses the cropping rectangle closest to the requested size, that is 608 × 224 (224 × 2:1 would exceed the limit 400). The offset 0, 0 is still valid, thus unmodified. Given the default cropping rectangle reported by :ref:`VIDIOC_CROPCAP ` the application can easily propose another offset to center the cropping rectangle.”h]”(hXÞSuppose scaling on a video capture device is restricted to a factor 1:1 or 2:1 in either direction and the target image size must be a multiple of 16 × 16 pixels. The source cropping rectangle is set to defaults, which are also the upper limit in this example, of 640 × 400 pixels at offset 0, 0. An application requests an image size of 300 × 225 pixels, assuming video will be scaled down from the “full picture†accordingly. The driver sets the image size to the closest possible values 304 × 224, then chooses the cropping rectangle closest to the requested size, that is 608 × 224 (224 × 2:1 would exceed the limit 400). The offset 0, 0 is still valid, thus unmodified. Given the default cropping rectangle reported by ”…””}”(hjˆhžhhŸNh Nubh)”}”(hŒ&:ref:`VIDIOC_CROPCAP `”h]”hì)”}”(hj’h]”hŒVIDIOC_CROPCAP”…””}”(hj”hžhhŸNh Nubah}”(h]”h ]”(h÷Œstd”Œstd-ref”eh"]”h$]”h&]”uh1hëhjubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jžŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆj Œvidioc_cropcap”uh1hhŸh³h KƒhjˆubhŒT the application can easily propose another offset to center the cropping rectangle.”…””}”(hjˆhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h Kƒhj˜hžhubhÞ)”}”(hXQNow the application may insist on covering an area using a picture aspect ratio closer to the original request, so it asks for a cropping rectangle of 608 × 456 pixels. The present scaling factors limit cropping to 640 × 384, so the driver returns the cropping size 608 × 384 and adjusts the image size to closest possible 304 × 192.”h]”hXQNow the application may insist on covering an area using a picture aspect ratio closer to the original request, so it asks for a cropping rectangle of 608 × 456 pixels. The present scaling factors limit cropping to 640 × 384, so the driver returns the cropping size 608 × 384 and adjusts the image size to closest possible 304 × 192.”…””}”(hjºhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h Khj˜hžhubeh}”(h]”Œscaling-adjustments”ah ]”h"]”Œscaling adjustments”ah$]”h&]”uh1hÂhhÄhžhhŸh³h KmubhÃ)”}”(hhh]”(hÈ)”}”(hŒExamples”h]”hŒExamples”…””}”(hjÓhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÇhjÐhžhhŸh³h K˜ubhÞ)”}”(hX Source and target rectangles shall remain unchanged across closing and reopening a device, such that piping data into or out of a device will work without special preparations. More advanced applications should ensure the parameters are suitable before starting I/O.”h]”hX Source and target rectangles shall remain unchanged across closing and reopening a device, such that piping data into or out of a device will work without special preparations. More advanced applications should ensure the parameters are suitable before starting I/O.”…””}”(hjáhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h KšhjÐhžhubhØ)”}”(hŒ~On the next two examples, a video capture device is assumed; change ``V4L2_BUF_TYPE_VIDEO_CAPTURE`` for other types of device.”h]”hÞ)”}”(hŒ~On the next two examples, a video capture device is assumed; change ``V4L2_BUF_TYPE_VIDEO_CAPTURE`` for other types of device.”h]”(hŒDOn the next two examples, a video capture device is assumed; change ”…””}”(hjóhžhhŸNh NubjÂ)”}”(hŒ``V4L2_BUF_TYPE_VIDEO_CAPTURE``”h]”hŒV4L2_BUF_TYPE_VIDEO_CAPTURE”…””}”(hjûhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÁhjóubhŒ for other types of device.”…””}”(hjóhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h K¡hjïubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hjÐhžhhŸh³h Nubeh}”(h]”Œexamples”ah ]”h"]”Œexamples”ah$]”h&]”uh1hÂhhÄhžhhŸh³h K˜ubhÃ)”}”(hhh]”(hÈ)”}”(hŒ*Example: Resetting the cropping parameters”h]”hŒ*Example: Resetting the cropping parameters”…””}”(hj$hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÇhj!hžhhŸh³h K¥ubhŒ literal_block”“”)”}”(hXstruct v4l2_cropcap cropcap; struct v4l2_crop crop; memset (&cropcap, 0, sizeof (cropcap)); cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (-1 == ioctl (fd, VIDIOC_CROPCAP, &cropcap)) { perror ("VIDIOC_CROPCAP"); exit (EXIT_FAILURE); } memset (&crop, 0, sizeof (crop)); crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; crop.c = cropcap.defrect; /* Ignore if cropping is not supported (EINVAL). */ if (-1 == ioctl (fd, VIDIOC_S_CROP, &crop) && errno != EINVAL) { perror ("VIDIOC_S_CROP"); exit (EXIT_FAILURE); }”h]”hXstruct v4l2_cropcap cropcap; struct v4l2_crop crop; memset (&cropcap, 0, sizeof (cropcap)); cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (-1 == ioctl (fd, VIDIOC_CROPCAP, &cropcap)) { perror ("VIDIOC_CROPCAP"); exit (EXIT_FAILURE); } memset (&crop, 0, sizeof (crop)); crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; crop.c = cropcap.defrect; /* Ignore if cropping is not supported (EINVAL). */ if (-1 == ioctl (fd, VIDIOC_S_CROP, &crop) && errno != EINVAL) { perror ("VIDIOC_S_CROP"); exit (EXIT_FAILURE); }”…””}”hj4sbah}”(h]”h ]”h"]”h$]”h&]”h±h²Œforce”‰Œlanguage”jãŒhighlight_args”}”uh1j2hŸh³h K§hj!hžhubeh}”(h]”Œ)example-resetting-the-cropping-parameters”ah ]”h"]”Œ*example: resetting the cropping parameters”ah$]”h&]”uh1hÂhhÄhžhhŸh³h K¥ubhÃ)”}”(hhh]”(hÈ)”}”(hŒExample: Simple downscaling”h]”hŒExample: Simple downscaling”…””}”(hjQhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÇhjNhžhhŸh³h KÂubj3)”}”(hX\struct v4l2_cropcap cropcap; struct v4l2_format format; reset_cropping_parameters (); /* Scale down to 1/4 size of full picture. */ memset (&format, 0, sizeof (format)); /* defaults */ format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; format.fmt.pix.width = cropcap.defrect.width >> 1; format.fmt.pix.height = cropcap.defrect.height >> 1; format.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; if (-1 == ioctl (fd, VIDIOC_S_FMT, &format)) { perror ("VIDIOC_S_FORMAT"); exit (EXIT_FAILURE); } /* We could check the actual image size now, the actual scaling factor or if the driver can scale at all. */”h]”hX\struct v4l2_cropcap cropcap; struct v4l2_format format; reset_cropping_parameters (); /* Scale down to 1/4 size of full picture. */ memset (&format, 0, sizeof (format)); /* defaults */ format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; format.fmt.pix.width = cropcap.defrect.width >> 1; format.fmt.pix.height = cropcap.defrect.height >> 1; format.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; if (-1 == ioctl (fd, VIDIOC_S_FMT, &format)) { perror ("VIDIOC_S_FORMAT"); exit (EXIT_FAILURE); } /* We could check the actual image size now, the actual scaling factor or if the driver can scale at all. */”…””}”hj_sbah}”(h]”h ]”h"]”h$]”h&]”h±h²jB‰jCjãjD}”uh1j2hŸh³h KÄhjNhžhubeh}”(h]”Œexample-simple-downscaling”ah ]”h"]”Œexample: simple downscaling”ah$]”h&]”uh1hÂhhÄhžhhŸh³h KÂubhÃ)”}”(hhh]”(hÈ)”}”(hŒ!Example: Selecting an output area”h]”hŒ!Example: Selecting an output area”…””}”(hjyhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÇhjvhžhhŸh³h KÞubhØ)”}”(hŒ&This example assumes an output device.”h]”hÞ)”}”(hj‰h]”hŒ&This example assumes an output device.”…””}”(hj‹hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h Kàhj‡ubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hjvhžhhŸh³h Nubj3)”}”(hXÔstruct v4l2_cropcap cropcap; struct v4l2_crop crop; memset (&cropcap, 0, sizeof (cropcap)); cropcap.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; if (-1 == ioctl (fd, VIDIOC_CROPCAP;, &cropcap)) { perror ("VIDIOC_CROPCAP"); exit (EXIT_FAILURE); } memset (&crop, 0, sizeof (crop)); crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; crop.c = cropcap.defrect; /* Scale the width and height to 50 % of their original size and center the output. */ crop.c.width /= 2; crop.c.height /= 2; crop.c.left += crop.c.width / 2; crop.c.top += crop.c.height / 2; /* Ignore if cropping is not supported (EINVAL). */ if (-1 == ioctl (fd, VIDIOC_S_CROP, &crop) && errno != EINVAL) { perror ("VIDIOC_S_CROP"); exit (EXIT_FAILURE); }”h]”hXÔstruct v4l2_cropcap cropcap; struct v4l2_crop crop; memset (&cropcap, 0, sizeof (cropcap)); cropcap.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; if (-1 == ioctl (fd, VIDIOC_CROPCAP;, &cropcap)) { perror ("VIDIOC_CROPCAP"); exit (EXIT_FAILURE); } memset (&crop, 0, sizeof (crop)); crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; crop.c = cropcap.defrect; /* Scale the width and height to 50 % of their original size and center the output. */ crop.c.width /= 2; crop.c.height /= 2; crop.c.left += crop.c.width / 2; crop.c.top += crop.c.height / 2; /* Ignore if cropping is not supported (EINVAL). */ if (-1 == ioctl (fd, VIDIOC_S_CROP, &crop) && errno != EINVAL) { perror ("VIDIOC_S_CROP"); exit (EXIT_FAILURE); }”…””}”hjžsbah}”(h]”h ]”h"]”h$]”h&]”h±h²jB‰jCjãjD}”uh1j2hŸh³h Kâhjvhžhubeh}”(h]”Œ example-selecting-an-output-area”ah ]”h"]”Œ!example: selecting an output area”ah$]”h&]”uh1hÂhhÄhžhhŸh³h KÞubhÃ)”}”(hhh]”(hÈ)”}”(hŒ0Example: Current scaling factor and pixel aspect”h]”hŒ0Example: Current scaling factor and pixel aspect”…””}”(hj¸hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÇhjµhžhhŸh³h MubhØ)”}”(hŒ,This example assumes a video capture device.”h]”hÞ)”}”(hjÈh]”hŒ,This example assumes a video capture device.”…””}”(hjÊhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝhŸh³h MhjÆubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hjµhžhhŸh³h Nubj3)”}”(hXstruct v4l2_cropcap cropcap; struct v4l2_crop crop; struct v4l2_format format; double hscale, vscale; double aspect; int dwidth, dheight; memset (&cropcap, 0, sizeof (cropcap)); cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (-1 == ioctl (fd, VIDIOC_CROPCAP, &cropcap)) { perror ("VIDIOC_CROPCAP"); exit (EXIT_FAILURE); } memset (&crop, 0, sizeof (crop)); crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (-1 == ioctl (fd, VIDIOC_G_CROP, &crop)) { if (errno != EINVAL) { perror ("VIDIOC_G_CROP"); exit (EXIT_FAILURE); } /* Cropping not supported. */ crop.c = cropcap.defrect; } memset (&format, 0, sizeof (format)); format.fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (-1 == ioctl (fd, VIDIOC_G_FMT, &format)) { perror ("VIDIOC_G_FMT"); exit (EXIT_FAILURE); } /* The scaling applied by the driver. */ hscale = format.fmt.pix.width / (double) crop.c.width; vscale = format.fmt.pix.height / (double) crop.c.height; aspect = cropcap.pixelaspect.numerator / (double) cropcap.pixelaspect.denominator; aspect = aspect * hscale / vscale; /* Devices following ITU-R BT.601 do not capture square pixels. For playback on a computer monitor we should scale the images to this size. */ dwidth = format.fmt.pix.width / aspect; dheight = format.fmt.pix.height;”h]”hXstruct v4l2_cropcap cropcap; struct v4l2_crop crop; struct v4l2_format format; double hscale, vscale; double aspect; int dwidth, dheight; memset (&cropcap, 0, sizeof (cropcap)); cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (-1 == ioctl (fd, VIDIOC_CROPCAP, &cropcap)) { perror ("VIDIOC_CROPCAP"); exit (EXIT_FAILURE); } memset (&crop, 0, sizeof (crop)); crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (-1 == ioctl (fd, VIDIOC_G_CROP, &crop)) { if (errno != EINVAL) { perror ("VIDIOC_G_CROP"); exit (EXIT_FAILURE); } /* Cropping not supported. */ crop.c = cropcap.defrect; } memset (&format, 0, sizeof (format)); format.fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (-1 == ioctl (fd, VIDIOC_G_FMT, &format)) { perror ("VIDIOC_G_FMT"); exit (EXIT_FAILURE); } /* The scaling applied by the driver. */ hscale = format.fmt.pix.width / (double) crop.c.width; vscale = format.fmt.pix.height / (double) crop.c.height; aspect = cropcap.pixelaspect.numerator / (double) cropcap.pixelaspect.denominator; aspect = aspect * hscale / vscale; /* Devices following ITU-R BT.601 do not capture square pixels. For playback on a computer monitor we should scale the images to this size. */ dwidth = format.fmt.pix.width / aspect; dheight = format.fmt.pix.height;”…””}”hjÝsbah}”(h]”h ]”h"]”h$]”h&]”h±h²jB‰jCjãjD}”uh1j2hŸh³h M hjµhžhubeh}”(h]”Œ/example-current-scaling-factor-and-pixel-aspect”ah ]”h"]”Œ0example: current scaling factor and pixel aspect”ah$]”h&]”uh1hÂhhÄhžhhŸh³h Mubeh}”(h]”(Œ1image-cropping-insertion-and-scaling-the-crop-api”hÁeh ]”h"]”(Œ5image cropping, insertion and scaling -- the crop api”Œcrop”eh$]”h&]”uh1hÂhhhžhhŸh³h Kjµ}”júh¶sj·}”hÁh¶subeh}”(h]”h ]”h"]”h$]”h&]”Œsource”h³uh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(hÇNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”j"Œerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”h³Œ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”(hÁ]”h¶aj]]”jSauŒnameids”}”(júhÁjùjöj•j’j²j]jÍjÊjjjKjHjsjpj²j¯jñjîuŒ nametypes”}”(júˆjù‰j•‰j²ˆj͉j‰jK‰js‰j²‰jñ‰uh}”(hÁhÄjöhÄj’jBj]jajÊj˜jjÐjHj!jpjNj¯jvjîjµj§jfuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”j0Ks…”R”Œparse_messages”]”Œtransform_messages”]”(hŒsystem_message”“”)”}”(hhh]”hÞ)”}”(hhh]”hŒ*Hyperlink target "crop" is not referenced.”…””}”hjsbah}”(h]”h ]”h"]”h$]”h&]”uh1hÝhjŠubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”ŒINFO”Œsource”h³Œline”Kuh1jˆubj‰)”}”(hhh]”hÞ)”}”(hhh]”hŒ0Hyperlink target "crop-scale" is not referenced.”…””}”hj¨sbah}”(h]”h ]”h"]”h$]”h&]”uh1hÝhj¥ubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”j¢Œsource”h³Œline”K>uh1jˆubeŒ transformer”NŒ include_log”]”Œ decoration”Nhžhub.