gpt4 book ai didi

c++ - 调用 `cvCreateCameraCapture(-1)`时异常终止

转载 作者:行者123 更新时间:2023-11-28 08:10:39 25 4
gpt4 key购买 nike

我的代码如下。当我在 openCamera 中执行 cvCreateCameraCapture(-1) 时,应用程序结束。

提示:程序异常终止。在启动过程中程序以代码 0X000135 退出

为什么?电脑是笔记本,内置摄像头。

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

>

#include<highgui.h>
#include<cv.h>

class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

private slots:
void openCamera();
void readFrame();
void closeCamera();
void takingPhote();

private:
Ui::MainWindow *ui;
QTimer* timer;
QImage* image;
CvCapture* cam;
IplImage* frame;
};

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
cam = NULL;
timer = new QTimer(this);
image = new QImage;

connect(ui->openCamera, SIGNAL(clicked()), this, SLOT(openCamera()));
}

void MainWindow::openCamera()
{
cam = cvCreateCameraCapture(-1);
// timer->start(33);
// connect(timer, SIGNAL(timeout()), this, SLOT(readFrame()));
}

最佳答案

添加我之前的评论作为答案,因为它帮助您解决了问题:

I want you to replace the cvCreateCameraCapture() call for something else, like cvWaitKey(0);. If this is a runtime issue related to environment variables and Windows not finding OpenCV, this simple test will show. So, if it continues to crash then it might really be related to the environment configuration.

关于c++ - 调用 `cvCreateCameraCapture(-1)`时异常终止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9173310/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com