Skip to content
Snippets Groups Projects
Select Git revision
  • d61f0106377bccd83fd298a7bf0b0c9c340ef28b
  • master default protected
2 results

camera.cpp

Blame
  • camera.cpp 13.57 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 <opencv2/opencv.hpp>
    #include <iomanip>
    #include <stdexcept>
    #include <cmath>
    #include <arpa/inet.h>
    
    using namespace std;
    using namespace GPIO;
    
    #define BUFFER_SIZE 1024
    
    #define SERVER_ADDR "192.168.121.4"
    #define SERVER_PORT 12345
    
    #define POUT 535  // 초음파 트리거 핀 (GPIO23)
    #define PIN 536  // 초음파 에코 핀 (GPIO24)
    
    #define DISTANCE 10  // 초음파 센서 인식 기준 거리 (cm 단위)
    
    
    // 번호판 후보 영역 필터링을 위한 파라미터 
    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;  // 화재 경보 여부