나는 라스베리 파이와 카메라 인터페이스를 위해 opencv에서 코드를 완성했습니다. 나는 소스 파일에 포함하고있는 camera.h 파일을 만들었습니다. 제대로 작동하고 있습니다. 그러나, 내 주요 프로그램에서 나는 capture_image() 함수에서 캡처 한 프레임이 필요합니다.OpenCV 카메라 문제 :
이#include<opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <stdio.h>
using namespace cv
using namespace std;
int n = 0;
static char cam_image[200];
int capture_image() {
VideoCapture capture(2); //try to open string, this will attempt to open it as a video file or image sequence
if (!capture.isOpened()) //if this fails, try to open as a video camera, through the use of an integer param
capture.open(2);
if (!capture.isOpened()) {
cerr << "Failed to open the video device, video file or image sequence!\n" << endl;
//help(av);
return 1;
}
string window_name = "Reference Image";
namedWindow(window_name, CV_WINDOW_KEEPRATIO); //resizable window;
Mat frame;
capture >> frame;
if (frame.empty());
imshow(window_name, frame);
waitKey(30);
sprintf(cam_image,"filename%.3d.jpg",n++);
imwrite(cam_image,frame);
cout << "Saved " << cam_image << endl;
return 0;// Actually I want return (frame)
}
오류가 :
camera.h: In function ‘int capture_image()’:
camera.h:34:17: error: invalid conversion from ‘cv::Mat*’ to ‘int’ [-fpermissive]
camera.h:24:13: warning: address of local variable ‘frame’ returned [enabled by default]
그것은 논리입니다
내 기능 capture_image()의 마지막 프레임을 반환하려면이
다음내 코드입니다 int 함수는 int를 반환합니다. 하지만, 나는 어떻게 정의 해야할지 모르겠다 cv :: Mat function(). 도와주세요.
당신이 바로 거기에 있었다 프레임 '을 생성하고 정수 오류 코드를 반환 할 수 없습니다. 다른 방법으로, 함수를'int capture_image (cv :: Mat & frame) {...; 모자 >> 프레임; ...}'를 사용하면 오류 코드 및/또는 프레임을 반환 할 수 있습니다. –
나는 cv :: Mat capture_image (void) {... return frame}과 똑같은 것을 사용하려했지만 camera.h 오류가 발생했습니다 : 'cv :: Mat capture_image()'함수에서 : camera.h : 20:16 : 오류 : 'int'에서 'cv :: Mat'로의 변환이 모호합니다 –