mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 11:56:52 +08:00
Using a default alprd.conf file with an override in /etc/openalpr/alprd.conf
This commit is contained in:
@@ -1,15 +1,17 @@
|
|||||||
[daemon]
|
[daemon]
|
||||||
|
|
||||||
; country determines the training dataset used for recognizing plates. Valid values are: us, eu
|
; country determines the training dataset used for recognizing plates.
|
||||||
|
; Valid values are: us, eu, au, auwide, gb, kr, mx, sg
|
||||||
country = us
|
country = us
|
||||||
|
|
||||||
; text name identifier for this location
|
; text name identifier for this location
|
||||||
site_id = your-unique-sitename
|
; site_id = your-unique-sitename
|
||||||
|
|
||||||
; Declare each stream on a separate line
|
; Declare each stream on a separate line
|
||||||
; each unique stream should be defined as stream = [url]
|
; each unique stream should be defined as stream = [url]
|
||||||
|
|
||||||
stream = http://127.0.0.1/example_video_stream.mjpeg
|
; Example stream config:
|
||||||
|
; stream = http://127.0.0.1/example_video_stream.mjpeg
|
||||||
; stream = http://127.0.0.1/example_second_stream.mjpeg
|
; stream = http://127.0.0.1/example_second_stream.mjpeg
|
||||||
; stream = webcam
|
; stream = webcam
|
||||||
|
|
4
config/alprd.conf.user
Normal file
4
config/alprd.conf.user
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
; This configuration file overrides the default values specified
|
||||||
|
; in ${CMAKE_INSTALL_PREFIX}/share/openalpr/config/alprd.defaults.conf
|
||||||
|
[daemon]
|
||||||
|
|
@@ -156,7 +156,12 @@ ENDIF()
|
|||||||
|
|
||||||
# Compile the alprd library on Unix-based OS
|
# Compile the alprd library on Unix-based OS
|
||||||
IF (WITH_DAEMON)
|
IF (WITH_DAEMON)
|
||||||
ADD_EXECUTABLE( alprd daemon.cpp daemon/beanstalk.c daemon/beanstalk.cc )
|
ADD_EXECUTABLE( alprd
|
||||||
|
daemon.cpp
|
||||||
|
daemon/daemonconfig.cpp
|
||||||
|
daemon/beanstalk.c
|
||||||
|
daemon/beanstalk.cc
|
||||||
|
)
|
||||||
|
|
||||||
FIND_PACKAGE( log4cplus REQUIRED )
|
FIND_PACKAGE( log4cplus REQUIRED )
|
||||||
|
|
||||||
@@ -212,8 +217,13 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/../config/openalpr.conf.defaults ${CMAKE_CURR
|
|||||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/share/openalpr/config/openalpr.defaults.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/share/openalpr/config COMPONENT config)
|
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/share/openalpr/config/openalpr.defaults.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/share/openalpr/config COMPONENT config)
|
||||||
|
|
||||||
IF (WITH_DAEMON)
|
IF (WITH_DAEMON)
|
||||||
|
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/../config/alprd.conf.user ${CMAKE_CURRENT_BINARY_DIR}/config/alprd.conf)
|
||||||
|
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/config/alprd.conf DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/openalpr/ COMPONENT config)
|
||||||
|
|
||||||
|
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/../config/alprd.conf.defaults ${CMAKE_CURRENT_BINARY_DIR}/share/openalpr/config/alprd.defaults.conf)
|
||||||
|
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/share/openalpr/config/alprd.defaults.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/share/openalpr/config COMPONENT config)
|
||||||
|
|
||||||
install (TARGETS alprd DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
install (TARGETS alprd DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||||
install (FILES ${CMAKE_SOURCE_DIR}/../config/alprd.conf DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/openalpr COMPONENT config)
|
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
|
||||||
|
@@ -6,10 +6,10 @@
|
|||||||
|
|
||||||
#include "daemon/beanstalk.hpp"
|
#include "daemon/beanstalk.hpp"
|
||||||
#include "video/logging_videobuffer.h"
|
#include "video/logging_videobuffer.h"
|
||||||
|
#include "daemon/daemonconfig.h"
|
||||||
|
|
||||||
#include "tclap/CmdLine.h"
|
#include "tclap/CmdLine.h"
|
||||||
#include "alpr.h"
|
#include "alpr.h"
|
||||||
#include "openalpr/simpleini/simpleini.h"
|
|
||||||
#include "openalpr/cjson.h"
|
#include "openalpr/cjson.h"
|
||||||
#include "support/tinythread.h"
|
#include "support/tinythread.h"
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
@@ -167,73 +167,47 @@ int main( int argc, const char** argv )
|
|||||||
LOG4CPLUS_INFO(logger, "Running OpenALPR daemon in the foreground.");
|
LOG4CPLUS_INFO(logger, "Running OpenALPR daemon in the foreground.");
|
||||||
}
|
}
|
||||||
|
|
||||||
CSimpleIniA ini;
|
LOG4CPLUS_INFO(logger, "Using: " << daemonConfigFile << " for daemon configuration");
|
||||||
ini.SetMultiKey();
|
|
||||||
|
|
||||||
ini.LoadFile(daemonConfigFile.c_str());
|
std::string daemon_defaults_file = INSTALL_PREFIX "/share/openalpr/config/alprd.defaults.conf";
|
||||||
|
DaemonConfig daemon_config(daemonConfigFile, daemon_defaults_file);
|
||||||
std::vector<std::string> stream_urls;
|
|
||||||
|
|
||||||
|
|
||||||
CSimpleIniA::TNamesDepend values;
|
if (daemon_config.stream_urls.size() == 0)
|
||||||
ini.GetAllValues("daemon", "stream", values);
|
|
||||||
|
|
||||||
// sort the values into the original load order
|
|
||||||
values.sort(CSimpleIniA::Entry::LoadOrder());
|
|
||||||
|
|
||||||
// output all of the items
|
|
||||||
CSimpleIniA::TNamesDepend::const_iterator i;
|
|
||||||
for (i = values.begin(); i != values.end(); ++i) {
|
|
||||||
stream_urls.push_back(i->pItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (stream_urls.size() == 0)
|
|
||||||
{
|
{
|
||||||
LOG4CPLUS_FATAL(logger, "No video streams defined in the configuration.");
|
LOG4CPLUS_FATAL(logger, "No video streams defined in the configuration.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string country = ini.GetValue("daemon", "country", "us");
|
LOG4CPLUS_INFO(logger, "Using: " << daemon_config.imageFolder << " for storing valid plate images");
|
||||||
int topn = ini.GetLongValue("daemon", "topn", 20);
|
|
||||||
|
|
||||||
bool storePlates = ini.GetBoolValue("daemon", "store_plates", false);
|
|
||||||
std::string imageFolder = ini.GetValue("daemon", "store_plates_location", "/tmp/");
|
|
||||||
bool uploadData = ini.GetBoolValue("daemon", "upload_data", false);
|
|
||||||
std::string upload_url = ini.GetValue("daemon", "upload_address", "");
|
|
||||||
std::string company_id = ini.GetValue("daemon", "company_id", "");
|
|
||||||
std::string site_id = ini.GetValue("daemon", "site_id", "");
|
|
||||||
|
|
||||||
LOG4CPLUS_INFO(logger, "Using: " << daemonConfigFile << " for daemon configuration");
|
|
||||||
LOG4CPLUS_INFO(logger, "Using: " << imageFolder << " for storing valid plate images");
|
|
||||||
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
for (int i = 0; i < stream_urls.size(); i++)
|
for (int i = 0; i < daemon_config.stream_urls.size(); i++)
|
||||||
{
|
{
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid == (pid_t) 0)
|
if (pid == (pid_t) 0)
|
||||||
{
|
{
|
||||||
// This is the child process, kick off the capture data and upload threads
|
// This is the child process, kick off the capture data and upload threads
|
||||||
CaptureThreadData* tdata = new CaptureThreadData();
|
CaptureThreadData* tdata = new CaptureThreadData();
|
||||||
tdata->stream_url = stream_urls[i];
|
tdata->stream_url = daemon_config.stream_urls[i];
|
||||||
tdata->camera_id = i + 1;
|
tdata->camera_id = i + 1;
|
||||||
tdata->config_file = openAlprConfigFile;
|
tdata->config_file = openAlprConfigFile;
|
||||||
tdata->output_images = storePlates;
|
tdata->output_images = daemon_config.storePlates;
|
||||||
tdata->output_image_folder = imageFolder;
|
tdata->output_image_folder = daemon_config.imageFolder;
|
||||||
tdata->country_code = country;
|
tdata->country_code = daemon_config.country;
|
||||||
tdata->company_id = company_id;
|
tdata->company_id = daemon_config.company_id;
|
||||||
tdata->site_id = site_id;
|
tdata->site_id = daemon_config.site_id;
|
||||||
tdata->top_n = topn;
|
tdata->top_n = daemon_config.topn;
|
||||||
tdata->clock_on = clockOn;
|
tdata->clock_on = clockOn;
|
||||||
|
|
||||||
tthread::thread* thread_recognize = new tthread::thread(streamRecognitionThread, (void*) tdata);
|
tthread::thread* thread_recognize = new tthread::thread(streamRecognitionThread, (void*) tdata);
|
||||||
|
|
||||||
if (uploadData)
|
if (daemon_config.uploadData)
|
||||||
{
|
{
|
||||||
// Kick off the data upload thread
|
// Kick off the data upload thread
|
||||||
UploadThreadData* udata = new UploadThreadData();
|
UploadThreadData* udata = new UploadThreadData();
|
||||||
udata->upload_url = upload_url;
|
udata->upload_url = daemon_config.upload_url;
|
||||||
tthread::thread* thread_upload = new tthread::thread(dataUploadThread, (void*) udata );
|
tthread::thread* thread_upload = new tthread::thread(dataUploadThread, (void*) udata );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
60
src/daemon/daemonconfig.cpp
Normal file
60
src/daemon/daemonconfig.cpp
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 OpenALPR Technology, Inc.
|
||||||
|
* Open source Automated License Plate Recognition [http://www.openalpr.com]
|
||||||
|
*
|
||||||
|
* This file is part of OpenALPR.
|
||||||
|
*
|
||||||
|
* OpenALPR is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License
|
||||||
|
* version 3 as published by the Free Software Foundation
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "daemonconfig.h"
|
||||||
|
#include "config_helper.h"
|
||||||
|
|
||||||
|
using namespace alpr;
|
||||||
|
|
||||||
|
DaemonConfig::DaemonConfig(std::string config_file, std::string config_defaults_file) {
|
||||||
|
CSimpleIniA ini;
|
||||||
|
ini.SetMultiKey();
|
||||||
|
ini.LoadFile(config_file.c_str());
|
||||||
|
|
||||||
|
CSimpleIniA defaultIni;
|
||||||
|
defaultIni.SetMultiKey();
|
||||||
|
defaultIni.LoadFile(config_defaults_file.c_str());
|
||||||
|
|
||||||
|
// Stream will only be in the user override config, never in the defaults
|
||||||
|
CSimpleIniA::TNamesDepend values;
|
||||||
|
ini.GetAllValues("daemon", "stream", values);
|
||||||
|
|
||||||
|
// sort the values into the original load order
|
||||||
|
values.sort(CSimpleIniA::Entry::LoadOrder());
|
||||||
|
|
||||||
|
// output all of the items
|
||||||
|
CSimpleIniA::TNamesDepend::const_iterator i;
|
||||||
|
for (i = values.begin(); i != values.end(); ++i) {
|
||||||
|
stream_urls.push_back(i->pItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
country = getString(&ini, &defaultIni, "daemon", "country", "us");
|
||||||
|
topn = getInt(&ini, &defaultIni, "daemon", "topn", 20);
|
||||||
|
|
||||||
|
storePlates = getBoolean(&ini, &defaultIni, "daemon", "store_plates", false);
|
||||||
|
imageFolder = getString(&ini, &defaultIni, "daemon", "store_plates_location", "/tmp/");
|
||||||
|
uploadData = getBoolean(&ini, &defaultIni, "daemon", "upload_data", false);
|
||||||
|
upload_url = getString(&ini, &defaultIni, "daemon", "upload_address", "");
|
||||||
|
company_id = getString(&ini, &defaultIni, "daemon", "company_id", "");
|
||||||
|
site_id = getString(&ini, &defaultIni, "daemon", "site_id", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
DaemonConfig::~DaemonConfig() {
|
||||||
|
}
|
||||||
|
|
31
src/daemon/daemonconfig.h
Normal file
31
src/daemon/daemonconfig.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
#ifndef OPENALPR_DAEMONCONFIG_H
|
||||||
|
#define OPENALPR_DAEMONCONFIG_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include "simpleini/simpleini.h"
|
||||||
|
|
||||||
|
class DaemonConfig {
|
||||||
|
public:
|
||||||
|
DaemonConfig(std::string config_file, std::string config_defaults_file);
|
||||||
|
virtual ~DaemonConfig();
|
||||||
|
|
||||||
|
std::vector<std::string> stream_urls;
|
||||||
|
|
||||||
|
std::string country;
|
||||||
|
|
||||||
|
int topn;
|
||||||
|
bool storePlates;
|
||||||
|
std::string imageFolder;
|
||||||
|
bool uploadData;
|
||||||
|
std::string upload_url;
|
||||||
|
std::string company_id;
|
||||||
|
std::string site_id;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* OPENALPR_DAEMONCONFIG_H */
|
||||||
|
|
Reference in New Issue
Block a user