Closed vlasov7979 closed 3 weeks ago
// Global configurations and database
sqlite3* db;
std::atomic
// Initialize the database to store LPR data void initDatabase() { if (sqlite3_open("DS-TCG406-E_LPR.db", &db) != SQLITE_OK) { std::cerr << "Cannot open database: " << sqlite3_errmsg(db) << std::endl; } else { const char sql = "CREATE TABLE IF NOT EXISTS Plates (id INTEGER PRIMARY KEY, plate TEXT, timestamp TEXT, vehicle_color TEXT, vehicle_type TEXT);"; char errMsg = nullptr; if (sqlite3_exec(db, sql, nullptr, nullptr, &errMsg) != SQLITE_OK) { std::cerr << "Database error: " << errMsg << std::endl; sqlite3_free(errMsg); } } }
// Log the recognized license plate information in the database void logPlateData(const std::string& plate, const std::string& timestamp, const std::string& color, const std::string& type) { std::string sql = "INSERT INTO Plates (plate, timestamp, vehicle_color, vehicle_type) VALUES (?, ?, ?, ?);"; sqlite3_stmt* stmt; sqlite3_prepare_v2(db, sql.c_str(), -1, &stmt, nullptr);
sqlite3_bind_text(stmt, 1, plate.c_str(), -1, SQLITE_STATIC);
sqlite3_bind_text(stmt, 2, timestamp.c_str(), -1, SQLITE_STATIC);
sqlite3_bind_text(stmt, 3, color.c_str(), -1, SQLITE_STATIC);
sqlite3_bind_text(stmt, 4, type.c_str(), -1, SQLITE_STATIC);
if (sqlite3_step(stmt) != SQLITE_DONE) {
std::cerr << "Error logging data: " << sqlite3_errmsg(db) << std::endl;
}
sqlite3_finalize(stmt);
}
// Configure camera settings for optimal LPR void configureCamera(HikvisionCamera& camera) { camera.setResolution(2688, 1520); camera.enableWDR(140); // Enable 140 dB WDR as specified camera.setCompression(HikvisionCamera::Compression::H265); camera.setFrameRate(30); // Setting to 30 fps as per 60Hz specifications camera.enableANPR(true); // Enable Automatic Number Plate Recognition camera.setLPRDirection(HikvisionCamera::LPRDirection::Bidirectional); }
// Function to detect and process license plates in real-time void processCameraFeed(HikvisionCamera& camera) { cv::Mat frame; while (runCapture) { frame = camera.captureFrame(); // Capture frame from camera feed
// Detect plates using the camera’s onboard LPR system
auto plates = camera.detectLicensePlates(frame);
for (const auto& plate : plates) {
// Extract vehicle details and log data
std::string timestamp = std::to_string(std::time(nullptr));
std::string color = camera.detectVehicleColor(frame); // Hypothetical color detection API
std::string type = camera.detectVehicleType(frame); // Hypothetical vehicle type API
logPlateData(plate, timestamp, color, type);
// Control barrier if necessary
if (barrierControl) {
camera.controlBarrier(HikvisionCamera::BarrierAction::Open);
barrierControl = false; // Reset barrier control
}
std::cout << "Detected plate: " << plate << ", Color: " << color << ", Type: " << type << std::endl;
}
cv::imshow("Live Feed - DS-TCG406-E", frame);
if (cv::waitKey(30) == 'q') break;
}
}
int main() { // Initialize database initDatabase();
// Initialize and configure camera
HikvisionCamera camera("192.168.1.100", "admin", "password");
configureCamera(camera);
// Launch camera feed processing thread
std::thread captureThread(processCameraFeed, std::ref(camera));
// Simulate running main GUI loop or other controls
captureThread.join();
// Close the database connection
sqlite3_close(db);
return 0;
}
Hello, Dear Partners! We are very interested in your project involving Hikvision equipment. My name is Denis, and I am with Skyvision Co. Ltd., based in Azerbaijan. We are about to launch a project focused on developing our own software for a management parking system, and we plan to use the Hikvision DS-TCG406-E ANPR camera. As you know, this is one of the latest Hikvision models suitable for creating a fully integrated parking solution. We are currently looking for an expert who can assist us in developing this program. If you have source code for the DS-TCG406-E camera that could be integrated into our solution, we would be interested in purchasing it. Our preferred programming language is C++. As a startup in the early stages, we are hoping to keep costs reasonable. We look forward to your support and the opportunity to work with you. Please feel free to reach me at d.vlasov@svg-company.com. With best regards, Denis Vlasov Director for Infrastructure Solutions Skyvision Co. Ltd.