I know this has already been posted, but i couldn't find a solution to my issue.
there are two files involved:
Camera(.cc|.h)
CameraServer(.cc|.h)
Camera.h
:
#ifndef myproject_CAMERASERVER_CAMERA_H
#define myproject_CAMERASERVER_CAMERA_H
#include <myprojectGlobal.h>
#include <opencv2/opencv.hpp>
#include <stdio.h>
#include "../ObjectDetection/FaceDetection.h"
namespace myproject::CameraServer {
class Camera {
private:
bool showWindow;
bool close;
cv::VideoCapture capture;
cv::Mat currentFrame;
s16 cameraID;
public:
Camera(s16 CameraID, bool ShowWindow);
i16 Open(bool faceDetection);
void Close();
};
}
#endif
Camera.cc
:
#include "Camera.h"
using namespace myproject::CameraServer;
Camera::Camera(s16 CameraID, bool ShowWindow) {
cameraID = CameraID;
showWindow = ShowWindow;
close = false;
printf("Initialized Camera Server for: %hd\n", cameraID);
}
i16 Camera::Open(bool faceDetection) {
printf("Opening Camera Stream for: %hd\n", cameraID);
if (showWindow) {
cv::namedWindow("Test Capture", cv::WINDOW_AUTOSIZE);
}
printf("Opening Camera...");
capture.open(cameraID);
if (!capture.isOpened()) {
printf("Error with Camera: %hd\n", cameraID);
return 1;
}
printf("done\n");
printf("Loading Face Detection Configuration...");
auto config = myproject::ObjectDetection::FaceDetection::LoadTemplateConfigurationFromAssets("./assets/OpenCV");
printf("done\n");
while(true) {
printf("Processing Frame...");
capture >> currentFrame;
if (currentFrame.empty()) {
printf("Frame is empty!\n");
break;
}
if (faceDetection) {
printf("Running Face Detection on Frame...");
myproject::ObjectDetection::FaceDetection::DetectFace(currentFrame, config, 1.0f);
printf("done\n");
}
if (showWindow) {
printf("Drawing Frame on to Window...\n");
cv::imshow("Test Capture", currentFrame);
if (cv::waitKey(30) >= 0) {
break;
}
printf("done\n");
}
}
return 0;
}
CameraServer.cc
:
#include "CameraServer.h"
int main(int argc, char* argv[]) {
printf("Hello World from the CameraServer!\n");
myproject::CameraServer::Camera camTest(0, true);
i16 result = camTest.Open(true);
printf("%i\n", result);
return result;
}
this is the logs that the console procudes:
Initialized Camera Server for: 0
Opening Camera Stream for: 0
Opening Camera...done
Loading Face Detection Configuration...done
[1] 67973 illegal hardware instruction ./myproject.CameraServer
- I'm using CMake with OpenCV
- working on a MacBook Pro 16 (Intel)
- only attached Webcam: integrated
Can someone help me or explain this to me?