在 gstreamer 元素中打开 OpenCV 窗口
Opening an OpenCV window in a gstreamer element
我正在尝试做一个非常基本的Gstreamer元素,该元素打开一个带有图像的OpenCV窗口。
在我的元素中,我有一个链函数,它只调用名为 select_points() 的窗口打开函数,该函数在 select_points.cpp 中。
chain_function:
static GstFlowReturn
gst_georeg_chain (GstPad * pad, GstBuffer * buf)
{
GstGeoreg *filter;
georeg_val gvals;
filter = GST_GEOREG (GST_OBJECT_PARENT (pad));
get_data(&gvals);
select_points(&gvals);
return gst_pad_push (filter->srcpad, buf);
}
现在在我的select_points.cpp中,我有以下代码
#include <stdio.h>
#include "datasetup.h"
#include <opencv/cv.h>
#include <opencv/highgui.h>
using namespace cv;
extern "C" void select_points(georeg_val *gvals) //plugin is in C
{
IplImage* img=0;
img=cvLoadImage(gvals->imageName,1);
if(!img)
{
printf("Could not load image file: n$%s$n",gvals->imageName);
}
else
{
printf("Image was loadedn");
cvNamedWindow("Select", CV_WINDOW_AUTOSIZE);
cvMoveWindow("Select", 200, 200); // offset from the UL corner of the screen
cvShowImage("Select",img);
cvDestroyWindow("Select");
cvReleaseImage(&img);
}
}
问题是当我使用我的元素运行管道时,它在调用 cvNamedWindow 时挂起。有什么建议吗?如果我注释掉 select_points(),其他一切都很好。
首先,在激活 gstreamer 管道之前,将cvNamedWindow()
移出select_points()
并移入 main()
函数。
其次,如果要查看窗口,则必须在调用cvShowImage()
后添加对cvWaitKey(0);
的调用。否则,您最终将显示图像并立即破坏窗口,使其不显示任何内容。
:)
相关文章:
- 如果不在窗口 10 中声明名为 openCV 的 openCV namedWindow,QT 图像显示将无法正常工作
- 检测 OpenCV C++窗口上的触摸
- Opencv在2013年第5季度不起作用.应用程序总是在窗口中崩溃
- OpenCV 在窗口关闭时中止(核心转储)
- 有没有办法拿一个opencv显示窗口并将其保存到GUI窗口?
- opencv+SaperaLT++ 多个不需要的窗口与垃圾名称
- 如何使用Opencv,qt creator,ming gw窗口在一起
- 如何使用OpenCV在不同的显示器中显示不同的窗口
- 用于 Opencv 3.3.0 窗口的非自由模块
- 一秒钟后,OpenCV窗口消失了
- OpenCV在我移动命名窗口时崩溃
- destroyWindow(来自opencv)关闭所有窗口并停止c ++程序
- OSG窗口阻止OpenCV窗口的刷新
- 在 gstreamer 元素中打开 OpenCV 窗口
- 如何检查opencv窗口是否已关闭
- 使用关闭按钮关闭Opencv窗口
- 试图关闭OpenCV窗口没有效果
- opencv窗口在鼠标回调时未刷新
- 创建样本在哪里.exe?- OpenCV窗口
- 采用OpenCV窗口,并使全屏