1 Star 0 Fork 14

dlpc/ccface

forked from zhouxiang/ccface 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
opencvcamera.cpp 1.39 KB
一键复制 编辑 原始数据 按行查看 历史
zhouxiang 提交于 2015-05-11 21:00 . create pro
#include "opencvcamera.h"
//#include <QSGSimpleTextureNode>
//#include <QQuickWindow>
//#include <QTimer>
#include <QDebug>
OpenCVcamera::OpenCVcamera(QObject *parent): OpenCVcapture(parent),
m_cameraId(0),
m_openedCameraId(-1),
m_iplImage(NULL),
m_cvCapture(NULL)
{
}
OpenCVcamera::~OpenCVcamera()
{
if (m_cvCapture != NULL) {
cvReleaseCapture(&m_cvCapture);
m_cvCapture = NULL;
}
m_iplImage = NULL;
}
int OpenCVcamera::cameraId() const
{
return m_cameraId;
}
void OpenCVcamera::setCameraId(int id)
{
m_cameraId = id;
}
void OpenCVcamera::setRun(bool r)
{
m_run = r;
if (m_run) {
if (m_cvCapture == NULL) {
m_cvCapture = cvCreateCameraCapture(m_cameraId);
m_openedCameraId = m_cameraId;
} else if (m_cameraId != m_openedCameraId){
cvReleaseCapture(&m_cvCapture);
m_cvCapture = NULL;
m_cvCapture = cvCreateCameraCapture(m_cameraId);
m_openedCameraId = m_cameraId;
}
} else {
if (m_cvCapture) {
cvReleaseCapture(&m_cvCapture);
m_cvCapture = NULL;
//m_cameraId = 0;
m_openedCameraId = -1;
}
}
}
IplImage* OpenCVcamera::getFrame()
{
if (m_cvCapture) {
m_iplImage = cvQueryFrame(m_cvCapture);
} else {
m_iplImage = NULL;
}
return m_iplImage;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/dlpc/ccface.git
git@gitee.com:dlpc/ccface.git
dlpc
ccface
ccface
master

搜索帮助