LitchiCheng 发表于 2024-3-9 20:24

RV1106手把手教你:4行代码使用linux v4l2接口调用usb摄像头连续拍照保存

<div class='showpostmsg'> 本帖最后由 LitchiCheng 于 2024-3-9 21:21 编辑

<p> &nbsp;</p>

<p>针对v4l2进行了C++库的封装,方便后面集成其他的测试中使用,仓库地址如下,有兴趣的可以clone,麻烦给个星</p>

<article data-content="[{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;3060-1621846615933&quot;,&quot;name&quot;:&quot;paragraph&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;p5PQ-1621846617594&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;针对v4l2进行了C++库的封装,方便后面集成其他的测试中使用,仓库地址如下,有兴趣的可以clone,麻烦给个星&quot;,&quot;marks&quot;:[]}]}],&quot;state&quot;:{}},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;q4GM-1709986797455&quot;,&quot;name&quot;:&quot;paragraph&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;AbeI-1709986797449&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;&quot;,&quot;marks&quot;:[]}]},{&quot;type&quot;:&quot;inline&quot;,&quot;id&quot;:&quot;XAVo-1708767960961&quot;,&quot;name&quot;:&quot;link&quot;,&quot;data&quot;:{&quot;href&quot;:&quot;https://github.com/LitchiCheng/RV1106_Linux/tree/main&quot;},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;Ct0g-1708767960962&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;LitchiCheng/RV1106_Linux: Linux test for RV1106 dev board (github.com)&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;G58s-1708767960967&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;&quot;,&quot;marks&quot;:[]}]}],&quot;state&quot;:{}},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;Z6Iw-1709735771021&quot;,&quot;name&quot;:&quot;paragraph&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;5p66-1709735771017&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;如下为调用usb摄像头,连续拍照保存的测试代码&quot;,&quot;marks&quot;:[]}]}],&quot;state&quot;:{}},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;j4rx-1709735831614&quot;,&quot;name&quot;:&quot;code&quot;,&quot;data&quot;:{&quot;wrap&quot;:false,&quot;language&quot;:&quot;&quot;,&quot;theme&quot;:&quot;default&quot;},&quot;nodes&quot;:[{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;QBtO-1709735831613&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;LmeH-1709735831612&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;#include &lt;iostream&gt;&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;tEjh-1709735832212&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;ZAsF-1709735832211&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;#include \&quot;v4l2CapPicTool.h\&quot;&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;wUaO-1709735832214&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;s2lL-1709735832213&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;#include \&quot;timecost.h\&quot;&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;FPTn-1709735832216&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;Mqrc-1709735832215&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;AoJw-1709735832218&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;Z1UZ-1709735832217&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;int main(int argc, char const *argv[])&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;CN3d-1709735832220&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;pmPK-1709735832219&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;{&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;4euL-1709735832222&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;YSrk-1709735832221&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;    v4l2CapPicTool vt(\&quot;/dev/video0\&quot;, 1080, 960, \&quot;jpg\&quot;);&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;sz8i-1709735832224&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;5Ycb-1709735832223&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;    vt.init();&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;55yl-1709735832226&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;rMxJ-1709735832225&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;    while (1){&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;zxJ6-1709735832230&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;KSfT-1709735832229&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;        usleep(100000);&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;KwRv-1709735832232&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;BXoW-1709735832231&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;        {&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;bTSS-1709735832234&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;skkY-1709735832233&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;            timecost tmp(\&quot;capture\&quot;);&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;wyOa-1709735832236&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;Yrry-1709735832235&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;            vt.capture();&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;Wyhh-1709735832238&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;Mmox-1709735832237&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;        }  &quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;h41q-1709735832242&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;02L1-1709735832241&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;        {&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;71nF-1709735832244&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;ouwR-1709735832243&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;            timecost tmp(\&quot;save\&quot;);&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;ALnq-1709735832246&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;GaMa-1709735832245&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;            vt.save(\&quot;./test.jpg\&quot;); &quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;isVE-1709735832248&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;6CfD-1709735832247&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;        }&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;iQMI-1709735832250&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;k32d-1709735832249&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;    }&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;hldJ-1709735832252&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;48o8-1709735832251&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;    return 0;&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;Dfmh-1709735832254&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;skK0-1709735832253&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;}&quot;,&quot;marks&quot;:[]}]}]}],&quot;state&quot;:{}},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;7d3j-1709735831615&quot;,&quot;name&quot;:&quot;paragraph&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;nnA7-1709735831616&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;同时测试,capture所花费的时间&quot;,&quot;marks&quot;:[]}]}],&quot;state&quot;:{}},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;jmYr-1709735982846&quot;,&quot;name&quot;:&quot;code&quot;,&quot;data&quot;:{&quot;wrap&quot;:false,&quot;language&quot;:&quot;&quot;,&quot;theme&quot;:&quot;default&quot;},&quot;nodes&quot;:[{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;MYBF-1709735982845&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;0hL1-1709735982844&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;pico@luckfox:~$ sudo ./captureJpgApp\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;UWTf-1709735983096&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;7Qle-1709735983095&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;init success\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;wE5b-1709735983098&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;5lIT-1709735983097&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;capturetime spent:0.382155sec\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;LcG4-1709735983100&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;cefT-1709735983099&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;savetime spent:0.003527sec\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;vyjc-1709735983102&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;z5TR-1709735983101&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;capturetime spent:0.073295sec\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;14CE-1709735983104&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;I340-1709735983103&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;savetime spent:0.001937sec\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;dH9m-1709735983106&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;t7vF-1709735983105&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;capturetime spent:0.030448sec\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;V7hL-1709735983108&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;fcmr-1709735983107&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;savetime spent:0.003411sec\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;MhHQ-1709735983110&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;smeY-1709735983109&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;capturetime spent:0.025701sec\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;5KOx-1709735983112&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;YpCJ-1709735983111&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;savetime spent:0.001992sec\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;uDB6-1709735983114&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;afdh-1709735983113&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;capturetime spent:0.031095sec\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;iT0p-1709735983116&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;mCmS-1709735983115&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;savetime spent:0.003586sec\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;8KcE-1709735983118&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;P2fY-1709735983117&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;capturetime spent:0.025089sec\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;JkDY-1709735983120&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;7zF9-1709735983119&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;savetime spent:0.004171sec\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;wU7T-1709735983122&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;9SLC-1709735983121&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;capturetime spent:0.02678sec\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;IcPV-1709735983124&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;Sc34-1709735983123&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;savetime spent:0.001836sec\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;kijs-1709735983126&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;CyeJ-1709735983125&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;capturetime spent:0.031064sec\r&quot;,&quot;marks&quot;:[]}]}]},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;JHGi-1709735983128&quot;,&quot;name&quot;:&quot;code-line&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;ASjx-1709735983127&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;savetime spent:0.001938sec&quot;,&quot;marks&quot;:[]}]}]}],&quot;state&quot;:{}},{&quot;type&quot;:&quot;block&quot;,&quot;id&quot;:&quot;1dDP-1709736019317&quot;,&quot;name&quot;:&quot;paragraph&quot;,&quot;data&quot;:{},&quot;nodes&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;id&quot;:&quot;9pft-1709736019318&quot;,&quot;leaves&quot;:[{&quot;text&quot;:&quot;可以看到,capture所花费的时间大概在0.03s左右,也就是30ms一帧,对应就是30fps&quot;,&quot;marks&quot;:[]}]}],&quot;state&quot;:{}}]">
<p><a href="https://github.com/LitchiCheng/RV1106_Linux/tree/main">LitchiCheng/RV1106_Linux: Linux test for RV1106 dev board (github.com)</a></p>

<p>如下为调用usb摄像头,连续拍照保存的测试代码</p>

<pre>
<code>#include &lt;iostream&gt;
#include "v4l2CapPicTool.h"
#include "timecost.h"

int main(int argc, char const *argv[])
{
    v4l2CapPicTool vt("/dev/video0", 1080, 960, "jpg");
    vt.init();
    while (1){
      usleep(100000);
      {
            timecost tmp("capture");
            vt.capture();
      }
      {
            timecost tmp("save");
            vt.save("./test.jpg");
      }
    }
    return 0;
}</code></pre>

<p>同时测试,capture所花费的时间</p>

<pre>
<code>pico@luckfox:~$ sudo ./captureJpgApp
init success
capturetime spent:0.382155sec
savetime spent:0.003527sec
capturetime spent:0.073295sec
savetime spent:0.001937sec
capturetime spent:0.030448sec
savetime spent:0.003411sec
capturetime spent:0.025701sec
savetime spent:0.001992sec
capturetime spent:0.031095sec
savetime spent:0.003586sec
capturetime spent:0.025089sec
savetime spent:0.004171sec
capturetime spent:0.02678sec
savetime spent:0.001836sec
capturetime spent:0.031064sec
savetime spent:0.001938sec</code></pre>

<p>可以看到,capture所花费的时间大概在0.03s左右,也就是30ms一帧,对应就是30fps</p>

<p><iframe allowfullscreen="true" frameborder="0" height="450" src="//player.bilibili.com/player.html?bvid=1tK421x7my&amp;page=1" style="background:#eee;margin-bottom:10px;" width="700"></iframe><br />
&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>
</article>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>
</div><script>                                var loginstr = '<div class="locked">查看精华帖全部内容,请<a href="javascript:;"   style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
                               
                                if(parseInt(discuz_uid)==0){
                                                                                        (function($){
                                                        var postHeight = getTextHeight(400);
                                                        $(".showpostmsg").html($(".showpostmsg").html());
                                                        $(".showpostmsg").after(loginstr);
                                                        $(".showpostmsg").css({height:postHeight,overflow:"hidden"});
                                                })(jQuery);
                                }
</script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script>

damiaa 发表于 2024-3-10 10:25

<p>感谢楼主分享!</p>

LitchiCheng 发表于 2024-3-10 11:20

damiaa 发表于 2024-3-10 10:25
感谢楼主分享!

<p>谢谢支持</p>

常见泽1 发表于 2024-3-10 11:38

<p>这玩意 看着是不是和opencv差不多</p>

LitchiCheng 发表于 2024-3-10 17:38

常见泽1 发表于 2024-3-10 11:38
这玩意 看着是不是和opencv差不多

<p>不是一个概念,opencv调用摄像头也是通过v4l2,但opencv更重要的是图像处理这些东西</p>

biubiubiub 发表于 2024-9-18 23:13

<p>请问怎么连接CSI相机呢</p>
页: [1]
查看完整版本: RV1106手把手教你:4行代码使用linux v4l2接口调用usb摄像头连续拍照保存