<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[获取图像的测试代码，依赖opencv4.2的动态库，测试可以正常出图，用opencv4.6的库出现cap.isOpened()返回false]]></title><description><![CDATA[<pre><code>//#include &lt;opencv2/opencv.hpp&gt;
#include "AlgorithmAT.h"
#include "AlgorithmSLF.h"
#include &lt;opencv.hpp&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;
//using namespace std;
int main(int argc, char* argv[])
{
	
	int width = 1080;
    int height = 1080;
    int fps = 30;

    if (argc &gt; 1) {
        width = std::stoi(argv[1]);
    }
    if (argc &gt; 2) {
        height = std::stoi(argv[2]);
    }
    if (argc &gt; 3) {
        fps = std::stoi(argv[3]);
    }

	//创建客户端实例
	AlgorithmAT* at = new AlgorithmAT();

	std::string configPath = "/home/gensong/project/ATDllDemo/config/config.yaml";
	std::string algorithmConfigPath = "/home/gensong/project/ATDllDemo/config/algorithmConfig.yaml";
	at-&gt;Init(configPath,algorithmConfigPath);

	int launchMode = 0;
	//cv::Mat src_frame = cv::imread("/home/gensong/project/ATDllDemo/picture/1.jpg");
	//bool ret_val = cap.read(src_frame);

	std::string v4l2_cmd = "media-ctl -d /dev/video0 --set-v4l2 '\"m00_b_mvcam 7-003b\":0[fmt:Y8_1X8/" + std::to_string(width) + "x" + std::to_string(height) + "@1/" + std::to_string(fps) + " field:none]'";
    system(v4l2_cmd.c_str());
    printf("func is %s,%d\n",__func__,__LINE__);
    cv::VideoCapture cap("v4l2src io-mode=dmabuf device=/dev/video0 ! video/x-raw, format=(string)GRAY8, width=(int)" + std::to_string(width) + ", height=(int)" + std::to_string(height) + " ! appsink");
	
    printf("func is %s,%d\n",__func__,__LINE__);
    if (cap.isOpened()) {
        printf("func is %s,%d\n",__func__,__LINE__);
        while (true) {
			cv::Mat src_frame;
            printf("func is %s,%d\n",__func__,__LINE__);
            bool ret_val = cap.read(src_frame);
            printf("func is %s,%d,ret_val is %d\n",__func__,__LINE__,ret_val);
            if (ret_val) {
                cv::imshow("demo", src_frame);
                cv::waitKey(1);

				long long frameTime = 20240222153410123;
				std::vector&lt;Algorithm_Pos_t&gt; locRes;
				cv::Mat dst_frame;
   				cv::medianBlur(src_frame, dst_frame, 5); // 
				bool retPos = at-&gt;GetPos(launchMode,dst_frame,frameTime,locRes);
				std::cout &lt;&lt; "retPos:" &lt;&lt; retPos &lt;&lt; std::endl;

				vector&lt;Algorithm_Pos_t&gt;::iterator locItem;
				for(locItem = locRes.begin();locItem != locRes.end();locItem++)
				{
					std::cout &lt;&lt; "id:" &lt;&lt; (*locItem).id &lt;&lt; std::endl;
					std::cout &lt;&lt; "timeDelay:" &lt;&lt; (*locItem).timeDelay &lt;&lt; std::endl;
					std::cout &lt;&lt; "x:" &lt;&lt; (*locItem).x &lt;&lt; std::endl;
					std::cout &lt;&lt; "y:" &lt;&lt; (*locItem).y &lt;&lt; std::endl;
					std::cout &lt;&lt; "z:" &lt;&lt; (*locItem).z &lt;&lt; std::endl;
					std::cout &lt;&lt; "yaw:" &lt;&lt; (*locItem).yaw &lt;&lt; std::endl;
					std::cout &lt;&lt; "pitch:" &lt;&lt; (*locItem).pitch &lt;&lt; std::endl;
					std::cout &lt;&lt; "roll:" &lt;&lt; (*locItem).roll &lt;&lt; std::endl;
					std::cout &lt;&lt; "id:" &lt;&lt; (*locItem).id &lt;&lt; std::endl;
				}
            } else {
                std::cout &lt;&lt; "camera open failed" &lt;&lt; std::endl;
                break;
            }
        }
    } else {
        printf("func is %s,%d\n",__func__,__LINE__);
        std::cout &lt;&lt; "camera open failed" &lt;&lt; std::endl;
    }

	cv::destroyAllWindows();
	
	//接收并打印数据
	// while(true)
	// {
	// 	//std::cout&lt;&lt; "getPose:"&lt;&lt;vision.aprilTag_t.id&lt;&lt;"-"&lt;&lt;vision.aprilTag_t.x&lt;&lt;"-"&lt;&lt;vision.aprilTag_t.y&lt;&lt;"-"&lt;&lt;vision.aprilTag_t.z&lt;&lt;std::endl;
	// 	usleep(30*1000);
	// }
		
	return 0;
}
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1708680624237-f47c4ad2-867b-4045-8d75-ee3bfafd30ac-image.png" alt="f47c4ad2-867b-4045-8d75-ee3bfafd30ac-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>http://forum.veye.cc/topic/561/获取图像的测试代码-依赖opencv4-2的动态库-测试可以正常出图-用opencv4-6的库出现cap-isopened-返回false</link><generator>RSS for Node</generator><lastBuildDate>Thu, 08 Oct 2026 15:40:31 GMT</lastBuildDate><atom:link href="http://forum.veye.cc/topic/561.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 23 Feb 2024 09:30:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 获取图像的测试代码，依赖opencv4.2的动态库，测试可以正常出图，用opencv4.6的库出现cap.isOpened()返回false on Thu, 25 Jul 2024 07:34:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/nb" aria-label="Profile: nb">@<bdi>nb</bdi></a> 您好，我遇到了类似的问题，请问一下您的解决方案就是将4.6的opencv更换成4.2的opencv吗？</p>
]]></description><link>http://forum.veye.cc/post/4320</link><guid isPermaLink="true">http://forum.veye.cc/post/4320</guid><dc:creator><![CDATA[w88121446]]></dc:creator><pubDate>Thu, 25 Jul 2024 07:34:54 GMT</pubDate></item><item><title><![CDATA[Reply to 获取图像的测试代码，依赖opencv4.2的动态库，测试可以正常出图，用opencv4.6的库出现cap.isOpened()返回false on Wed, 28 Feb 2024 02:12:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/nb" aria-label="Profile: nb">@<bdi>nb</bdi></a> 好的。真棒~</p>
]]></description><link>http://forum.veye.cc/post/3827</link><guid isPermaLink="true">http://forum.veye.cc/post/3827</guid><dc:creator><![CDATA[veye_xumm]]></dc:creator><pubDate>Wed, 28 Feb 2024 02:12:38 GMT</pubDate></item><item><title><![CDATA[Reply to 获取图像的测试代码，依赖opencv4.2的动态库，测试可以正常出图，用opencv4.6的库出现cap.isOpened()返回false on Tue, 27 Feb 2024 05:53:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/veye_xumm" aria-label="Profile: veye_xumm">@<bdi>veye_xumm</bdi></a> said in <a href="/post/3823">获取图像的测试代码，依赖opencv4.2的动态库，测试可以正常出图，用opencv4.6的库出现cap.isOpened()返回false</a>:</p>
<blockquote>
<p dir="auto">好意思，回复的晚了。 我们对opencv的研究并不深入，只是给了一个简单的调试demo。 我想这个问题我现在无法给您准确的回复</p>
</blockquote>
<p dir="auto">好的 谢谢 这个问题 我已经自己解决了的</p>
]]></description><link>http://forum.veye.cc/post/3824</link><guid isPermaLink="true">http://forum.veye.cc/post/3824</guid><dc:creator><![CDATA[nb]]></dc:creator><pubDate>Tue, 27 Feb 2024 05:53:13 GMT</pubDate></item><item><title><![CDATA[Reply to 获取图像的测试代码，依赖opencv4.2的动态库，测试可以正常出图，用opencv4.6的库出现cap.isOpened()返回false on Mon, 26 Feb 2024 06:03:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/nb" aria-label="Profile: nb">@<bdi>nb</bdi></a> said in <a href="/post/3822">获取图像的测试代码，依赖opencv4.2的动态库，测试可以正常出图，用opencv4.6的库出现cap.isOpened()返回false</a>:</p>
<blockquote>
<p dir="auto">麻烦问下   cv::VideoCapture cap("v4l2src io-mode=dmabuf device=/dev/video0 ! video/x-raw, format=(string)GRAY8, width=(int)" + std::to_string(width) + ", height=(int)" + std::to_string(height) + " ! appsink");    和   cv::VideoCapture cap("/home/gensong/test.mp4");   两者的区别是什么？  为什么    cv::VideoCapture cap("/home/gensong/test.mp4");   就可以打开视频，  而   cv::VideoCapture cap("v4l2src io-mode=dmabuf device=/dev/video0 ! video/x-raw, format=(string)GRAY8, width=(int)" + std::to_string(width) + ", height=(int)" + std::to_string(height) + " ! appsink");  就会提示  cap.isOpened()返回false</p>
</blockquote>
<p dir="auto">不好意思，回复的晚了。 我们对opencv的研究并不深入，只是给了一个简单的调试demo。 我想这个问题我现在无法给您准确的回复。</p>
]]></description><link>http://forum.veye.cc/post/3823</link><guid isPermaLink="true">http://forum.veye.cc/post/3823</guid><dc:creator><![CDATA[veye_xumm]]></dc:creator><pubDate>Mon, 26 Feb 2024 06:03:10 GMT</pubDate></item><item><title><![CDATA[Reply to 获取图像的测试代码，依赖opencv4.2的动态库，测试可以正常出图，用opencv4.6的库出现cap.isOpened()返回false on Sun, 25 Feb 2024 02:26:20 GMT]]></title><description><![CDATA[<p dir="auto">麻烦问下   cv::VideoCapture cap("v4l2src io-mode=dmabuf device=/dev/video0 ! video/x-raw, format=(string)GRAY8, width=(int)" + std::to_string(width) + ", height=(int)" + std::to_string(height) + " ! appsink");    和   cv::VideoCapture cap("/home/gensong/test.mp4");   两者的区别是什么？  为什么    cv::VideoCapture cap("/home/gensong/test.mp4");   就可以打开视频，  而   cv::VideoCapture cap("v4l2src io-mode=dmabuf device=/dev/video0 ! video/x-raw, format=(string)GRAY8, width=(int)" + std::to_string(width) + ", height=(int)" + std::to_string(height) + " ! appsink");  就会提示  cap.isOpened()返回false</p>
]]></description><link>http://forum.veye.cc/post/3822</link><guid isPermaLink="true">http://forum.veye.cc/post/3822</guid><dc:creator><![CDATA[nb]]></dc:creator><pubDate>Sun, 25 Feb 2024 02:26:20 GMT</pubDate></item><item><title><![CDATA[Reply to 获取图像的测试代码，依赖opencv4.2的动态库，测试可以正常出图，用opencv4.6的库出现cap.isOpened()返回false on Sun, 25 Feb 2024 02:21:29 GMT]]></title><description><![CDATA[<p dir="auto">#include &lt;opencv.hpp&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;string&gt;</p>
<p dir="auto">int main() {<br />
cv::VideoCapture cap("/home/gensong/test.mp4");  // 打开本地视频文件<br />
if (!cap.isOpened()) {             // 检查文件是否成功打开<br />
std::cout &lt;&lt; "Failed to open video file!" &lt;&lt; std::endl;<br />
return -1;<br />
}</p>
<pre><code>cv::Mat frame;
while (cap.read(frame)) {          // 读取每一帧画面
    cv::imshow("Video", frame);    // 显示视频
    cv::waitKey(1);
}

cap.release();                     // 释放资源

return 0;
</code></pre>
<p dir="auto">}  基于opencv4.6的库 用这个代码可以正常打开播放视频</p>
]]></description><link>http://forum.veye.cc/post/3821</link><guid isPermaLink="true">http://forum.veye.cc/post/3821</guid><dc:creator><![CDATA[nb]]></dc:creator><pubDate>Sun, 25 Feb 2024 02:21:29 GMT</pubDate></item></channel></rss>