私はこの問題で数日間立ち往生しており、助けを求めようと思いました. 私の問題を表示するためにこのテストコードを書きました
これは私の撮影機能です
cv::Mat takePicture(){
cv::Mat pic;
VideoCapture cam(0);
if(!cam.isOpened()){
std::cout << "Failed to make connection to Cam" << std::endl;
exit(1);
}
cam.set(CV_CAP_PROP_FRAME_WIDTH, 320);
cam.set(CV_CAP_PROP_FRAME_HEIGHT, 240);
cam >> pic;
cvWaitKey(100);
return pic.clone();
}
これは、クラッシュを引き起こすメイン関数のループです
if(test_mode == true){
while(true){
Mat testImg;
char fileName[50];
sprintf(fileName, "testFile%d", threadNo);
testImg = takePicture();
cout << "current pic is " << threadNo << endl;
threadNo++;
testImg.release();
}
}
プログラムは画像27まで正常に実行され、その後遅くなり、画像30までにさまざまなエラーが発生します
mmap: Cannot allocate memory
munmap: Invalid argument
Unable to stop the stream.: Bad file descriptor
libv4l1: error allocating v4l1 buffers: Cannot allocate memory
HIGHGUI ERROR: V4L: Mapping Memmory from video source error: Invalid argument
HIGHGUI ERROR: V4L: Initial Capture Error: Unable to load initial memory buffers
*** glibc detected *** ./Cam: free(): invalid pointer: 0x0076ab88 ***
Aborted
これはリークが原因であるに違いないと考え続けています。助けてくれてありがとう。