OpenCV SIGSEGV C++ minGW
OpenCV SIGSEGV C++ minGW
即使在简单的程序中也有内存和异常错误。代码块+调试中的mingw - SIGSEGV,调用堆栈 - user32.dll。运行时崩溃并出现0xc0000005错误。VC 也会崩溃,并出现未经处理的异常。
#include "opencv2/video/tracking.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include <iostream>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
CvCapture* capture = cvCreateCameraCapture(CV_CAP_ANY); //cvCaptureFromCAM( 0 );
assert( capture );
IplImage* frame=0;
cvNamedWindow("capture", CV_WINDOW_AUTOSIZE);
int counter=0;
char filename[512];
while(true){
frame = cvQueryFrame( capture );
cvShowImage("capture", frame);
char c = cvWaitKey(33);
if (c == 27) {
break;
}
}
cvReleaseCapture( &capture );
cvDestroyWindow("capture");
return 0;
}
我在您的代码中没有看到任何错误。也许这是一些库的错误。
但是你为什么要使用这个旧的OpenCV版本。有了C++,它就更容易了
#include "opencv2/opencv.hpp"
using namespace cv;
int main(int, char**)
{
VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) // check if we succeeded
return -1;
while(true)
{
Mat frame;
cap >> frame; // get a new frame from camera
imshow("frame", frame);
if(waitKey(30) >= 0) break;
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
}
您是否尝试交换以下行:
cvDestroyWindow("capture");
和
cvReleaseCapture( &capture );
我相信你应该比cvReleaseCapture
更早打电话给cvDestroyWindow
.我认为窗户成了capture
的主人,应该先被摧毁。
相关文章:
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 如何将C++中的库和头与MinGW一起使用
- 为什么与常规GCC不同,即使有"学究性错误",MinGW-GCC也能容忍丢失的返回类型
- 无法在windows上使用mingw将sqlite3与c连接
- MinGw 无法从 cmake 编译测试文件
- MSYS2 MinGW程序包中缺少grpc_cpp_plugin协议
- Mingw-64 在构建和安装后不会编译 openCV 代码
- 安装MinGW后C++编译器不起作用?
- 当我尝试通过 mingw 使用 CMake 和 SFML 库编译项目时出错
- 如何在 Linux for Windows 上通过 MinGW 构建静态 ICU 的 Boost
- 使用 MinGW 在 Windows 上安装 GMP 时出错
- VSCode - C++ - MinGW 编译器的问题
- C++:如何在Windows 10上使用编译器MinGW 9.2.0安装OpenCV
- MINGW - 正确运行函数所需的 cdecl
- 尝试在Windows上执行C++时出错(通过MinGW编译)
- 分段 Linux Ubuntu 中的 g++ 错误,但在 Windows 中的 g++/MingW 中,在 C++ 中打
- SFML 库 - 在 MinGW 构建期间未找到错误
- 使用 MinGW 在 Windows 上构建 GLEW 时遇到问题
- 如何使用命令提示符、记事本和 MinGW 使用主文件、头文件和实现文件编译C++程序?
- 如何构建一个 setup.py 来编译C++使用 Python、pybind11 和 Mingw-w64 的扩展?