Select Git revision
BoardRequestDto.java
camera.cpp 16.20 KiB
#include "gpio.h"
#include <chrono>
#include <iostream>
#include <memory>
#include <thread>
#include <vector>
#include <queue>
#include <string>
#include <fstream>
#include <sys/mman.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <libcamera/libcamera.h>
#include <opencv2/opencv.hpp>
#include <iomanip>
#include <stdexcept>
#include <cmath>
#include <arpa/inet.h>
using namespace std;
using namespace libcamera;
using namespace GPIO;
#define BUFFER_SIZE 1024
#define POUT 535 // 초음파 트리거 핀
#define PIN 536 // 초음파 에코 핀
// 번호판 후보 영역 필터링을 위한 파라미터
const int MIN_AREA = 100;
const int MIN_WIDTH = 4;
const int MIN_HEIGHT = 2;
const float MIN_RATIO = 0.25f;
const float MAX_RATIO = 0.9f;
// 번호판 문자 검출 파라미터
const float MAX_DIAG = 5.0f;
const float MAX_ANGLE = 12.0f;
const float MAX_AREA_DIFF = 0.6f;
const float MAX_WIDTH_DIFF = 0.8f;
const float MAX_HEIGHT_DIFF = 0.2f;
const int MIN_CHARACTER = 6;
// 번호판 문자 여백 비율
const float MARGIN_RATIO = 0.1f;
// 파일 저장 경로 (폴더 생성 필요)
const string IMAGES_DIR = "../images";
const string PLATES_DIR = "../plates";
struct Rect {
int x, y, w, h;
float cx, cy;
Rect(int x, int y, int w, int h, float cx, float cy) : x(x), y(y), w(w), h(h), cx(cx), cy(cy) {}
bool operator==(const Rect& other) const {
return x == other.x && y == other.y && w == other.w && h == other.h && cx == other.cx && cy == other.cy;
}
};
int server_socket, python_socket; // 서버 소켓 및 파이썬 소켓
bool detected = false; // 차량 감지 여부
bool fireAlert = false; // 화재 경보 여부
pthread_t sensor_thread, receive_thread;
shared_ptr<Camera> camera;
unique_ptr<CameraManager> cm;