41 changed files with 3437 additions and 272 deletions
-
1Linux_Workspace.vpw
-
BINProjects/img_mill/side/workingConfig.tar.bz2
-
25Projects/img_slim/Debug/default.conf
-
258Projects/img_slim/IM_Backend.cpp
-
48Projects/img_slim/IM_Backend.h
-
230Projects/img_slim/IM_ClientHandler.cpp
-
34Projects/img_slim/IM_ClientHandler.h
-
57Projects/img_slim/IM_ClientProtocol.cpp
-
24Projects/img_slim/IM_ClientProtocol.h
-
476Projects/img_slim/IM_DLibWorker.cpp
-
118Projects/img_slim/IM_DLibWorker.h
-
251Projects/img_slim/IM_DataBaseAdapter.cpp
-
53Projects/img_slim/IM_DataBaseAdapter.h
-
30Projects/img_slim/IM_DataStructs.cpp
-
60Projects/img_slim/IM_DataStructs.h
-
349Projects/img_slim/IM_DnnWorker.cpp
-
66Projects/img_slim/IM_DnnWorker.h
-
148Projects/img_slim/IM_Kernel.cpp
-
52Projects/img_slim/IM_Kernel.h
-
9Projects/img_slim/build
-
332Projects/img_slim/img_slim.vpj
-
275Projects/img_slim/makefile
-
127lib/App/common/SQLite_dataBinder.cpp
-
3lib/App/common/SQLite_dataBinder.h
-
1lib/App/common/dataBinder.h
-
13lib/App/common/dataBinder_structures.h
-
1lib/App/common/deviceNode.h
-
55lib/App/common/deviceNode2D.cpp
-
5lib/App/common/deviceNode2D.h
-
24lib/App/common/deviceNodeCamera.cpp
-
2lib/App/common/deviceNodeSensor.cpp
-
2lib/App/common/deviceNodeSensor.h
-
19lib/App/common/kernelEventFilter.cpp
-
2lib/App/common/kernelEventFilter.h
-
301lib/App/common/kernelEventFilterTrain.cpp
-
33lib/App/common/kernelEventFilterTrain.h
-
162lib/App/mojo/mojoKernel.cpp
-
7lib/App/mojo/mojoKernel.h
-
46lib/App/mojo/mojoRemoteClient.cpp
-
2lib/App/mojo/mojoRemoteClient.h
-
8lib/components/base/basicEvent.h
Binary file not shown.
@ -0,0 +1,25 @@ |
|||
NETWORK_SERVER : |
|||
{ |
|||
NW_LISTEN_PORT = 2222; |
|||
}; |
|||
KERNEL : |
|||
{ |
|||
DBC : |
|||
{ |
|||
DATABASE_HOST = "localhost"; |
|||
DATABASE_NAME = "dfsl_gunter"; |
|||
DATABASE_USER = "dbroot"; |
|||
DATABASE_PASSWORD = "123567"; |
|||
DATABASE_PORT = 3306; |
|||
}; |
|||
DNN : |
|||
{ |
|||
PICTURES_BASE = "/srv/vault"; |
|||
NET_CONFIG_FILE = "conf/yolo9000.cfg"; |
|||
NET_WEIGHTS_FILE = "data/yolo9000.weights"; |
|||
DETECTION_PROBABILITY = 0.5; |
|||
USE_CLASS_MAP = false; |
|||
NET_TARGET_DEVICE = "CPU"; |
|||
NET_BACKEND_ENGINE = "DEFAULT"; |
|||
}; |
|||
}; |
|||
@ -0,0 +1,258 @@ |
|||
#include "IM_Backend.h"
|
|||
|
|||
// Global Variables
|
|||
|
|||
CSTR gsCFG_ADDRESS; |
|||
uint16_t guCFG_PORT = DEFAULT_SERVER_PORT; |
|||
CSTR gsCFG_LICENSE; |
|||
CSTR gsCFG_DB_SERVER; |
|||
CSTR gsCFG_DB_NAME; |
|||
CSTR gsCFG_DB_USER; |
|||
CSTR gsCFG_DB_PASSWORD; |
|||
CSTR gsCFG_PID_FILE = (CSTR) DEFAULT_SERVER_PID_FILE; |
|||
SOFTWARE_INFO gsSOFT_INFO; |
|||
bool gbCFG_MASTER_ROLE = true; |
|||
|
|||
bool gModule_GeoFence_Enabled = true; |
|||
bool gModule_SMS_Enabled = false; |
|||
bool gModule_Email_Enabled = false; |
|||
bool gSignal_Handler_Enabled = true; |
|||
|
|||
#define LOG( X ) m_pLog->Log( "main", 0, X )
|
|||
#define LOG_ERROR( X ) m_pLog->Log( "main", 0, _LOG_ERROR, X )
|
|||
|
|||
IM_Kernel * Kernel = NULL; |
|||
basicLogCollection * m_pLog = NULL; |
|||
networkServer * NetworkManager = NULL; |
|||
|
|||
void (*old_update_handler_2)(int); //SIGINT
|
|||
void (*old_kill_handler_3)(int); //SIGQUIT
|
|||
void (*old_kill_handler_9)(int); //SIGKILL
|
|||
void (*old_alarm_handler_14)(int); //SIGALRM
|
|||
void (*old_kill_handler_15)(int); //SIGTERM
|
|||
|
|||
|
|||
|
|||
|
|||
void signal_SIGKILL_handler( int SIG ){ |
|||
if( Kernel!= NULL ){ |
|||
if( gSignal_Handler_Enabled ){ |
|||
m_pLog->Log("SIG", 0, _LOG_DEBUG, "Shutdown Service by Signal" ); |
|||
Kernel->setStatus( TH_ENDED ); // Closing all Connections;
|
|||
} else { |
|||
m_pLog->Log("SIG", 0, _LOG_DEBUG, "Shutdown Signal Handler Disabled" ); |
|||
}; |
|||
}; |
|||
}; |
|||
|
|||
//#include <sys/resource.h>
|
|||
|
|||
int main (int argc, char *argv[]){ |
|||
basicSettingsProvider * SETTINGS = NULL; |
|||
bool WBG; // Working Background
|
|||
bool SSE; // Server Statistics Engine
|
|||
bool NDC; // No Default Configuration
|
|||
CSTR FLE_NAME; |
|||
CSTR DCF_NAME; |
|||
CSTR SSP_NAME; |
|||
objectFileLoggingService * FLE = NULL; |
|||
objectConsoleLoggingService * CLE = NULL; |
|||
// default init
|
|||
WBG = true; |
|||
FLE_NAME = (CSTR) DEFAULT_SERVER_LOG_FILE; |
|||
SSE = true; |
|||
NDC = true; |
|||
DCF_NAME = (CSTR) DEFAULT_SERVER_CONFIG_PATH; |
|||
SSP_NAME = (CSTR) DEFAULT_SERVER_SOCKET_PATH; |
|||
gsSOFT_INFO.SW_BUILD_DATE = UNIX_TIMESTAMP; |
|||
gsSOFT_INFO.DATA_VALID = false; |
|||
m_pLog = basicLogCollection::getInstance( _LOG_TIME ); |
|||
gsSOFT_INFO.SW_MODE_FLAGS = 0 |
|||
#ifdef SKIP_TARGET_LOG
|
|||
| SW_INFO_NO_TARGET_LOG |
|||
#endif
|
|||
#ifdef HIBERNATE_ENABLE
|
|||
| SW_INFO_HIBERNATE_ENA |
|||
#endif
|
|||
#ifdef TGD
|
|||
| SW_INFO_TGD_MOTORS |
|||
#ifdef TGD_VERSION_2
|
|||
| SW_INFO_TGD_VER_2 |
|||
#endif
|
|||
#endif
|
|||
#ifdef ENCODER_8192
|
|||
| SW_INFO_EU_PROJECT |
|||
#endif
|
|||
#ifdef NO_BLACK_TARGETS
|
|||
| SW_INFO_NO_BLACK_TARGETS |
|||
#endif
|
|||
#ifndef NO_MOTORS
|
|||
| SW_INFO_MOTOR_CTRL_ENA |
|||
#endif
|
|||
#ifdef THREADED_FLIP
|
|||
| SW_INFO_THREAD_FLIP |
|||
#endif
|
|||
#ifndef PRU_SLAVE
|
|||
| SW_INFO_FLAG_MASTER |
|||
#endif
|
|||
#ifdef DEBUG
|
|||
| SW_INFO_DEBUG_MODE |
|||
#endif
|
|||
; |
|||
|
|||
|
|||
// Reading Config
|
|||
if( argc > 1 ){ |
|||
for( int i = 0; i < argc; i++ ){ |
|||
switch( argv[i][0] ){ |
|||
case '-': |
|||
case '\\': |
|||
case '/':{ |
|||
switch( argv[i][1] ){ |
|||
case 'h': case 'H': case 'v': case 'V': case '?':{ |
|||
printf( "Image Mill Neural Network Server\n"); |
|||
printf( "Software version <%s>\n", VERSION_NUMBER ); |
|||
printf( " -h -H This Message\n" ); |
|||
printf( " -i -I Interactive Mode\n" ); |
|||
return 0; |
|||
break; |
|||
}; |
|||
case 'i': case 'I':{ |
|||
WBG = false; |
|||
CLE = new objectConsoleLoggingService(); |
|||
if( CLE != NULL ) { |
|||
m_pLog->addHandler( CLE ); |
|||
}; |
|||
break; |
|||
}; |
|||
case 'c': case 'C':{ |
|||
DCF_NAME = (CSTR) malloc( MAX_PATH_LEN ); |
|||
if( DCF_NAME != NULL ) { |
|||
sprintf( DCF_NAME, "%s", argv[i+1] ); |
|||
} else { |
|||
printf("ERROR!\n\n"); |
|||
return -1; |
|||
}; |
|||
break; |
|||
}; |
|||
}; |
|||
break; |
|||
}; |
|||
}; |
|||
}; |
|||
}; |
|||
|
|||
FLE = new objectFileLoggingService( FLE_NAME ); |
|||
if( FLE != NULL ) { |
|||
m_pLog->addHandler( FLE ); |
|||
}; |
|||
LOG("Starting Log Engine!"); |
|||
if ( fileExist( DCF_NAME ) ){ |
|||
SETTINGS = basicSettingsProvider::getInstance(DCF_NAME); |
|||
} else { |
|||
SETTINGS = basicSettingsProvider::getInstance(); |
|||
}; |
|||
|
|||
// Demonizing or not
|
|||
if( WBG ){ |
|||
printf( "Image Mill Neural Network Server ver. %s\n", VERSION_NUMBER ); |
|||
printf( "Configuration Applied:\n"); |
|||
printf( " Service Established %s at %d\n", gsCFG_ADDRESS, guCFG_PORT ); |
|||
printf( " PID File: %s\n", gsCFG_PID_FILE ); |
|||
printf( " Log File: %s\n", FLE_NAME ); |
|||
printf( " License: %s\n", gsCFG_LICENSE ); |
|||
printf( " Database Server: %s Database: %s\n", gsCFG_DB_SERVER, gsCFG_DB_NAME ); |
|||
if( NDC ){ |
|||
printf( " No configuration file (%s) supplied.\n", DCF_NAME); |
|||
} else { |
|||
printf( " Configuration read from: %s\n", DCF_NAME ); |
|||
}; |
|||
|
|||
//Demonizing
|
|||
pid_t pid, sid; |
|||
sync(); |
|||
close( STDIN_FILENO ); |
|||
close( STDOUT_FILENO ); |
|||
close( STDERR_FILENO ); |
|||
|
|||
pid = fork(); |
|||
if( pid < 0 ){ |
|||
return pid; |
|||
}; |
|||
if( pid > 0 ){ |
|||
return 0; |
|||
}; |
|||
//umask(0);
|
|||
sid = setsid(); |
|||
if (sid < 0) { |
|||
return sid; |
|||
}; |
|||
|
|||
pid = fork(); |
|||
if( pid < 0 ){ |
|||
return pid; |
|||
}; |
|||
if( pid > 0 ){ |
|||
FILE *pPIDF = fopen( gsCFG_PID_FILE, "w+" ); |
|||
if( pPIDF ){ |
|||
fprintf( pPIDF, "%d\n", pid ); |
|||
fclose( pPIDF ); |
|||
} |
|||
return 0; |
|||
}; |
|||
}; |
|||
|
|||
uint8_t m_bKernelExitCode = 0; |
|||
|
|||
NetworkManager = new networkServer(); |
|||
if( NetworkManager != NULL ) { |
|||
if( NetworkManager->BootUp() ){ |
|||
LOG("Net Service is UP"); |
|||
} else { |
|||
delete(NetworkManager); |
|||
NetworkManager = NULL; |
|||
}; |
|||
}; |
|||
do{ |
|||
//Loop till some Restart action
|
|||
Kernel = IM_Kernel::getInstance(); |
|||
if( Kernel == NULL ) { |
|||
// Aborting Work
|
|||
LOG_ERROR( "++++ Kernel failed to born ++++" ); |
|||
unlink( gsCFG_PID_FILE ); |
|||
LOG( "PID File Deleted" ); |
|||
delete( m_pLog ); |
|||
return -1; |
|||
} else { |
|||
if ( Kernel->start() == false ){ |
|||
LOG_ERROR("Kernel create failure!"); |
|||
} else { |
|||
LOG( "++++ Server Started ++++" ); |
|||
if( NetworkManager!= NULL ) { |
|||
NetworkManager->attachEngine( Kernel ); |
|||
}; |
|||
//Install Signal Listeners
|
|||
old_kill_handler_15 = signal( 15, signal_SIGKILL_handler ); |
|||
old_kill_handler_9 = signal( 9, signal_SIGKILL_handler ); |
|||
// Waiting for Worker to Shut Down
|
|||
Kernel->stop( false ); |
|||
m_bKernelExitCode = Kernel->getExitCause(); |
|||
signal( 9, old_kill_handler_9 ); |
|||
signal( 15, old_kill_handler_15 ); |
|||
}; |
|||
//Since Kernel is Singletone Object no need to delete
|
|||
delete( Kernel ); |
|||
LOG( "++++ Server Ended ++++" ); |
|||
}; |
|||
} while( m_bKernelExitCode > 0 ); |
|||
|
|||
if( NetworkManager ) delete( NetworkManager ); |
|||
//LOG( "++++ CDC DEL ++++" );
|
|||
unlink( gsCFG_PID_FILE ); |
|||
LOG( "PID File Deleted" ); |
|||
if( FLE!= NULL ) delete( FLE ); |
|||
if( CLE!= NULL ) delete( CLE ); |
|||
delete( m_pLog ); |
|||
return(0); |
|||
} |
|||
|
|||
@ -0,0 +1,48 @@ |
|||
/******************************************************************* |
|||
* |
|||
* DESCRIPTION: Iage Mill project main header file |
|||
* |
|||
* AUTHOR: Gagua |
|||
* |
|||
* HISTORY: |
|||
* |
|||
* DATE:5/29/2019 |
|||
* |
|||
*******************************************************************/ |
|||
#ifndef __IMG_MILL_BACKEND_MAIN_HEADER__ |
|||
#define __IMG_MILL_BACKEND_MAIN_HEADER__ |
|||
|
|||
/** include files **/ |
|||
|
|||
#include <stdlib.h> |
|||
#include <stdio.h> |
|||
#include <signal.h> |
|||
|
|||
#include "../../lib/components/base/basicSettings.h" |
|||
#include "../../lib/components/base/basicLogCollection.h" |
|||
#include "../../lib/components/base/basicMemoryOperation.h" |
|||
#include "../../lib/components/object/objectFileLoggingService.h" |
|||
#include "../../lib/components/object/objectConsoleLoggingService.h" |
|||
#include "../../lib/data/net/netServer.h" |
|||
//#include "../../lib/data/mysql/database_class.h" |
|||
#include "IM_Kernel.h" |
|||
|
|||
/** local definitions **/ |
|||
//http://xmsecu.com:8080/ocx/NewActive.exe |
|||
/* default settings */ |
|||
|
|||
/** external functions **/ |
|||
|
|||
/** external data **/ |
|||
|
|||
/** internal functions **/ |
|||
|
|||
/** public data **/ |
|||
|
|||
/** private data **/ |
|||
|
|||
/** public functions **/ |
|||
|
|||
/** private functions **/ |
|||
|
|||
#endif |
|||
@ -0,0 +1,230 @@ |
|||
#include "IM_ClientHandler.h"
|
|||
#include "IM_Kernel.h"
|
|||
|
|||
#include "../../lib/components/base/basicFunctionality.h"
|
|||
#include "../../lib/data/json/json_tool.h"
|
|||
#include "../../lib/data/protocol/xmlParser.h"
|
|||
|
|||
#include <strings.h>
|
|||
#include <json/value.h>
|
|||
#include <json/writer.h>
|
|||
#include <json/reader.h>
|
|||
|
|||
|
|||
|
|||
#define LOG( X ) m_pLog->Log( "NCH", this, X )
|
|||
#ifdef DEBUG
|
|||
#define LOG_ERROR( X ) {\
|
|||
char _tBfrErrMSG234[256];\ |
|||
sprintf( _tBfrErrMSG234, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\ |
|||
m_pLog->Log( "NCH", this, _LOG_ERROR, _tBfrErrMSG234 );\ |
|||
} |
|||
#else
|
|||
#define LOG_ERROR( X ) m_pLog->Log( "NCH", this, _LOG_ERROR, X );
|
|||
#endif
|
|||
|
|||
// Constructor implementation
|
|||
IM_ClientHandler::IM_ClientHandler( int SOCKET, networkServiceEngine *ptr ) : networkClientHandler( SOCKET, ptr ), IM_ClientProtocol(){ |
|||
m_pLog = basicLogCollection::getInstance(); |
|||
m_pDBA = IM_DataBaseAdapter::getInstance(); |
|||
m_pMyCurrentJob = NULL; |
|||
if( create() ){ |
|||
m_pPort = new serverPort( SOCKET ); |
|||
if( m_pPort != NULL ){ |
|||
setTransport( m_pPort ); |
|||
#ifdef DEBUG
|
|||
LOG("Port Created OK!"); |
|||
#endif
|
|||
if( m_pPort->create() ){ |
|||
LOG("Port Init OK!"); |
|||
} else LOG_ERROR("Not Connected!"); |
|||
} else LOG_ERROR("Port Not Created!"); |
|||
} else LOG_ERROR( "Protocol Parser Creation Failed!"); |
|||
}; |
|||
|
|||
// Destructor implementation
|
|||
IM_ClientHandler::~IM_ClientHandler(){ |
|||
if( m_pPort != NULL ) delete( m_pPort ); |
|||
if( m_pMyCurrentJob ) free( (IM_JOB *)m_pMyCurrentJob ); |
|||
}; |
|||
|
|||
bool IM_ClientHandler::getStatus( void ){ |
|||
if( m_pPort!= NULL ) { |
|||
return m_pPort->getStatus(); |
|||
}; |
|||
return false; |
|||
}; |
|||
|
|||
bool IM_ClientHandler::handleItem( IM_ITEM_DATA *ptr ){ |
|||
if( ptr ) { |
|||
if( m_pEngine != NULL ) { |
|||
IM_Kernel *tKernel = (IM_Kernel *)m_pEngine; |
|||
IM_JOB *tJOB; |
|||
tJOB = (IM_JOB*)malloc(sizeof(IM_JOB)); |
|||
if( tJOB ) { |
|||
if( m_pMyCurrentJob ) { |
|||
LOG("CLEANNING UNCLEAN JOB!"); |
|||
//AnyWay Clean Memory that was Used!
|
|||
free((IM_JOB *)m_pMyCurrentJob); |
|||
}; |
|||
m_pMyCurrentJob = (void*) tJOB; |
|||
memset( tJOB, 0 , sizeof(IM_JOB)); |
|||
tJOB->dbID = ptr->item_id; |
|||
tJOB->image_type = ptr->type; |
|||
tJOB->job_type = ptr->process_type; |
|||
tJOB->width = ptr->width; |
|||
tJOB->height = ptr->height; |
|||
memcpy( tJOB->md5, ptr->md5, 32 ); |
|||
tKernel->enqueueJob( tJOB ); |
|||
}; |
|||
}; |
|||
free( ptr ); |
|||
}; |
|||
return true; |
|||
}; |
|||
|
|||
bool IM_ClientHandler::packetHandler( protocolPackage *Package ){ |
|||
if( Package ) { |
|||
if( Package->m_pData ) { |
|||
if (Package->m_nSize > 3 ) { |
|||
if( Package->m_pData[Package->m_nSize-4] == 13 ) Package->m_pData[Package->m_nSize-4] = 0; |
|||
if( Package->m_pData[Package->m_nSize-3] == 10 ) Package->m_pData[Package->m_nSize-3] = 0; |
|||
} |
|||
Package->m_pData[Package->m_nSize-2] = 0; |
|||
Package->m_pData[Package->m_nSize-1] = 0; |
|||
LOG( (CSTR) Package->m_pData ); |
|||
try{ |
|||
XMLNode node1 = XMLNode::parseString( (const char *)Package->m_pData, "root"); |
|||
if( !node1.isEmpty() ){ |
|||
LOG( node1.getName() ); |
|||
if( strstr(node1.getName(),"ClockSync")!=NULL ){ |
|||
#ifdef __linux__
|
|||
unsigned long long t0, t1, t2, t3; |
|||
#else
|
|||
unsigned __int64 t0, t1, t2, t3; |
|||
#endif
|
|||
XMLNode node3 = node1.getChildNode("t0", 0); |
|||
XMLNode node4 = node1.getChildNode("t1", 0); |
|||
XMLNode node5 = node1.getChildNode("t2", 0); |
|||
/*
|
|||
t3 = getSHDTimeValue(); |
|||
#ifdef __linux__
|
|||
t0 = atoll(node3.getText(0)); |
|||
t1 = atoll(node4.getText(0)); |
|||
t2 = atoll(node5.getText(0)); |
|||
#else
|
|||
t0 = _atoi64(node3.getText(0)); |
|||
t1 = _atoi64(node4.getText(0)); |
|||
t2 = _atoi64(node5.getText(0)); |
|||
#endif
|
|||
int offset = ((t1-t0)+(t2-t3))/2; |
|||
int latency = (t3-t0)-(t2-t1); |
|||
int jagajaga = offset+latency; |
|||
//if( 0 & correctSHTime( jagajaga ) ){
|
|||
// LOG("Time is Synced");
|
|||
// g_iTimeDiff = 0;
|
|||
//} else {
|
|||
// LOG_ERROR("Time Sync Unucessfull - Will use DIFF!");
|
|||
g_iTimeDiff = jagajaga; |
|||
//};
|
|||
*/ |
|||
}; |
|||
}; |
|||
} catch( exception e ){ |
|||
LOG_ERROR("Some Error in XML Parser!"); |
|||
}; |
|||
// JSON Parsing
|
|||
try{ |
|||
Json::Value root; |
|||
Json::Reader reader; |
|||
if( !reader.parse( (char *)Package->m_pData, root ) ){ |
|||
LOG_ERROR( "The package data is nor a valid JSON data nor valid XML data" ); |
|||
return true; |
|||
}; |
|||
if( root.size() ){ |
|||
IM_ITEM_DATA * tData = NULL; |
|||
Json::Value tVal; |
|||
|
|||
tVal = root["item_id"]; |
|||
|
|||
if( tVal != NULL ){ |
|||
int itemID = atoi( tVal.asString().c_str() ) ; |
|||
if( itemID > 0 ) { |
|||
tData = m_pDBA->getItemDataById( itemID ); |
|||
if( tData!= NULL ) tData->process_type = IM_PROC_TYPE_DNN; |
|||
}; |
|||
}; |
|||
|
|||
tVal = root["item_md5"]; |
|||
if( tVal != NULL ){ |
|||
if( strlen( tVal.asString().c_str())== 32 ){ |
|||
tData = m_pDBA->getItemDataByMd5( (CSTR) tVal.asString().c_str() ); |
|||
if( tData!= NULL ) tData->process_type = IM_PROC_TYPE_DNN; |
|||
}; |
|||
}; |
|||
|
|||
tVal = root["process_type"]; |
|||
if( tVal != NULL ){ |
|||
if( tData!= NULL ) tData->process_type = atoi( tVal.asString().c_str()); |
|||
}; |
|||
|
|||
if( tData!= NULL ){ |
|||
return handleItem( tData ); |
|||
} else { |
|||
m_pPort->sendData( (uint8_t *) "{\"STATUS\":\"ERROR\"}\n", 19 ); |
|||
} |
|||
}; |
|||
} catch ( exception e ){ |
|||
LOG_ERROR("Some Error in JSON Parser!"); |
|||
m_pPort->sendData( (uint8_t *) "{\"STATUS\":\"ERROR\"}\n", 19 ); |
|||
}; |
|||
}; |
|||
}; |
|||
return true; |
|||
}; |
|||
|
|||
bool IM_ClientHandler::dispatchEvent( EVENT_CONTAINER *Evt ){ |
|||
if( Evt!= NULL ) { |
|||
if( Evt->m_eClass == EVT_CLASS_IMAGE ){ |
|||
if( Evt->m_eType == EVT_READY ){ |
|||
IM_RESULT *tData = (IM_RESULT*) Evt->m_pEvtData; |
|||
if( tData!= NULL ) { |
|||
if( tData->pJOB == m_pMyCurrentJob ) { |
|||
LOG("JOB Finished Sucessfully!"); |
|||
for( int i=0; i < tData->nBoxCount; i++ ){ |
|||
m_pDBA->insertItemROI( |
|||
tData->pJOB->dbID, |
|||
tData->boxes[i].classID, |
|||
tData->boxes[i].weight, |
|||
tData->boxes[i].x, |
|||
tData->boxes[i].y, |
|||
tData->boxes[i].width, |
|||
tData->boxes[i].height |
|||
); |
|||
}; |
|||
//handle finished Job
|
|||
free( (IM_JOB *)m_pMyCurrentJob ); |
|||
m_pMyCurrentJob = NULL; |
|||
free( (IM_CLASS_BOUNDARY_BOX *)tData->boxes ); |
|||
free( (IM_RESULT *)Evt->m_pEvtData ); |
|||
Evt->m_pEvtData = NULL; |
|||
m_pPort->sendData( (uint8_t *) "{\"STATUS\":\"OK\"}\n", 16 ); |
|||
}; |
|||
} else { |
|||
LOG("JOB Finished Without Detection!"); |
|||
free( (IM_JOB *)m_pMyCurrentJob ); |
|||
m_pMyCurrentJob = NULL; |
|||
m_pPort->sendData( (uint8_t *) "{\"STATUS\":\"ERROR\"}\n", 19 ); |
|||
}; |
|||
}; |
|||
}; |
|||
return true; |
|||
}; |
|||
return false; |
|||
}; |
|||
|
|||
|
|||
#undef LOG
|
|||
#undef LOG_ERROR
|
|||
|
|||
|
|||
@ -0,0 +1,34 @@ |
|||
#ifndef __IM_CLIENTHANDLER_H_INCL__ |
|||
#define __IM_CLIENTHANDLER_H_INCL__ |
|||
|
|||
#include "../../lib/data/net/netClientHandler.h" |
|||
#include "IM_ClientProtocol.h" |
|||
#include "IM_DataBaseAdapter.h" |
|||
|
|||
|
|||
/** |
|||
* TODO: Add class description |
|||
* |
|||
* @author Gagua |
|||
*/ |
|||
class IM_ClientHandler : public networkClientHandler, public IM_ClientProtocol{ |
|||
private: |
|||
basicLogCollection * m_pLog; |
|||
void * m_pMyCurrentJob; |
|||
IM_DataBaseAdapter * m_pDBA; |
|||
protected: |
|||
virtual bool packetHandler( protocolPackage *Package ); |
|||
public: |
|||
// Constructor |
|||
explicit IM_ClientHandler( int SOCKET, networkServiceEngine *ptr=NULL ); |
|||
|
|||
// Destructor |
|||
virtual ~IM_ClientHandler(); |
|||
virtual bool getStatus( void ); |
|||
bool handleItem( IM_ITEM_DATA *ptr ); |
|||
virtual bool dispatchEvent( EVENT_CONTAINER *Evt ); |
|||
}; |
|||
|
|||
|
|||
|
|||
#endif // __IM_CLIENTHANDLER_H_INCL__ |
|||
@ -0,0 +1,57 @@ |
|||
#include "IM_ClientProtocol.h"
|
|||
|
|||
#define LOG( X ) m_pLog->Log( "NCP", this, X )
|
|||
#ifdef DEBUG
|
|||
#define LOG_ERROR( X ) {\
|
|||
char _tBfrErrMSG234[256];\ |
|||
sprintf( _tBfrErrMSG234, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\ |
|||
m_pLog->Log( "NCP", this, _LOG_ERROR, _tBfrErrMSG234 );\ |
|||
} |
|||
#else
|
|||
#define LOG_ERROR( X ) m_pLog->Log( "NCP", this, _LOG_ERROR, X );
|
|||
#endif
|
|||
|
|||
// Constructor implementation
|
|||
IM_ClientProtocol::IM_ClientProtocol() : protocolParser(){ |
|||
|
|||
}; |
|||
|
|||
// Destructor implementation
|
|||
IM_ClientProtocol::~IM_ClientProtocol(){ |
|||
|
|||
}; |
|||
|
|||
int IM_ClientProtocol::packetChecker(U8 *Buffer, size_t BufferSize){ |
|||
// double enter -> finish package
|
|||
if( BufferSize > 2 ){ |
|||
if( ( Buffer[BufferSize-2] == 13 ) && ( Buffer[BufferSize-1] == 13 ) ) return 0; |
|||
}; |
|||
if( BufferSize > 3 ){ |
|||
if( ( Buffer[BufferSize-4] == 13 ) && ( Buffer[BufferSize-3] == 10 ) && ( Buffer[BufferSize-2] == 13 ) && ( Buffer[BufferSize-1] == 10 ) ) return 0; |
|||
}; |
|||
return 1; |
|||
}; |
|||
|
|||
protocolPackage *IM_ClientProtocol::packetExtractor(U8 *Buffer, size_t BufferSize){ |
|||
protocolPackage *tVal = NULL; |
|||
tVal = (protocolPackage *) malloc( sizeof(protocolPackage)); |
|||
if(tVal) { |
|||
tVal->m_pData = (U8*)malloc( BufferSize+1 ); |
|||
if( tVal->m_pData ) { |
|||
tVal->m_nCode = 200; |
|||
tVal->m_nSize = BufferSize; |
|||
memcpy( tVal->m_pData, Buffer, BufferSize ); |
|||
tVal->m_pData[BufferSize]=0; |
|||
} else { |
|||
free( tVal ); |
|||
tVal = NULL; |
|||
}; |
|||
}; |
|||
return tVal; |
|||
}; |
|||
|
|||
|
|||
|
|||
#undef LOG
|
|||
#undef LOG_ERROR
|
|||
|
|||
@ -0,0 +1,24 @@ |
|||
#ifndef __IM_CLIENTPROTOCOL_H_INCL__ |
|||
#define __IM_CLIENTPROTOCOL_H_INCL__ |
|||
|
|||
#include "../../lib/data/protocol/protocol.h" |
|||
|
|||
/** |
|||
* TODO: Add class description |
|||
* |
|||
* @author Gagua |
|||
*/ |
|||
class IM_ClientProtocol : public protocolParser { |
|||
protected: |
|||
virtual int packetChecker(U8 *Buffer, size_t BufferSize); |
|||
virtual protocolPackage *packetExtractor(U8 *Buffer, size_t BufferSize); |
|||
virtual bool packetHandler( protocolPackage *Package ){ return false; }; |
|||
public: |
|||
// Constructor |
|||
IM_ClientProtocol(); |
|||
|
|||
// Destructor |
|||
virtual ~IM_ClientProtocol(); |
|||
}; |
|||
|
|||
#endif // __IM_CLIENTPROTOCOL_H_INCL__ |
|||
@ -0,0 +1,476 @@ |
|||
#include "IM_DLibWorker.h"
|
|||
#include <stdio.h>
|
|||
#include "../../lib/alg/generic/md5.h"
|
|||
#include "../../lib/components/base/basicFunctionality.h"
|
|||
|
|||
#define LOG( X ) m_pLog->Log( "WDLIB", this, X )
|
|||
#ifdef DEBUG
|
|||
#define LOG_ERROR( X ) {\
|
|||
char _tBfrErrMSG234[256];\ |
|||
sprintf( _tBfrErrMSG234, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\ |
|||
m_pLog->Log( "WDLIB", this, _LOG_ERROR, _tBfrErrMSG234 );\ |
|||
} |
|||
#else
|
|||
#define LOG_ERROR( X ) m_pLog->Log( "WDLIB", this, _LOG_ERROR, X );
|
|||
#endif
|
|||
|
|||
|
|||
|
|||
// Constructor implementation
|
|||
IM_DlibWorker::IM_DlibWorker( config_setting_t * Settings ) : basicThread(), m_mBufferProtectorMutex(){ |
|||
m_pLog = basicLogCollection::getInstance(); |
|||
m_pSettings = basicSettingsProvider::getInstance()->getSubNode( Settings, "DLIB" ); |
|||
m_pEvtHeap = basicEventHeap::getInstance(); |
|||
m_pDBA = IM_DataBaseAdapter::getInstance(); |
|||
|
|||
// m_eBackendEngine = cv::dnn::DNN_BACKEND_DEFAULT;
|
|||
// m_eTargetDevice = cv::dnn::DNN_TARGET_CPU;
|
|||
m_pActiveJob = NULL; |
|||
|
|||
#ifdef DARKNET
|
|||
m_pDarknetDetector = NULL; |
|||
#endif
|
|||
m_fDetectionProbability = .7f; |
|||
m_bUseShapePredictor = false; |
|||
m_bUseFaceRecognition = false; |
|||
m_bDataIsActive = false; |
|||
}; |
|||
|
|||
// Destructor implementation
|
|||
IM_DlibWorker::~IM_DlibWorker(){ |
|||
#ifdef DARKNET
|
|||
if( m_pDarknetDetector ) delete( m_pDarknetDetector ); |
|||
#endif
|
|||
}; |
|||
|
|||
bool IM_DlibWorker::create( void ){ |
|||
char tBuff[256]; |
|||
if( m_pSettings == NULL ){ |
|||
return false; |
|||
} else { |
|||
config_setting_t * tSetting; |
|||
tSetting = config_setting_get_member( m_pSettings, "PICTURES_BASE" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "PICTURES_BASE", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "/srv/vault" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Pictures Base Path! Using default!"); |
|||
}; |
|||
sprintf( m_pPicturesBase, "%s", config_setting_get_string(tSetting)); |
|||
tSetting = config_setting_get_member( m_pSettings, "FACEES_BASE" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "FACEES_BASE", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "/srv/vault/faces" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Face Pictures Base Path! Using default!"); |
|||
}; |
|||
sprintf( m_pFacesBase, "%s", config_setting_get_string(tSetting)); |
|||
tSetting = config_setting_get_member( m_pSettings, "USE_SHAPE_PREDICTOR" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "USE_SHAPE_PREDICTOR", CONFIG_TYPE_BOOL ); |
|||
config_setting_set_bool( tSetting, 0 ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Class Map Usage Set! Using default!"); |
|||
}; |
|||
m_bUseShapePredictor = (bool) config_setting_get_bool(tSetting); |
|||
if( m_bUseShapePredictor ) { |
|||
tSetting = config_setting_get_member( m_pSettings, "USE_FACE_RECOGNITION" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "USE_FACE_RECOGNITION", CONFIG_TYPE_BOOL ); |
|||
config_setting_set_bool( tSetting, 0 ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Class Map Usage Set! Using default!"); |
|||
}; |
|||
m_bUseFaceRecognition = (bool) config_setting_get_bool(tSetting); |
|||
|
|||
tSetting = config_setting_get_member( m_pSettings, "SHAPE_PREDICTOR_LANDMARKS" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "SHAPE_PREDICTOR_LANDMARKS", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "data/shape_predictor_5_face_landmarks.dat" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Net Config File! Using default!"); |
|||
}; |
|||
sprintf( m_pShapePredictorPath, "%s", config_setting_get_string(tSetting)); |
|||
if( m_bUseFaceRecognition ) { |
|||
tSetting = config_setting_get_member( m_pSettings, "NET_CONFIG_FILE" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "NET_CONFIG_FILE", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "data/dlib_face_recognition_resnet_model_v1.dat" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Net Weights File! Using default!"); |
|||
}; |
|||
sprintf( m_pNetModelPath, "%s", config_setting_get_string(tSetting)); |
|||
}; |
|||
} else m_bUseFaceRecognition = false; |
|||
|
|||
tSetting = config_setting_get_member( m_pSettings, "DETECTION_PROBABILITY" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "DETECTION_PROBABILITY", CONFIG_TYPE_FLOAT ); |
|||
config_setting_set_float( tSetting, 0.5f ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Probability Set! Using default!"); |
|||
}; |
|||
m_fDetectionProbability = config_setting_get_float(tSetting); |
|||
|
|||
tSetting = config_setting_get_member( m_pSettings, "OUTPUT_CHOWN_USER" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "OUTPUT_CHOWN_USER", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "www-data" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No CHOWN USER! Using default!"); |
|||
}; |
|||
sprintf( m_sChownUser, "%s", config_setting_get_string(tSetting)); |
|||
|
|||
tSetting = config_setting_get_member( m_pSettings, "OUTPUT_CHOWN_GROUP" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "OUTPUT_CHOWN_GROUP", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "www-data" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No CHOWN GROUP! Using default!"); |
|||
}; |
|||
sprintf( m_sChownGroup, "%s", config_setting_get_string(tSetting)); |
|||
|
|||
|
|||
/*
|
|||
tSetting = config_setting_get_member( m_pSettings, "USE_CLASS_MAP" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "USE_CLASS_MAP", CONFIG_TYPE_BOOL ); |
|||
config_setting_set_bool( tSetting, 0 ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Class Map Usage Set! Using default!"); |
|||
}; |
|||
m_bUseClassMapping = (bool) config_setting_get_bool(tSetting); |
|||
if( m_bUseClassMapping ) { |
|||
char tMapFileName[1024]; |
|||
FILE *fd; |
|||
tSetting = config_setting_get_member( m_pSettings, "CLASS_MAP_FILE" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "CLASS_MAP_FILE", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "data/coco9k.map" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Class Map File Set! Using default!"); |
|||
}; |
|||
sprintf( tMapFileName, "%s", config_setting_get_string(tSetting) ); |
|||
fd = fopen( tMapFileName, "r" ); |
|||
if( fd ) { |
|||
uint32_t tV; |
|||
uint32_t idx = 0; |
|||
char tB[128]; |
|||
while( !feof(fd) ) { |
|||
if( fgets( tB, 128, fd ) ){ |
|||
tV = atoi( tB )+1; |
|||
m_vClassesMap.push_back( tV ); |
|||
idx++; |
|||
}; |
|||
}; |
|||
fclose( fd ); |
|||
sprintf( tB, "Loadded %d classes map", idx ); |
|||
LOG( tB ); |
|||
} else { |
|||
m_bUseClassMapping = false; |
|||
}; |
|||
}; |
|||
tSetting = config_setting_get_member( m_pSettings, "NET_TARGET_DEVICE" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "NET_TARGET_DEVICE", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "CPU" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Net Target Device! Using default!"); |
|||
}; |
|||
if( strstr( config_setting_get_string(tSetting), "CPU" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_CPU; |
|||
if( strstr( config_setting_get_string(tSetting), "OPENCL_FP16" )!=NULL ){ |
|||
m_eTargetDevice = cv::dnn::DNN_TARGET_OPENCL_FP16; |
|||
} else { |
|||
if( strstr( config_setting_get_string(tSetting), "OPENCL" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_OPENCL; |
|||
}; |
|||
if( strstr( config_setting_get_string(tSetting), "MYRIAD" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_MYRIAD; |
|||
if( strstr( config_setting_get_string(tSetting), "VULKAN" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_VULKAN; |
|||
if( strstr( config_setting_get_string(tSetting), "FPGA" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_FPGA; |
|||
if( strstr( config_setting_get_string(tSetting), "CUDA_FP16" )!=NULL ){ |
|||
m_eTargetDevice = cv::dnn::DNN_TARGET_CUDA_FP16; |
|||
} else { |
|||
if( strstr( config_setting_get_string(tSetting), "CUDA" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_CUDA; |
|||
}; |
|||
if( strstr( config_setting_get_string(tSetting), "HDDL" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_HDDL; |
|||
sprintf( tBuff, "Device: %s", config_setting_get_string(tSetting) ); |
|||
LOG( tBuff ); |
|||
|
|||
tSetting = config_setting_get_member( m_pSettings, "NET_BACKEND_ENGINE" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "NET_BACKEND_ENGINE", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "DEFAULT" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Net Backend Engine! Using default!"); |
|||
}; |
|||
if( strstr( config_setting_get_string(tSetting), "DEFAULT" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_DEFAULT; |
|||
if( strstr( config_setting_get_string(tSetting), "HALIDE" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_HALIDE; |
|||
if( strstr( config_setting_get_string(tSetting), "INFERENCE" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_INFERENCE_ENGINE; |
|||
if( strstr( config_setting_get_string(tSetting), "OPENCV" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_OPENCV; |
|||
if( strstr( config_setting_get_string(tSetting), "VKCOM" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_VKCOM; |
|||
if( strstr( config_setting_get_string(tSetting), "CUDA" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_CUDA; |
|||
sprintf( tBuff, "Engine: %s", config_setting_get_string(tSetting) ); |
|||
LOG( tBuff ); |
|||
*/ |
|||
basicSettingsProvider::getInstance()->validate(); |
|||
}; |
|||
if( m_bUseShapePredictor ) { |
|||
if( m_bUseFaceRecognition ) { |
|||
sprintf( tBuff, "loading Data from disk... Shape: %s Face: %s", m_pShapePredictorPath, m_pNetModelPath ); |
|||
} else { |
|||
sprintf( tBuff, "loading Data from disk... Shape Predictor: %s ", m_pShapePredictorPath ); |
|||
}; |
|||
LOG( tBuff ); |
|||
if(!fileExist( m_pShapePredictorPath )) { |
|||
LOG_ERROR("No Shape Predictor file exists!"); |
|||
return false; |
|||
}; |
|||
if( m_bUseFaceRecognition ) { |
|||
if(!fileExist( m_pNetModelPath )) { |
|||
LOG_ERROR("No Net Model file exists!"); |
|||
return false; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
m_oFaceDetector = get_frontal_face_detector(); |
|||
|
|||
if( m_bUseShapePredictor ) { |
|||
|
|||
deserialize( m_pShapePredictorPath ) >> m_oShapePredictor; |
|||
|
|||
if( m_bUseFaceRecognition ) { |
|||
|
|||
deserialize( m_pNetModelPath ) >> m_oNet; |
|||
|
|||
}; |
|||
}; |
|||
|
|||
return init(); |
|||
}; |
|||
|
|||
std::vector<matrix<rgb_pixel>> jitter_image( const matrix<rgb_pixel>& img ){ |
|||
// All this function does is make 100 copies of img, all slightly jittered by being
|
|||
// zoomed, rotated, and translated a little bit differently. They are also randomly
|
|||
// mirrored left to right.
|
|||
thread_local dlib::rand rnd; |
|||
|
|||
std::vector<matrix<rgb_pixel>> crops; |
|||
for (int i = 0; i < 100; ++i) |
|||
crops.push_back(jitter_image(img,rnd)); |
|||
|
|||
return crops; |
|||
}; |
|||
|
|||
CSTR IM_DlibWorker::m_fSaveFace( matrix<rgb_pixel> &Picture, CSTR md5, uint32_t index ){ |
|||
char tPathSrc[1024]; |
|||
char tPathDest[1024]; |
|||
CSTR nMd5; |
|||
CSTR nPath; |
|||
sprintf( tPathSrc, "%s/%s_%d.jpg", m_pFacesBase, md5, index ); |
|||
LOG("Save Face"); |
|||
LOG( tPathSrc ); |
|||
save_jpeg( Picture, tPathSrc, 75 ); |
|||
nMd5 = MD5File( tPathSrc ); |
|||
nPath = buildMd5Path( m_pFacesBase, nMd5, 0755, m_sChownUser, m_sChownGroup ); |
|||
sprintf( tPathDest, "%s/%s.jpg", nPath, nMd5 ); |
|||
free( nPath ); |
|||
//fileCopy( tPathSrc, tPathDest );
|
|||
//remove( tPathSrc );
|
|||
rename ( tPathSrc, tPathDest ); |
|||
ch_chown( tPathDest, m_sChownUser, m_sChownGroup ); |
|||
return nMd5; |
|||
}; |
|||
|
|||
IM_RESULT *IM_DlibWorker::m_fImageAnalyzer( cv::Mat &Pic ){ |
|||
IM_RESULT * retVal = NULL; |
|||
cv_image<bgr_pixel> Picture(Pic); |
|||
std::vector<matrix<rgb_pixel>> faces; |
|||
std::vector<uint32_t> dbIDs; |
|||
uint32_t idx = 0; |
|||
CSTR tVAL = NULL; |
|||
for( auto face : m_oFaceDetector( Picture ) ){ |
|||
//dlib::rectangle face
|
|||
if( m_bUseShapePredictor ) { |
|||
auto shape = m_oShapePredictor( Picture, face ); |
|||
matrix<rgb_pixel> face_chip; |
|||
extract_image_chip( Picture, get_face_chip_details( shape, 150, 0.25 ), face_chip ); |
|||
tVAL = m_fSaveFace( face_chip, m_pActiveJob->md5, idx ); |
|||
faces.push_back( move( face_chip ) ); |
|||
} else { |
|||
matrix<rgb_pixel> face_chip; |
|||
extract_image_chip( Picture, face, face_chip ); |
|||
tVAL = m_fSaveFace( face_chip, m_pActiveJob->md5, idx ); |
|||
}; |
|||
if( tVAL!= NULL ) { |
|||
uint32_t tID; |
|||
tID = m_pDBA->insertItemFace( m_pActiveJob->dbID, tVAL, face.left(), face.top(), face.width(), face.height() ); |
|||
dbIDs.push_back( tID ); |
|||
|
|||
char tB[64]; |
|||
sprintf(tB,"ID:%d", tID); |
|||
LOG(tB); |
|||
|
|||
free( tVAL ); |
|||
tVAL = NULL; |
|||
}; |
|||
idx++; |
|||
}; |
|||
|
|||
if( m_bUseShapePredictor ) { |
|||
//if (faces.size() == 0){
|
|||
// cout << "No faces found in image!" << endl;
|
|||
// return 1;
|
|||
//}
|
|||
if( m_bUseFaceRecognition ) { |
|||
// This call asks the DNN to convert each face image in faces into a 128D vector.
|
|||
// In this 128D vector space, images from the same person will be close to each other
|
|||
// but vectors from different people will be far apart. So we can use these vectors to
|
|||
// identify if a pair of images are from the same person or from different people.
|
|||
if( faces.size() ) { |
|||
//LOG("Have Detected Faces!");
|
|||
//std::vector<matrix<float,0,1>> face_descriptors = m_oNet( faces );
|
|||
try{ |
|||
for( int idx = 0; idx < faces.size(); idx++ ) { |
|||
matrix<float,0,1> face_descriptor = mean( mat( m_oNet( jitter_image( faces[idx] ) ) ) ); |
|||
//matrix<float,0,1> face_descriptor = m_oNet( faces[0] );
|
|||
//LOG("Classification Done!");
|
|||
for( int i = 0; i < face_descriptor.size(); i++ ) m_pDBA->updateItemFace( dbIDs[idx], i, face_descriptor( i, 0 ) ); |
|||
}; |
|||
} catch ( std::exception& e ){ |
|||
LOG_ERROR( e.what() ); |
|||
}; |
|||
} else { |
|||
LOG("No Faces Found!"); |
|||
}; |
|||
|
|||
//std::vector<matrix<float,0,1>> face_descriptors = m_oNet( faces );
|
|||
|
|||
// In particular, one simple thing we can do is face clustering. This next bit of code
|
|||
// creates a graph of connected faces and then uses the Chinese whispers graph clustering
|
|||
// algorithm to identify how many people there are and which faces belong to whom.
|
|||
/*
|
|||
std::vector<sample_pair> edges; |
|||
for (size_t i = 0; i < face_descriptors.size(); ++i){ |
|||
for (size_t j = i; j < face_descriptors.size(); ++j){ |
|||
// Faces are connected in the graph if they are close enough. Here we check if
|
|||
// the distance between two face descriptors is less than 0.6, which is the
|
|||
// decision threshold the network was trained to use. Although you can
|
|||
// certainly use any other threshold you find useful.
|
|||
if (length(face_descriptors[i]-face_descriptors[j]) < 0.6) |
|||
edges.push_back(sample_pair(i,j)); |
|||
}; |
|||
}; |
|||
std::vector<unsigned long> labels; |
|||
const auto num_clusters = chinese_whispers(edges, labels); |
|||
*/ |
|||
// This will correctly indicate that there are 4 people in the image.
|
|||
//cout << "number of people found in the image: "<< num_clusters << endl;
|
|||
|
|||
|
|||
// Now let's display the face clustering results on the screen. You will see that it
|
|||
// correctly grouped all the faces.
|
|||
/*
|
|||
std::vector<image_window> win_clusters(num_clusters); |
|||
for( size_t cluster_id = 0; cluster_id < num_clusters; ++cluster_id ){ |
|||
std::vector<matrix<rgb_pixel>> temp; |
|||
for( size_t j = 0; j < labels.size(); ++j ){ |
|||
if (cluster_id == labels[j]) temp.push_back(faces[j]); |
|||
}; |
|||
win_clusters[cluster_id].set_title("face cluster " + cast_to_string(cluster_id)); |
|||
win_clusters[cluster_id].set_image(tile_images(temp)); |
|||
}; |
|||
|
|||
// Finally, let's print one of the face descriptors to the screen.
|
|||
cout << "face descriptor for one face: " << trans(face_descriptors[0]) << endl; |
|||
|
|||
// It should also be noted that face recognition accuracy can be improved if jittering
|
|||
// is used when creating face descriptors. In particular, to get 99.38% on the LFW
|
|||
// benchmark you need to use the jitter_image() routine to compute the descriptors,
|
|||
// like so:
|
|||
matrix<float,0,1> face_descriptor = mean(mat(net(jitter_image(faces[0])))); |
|||
cout << "jittered face descriptor for one face: " << trans(face_descriptor) << endl; |
|||
// If you use the model without jittering, as we did when clustering the bald guys, it
|
|||
// gets an accuracy of 99.13% on the LFW benchmark. So jittering makes the whole
|
|||
// procedure a little more accurate but makes face descriptor calculation slower.
|
|||
*/ |
|||
}; |
|||
}; |
|||
return retVal; |
|||
}; |
|||
|
|||
void IM_DlibWorker::m_fThreadProc( void ){ |
|||
m_bThreadStatus = TH_WORKING; |
|||
EVENT_CONTAINER *EVT_PTR = NULL; |
|||
while( m_bThreadStatus < TH_ENDED ) { |
|||
while (!m_bDataIsActive && m_bThreadStatus < TH_ENDED ) SLEEP( 20 ); |
|||
if( m_mBufferProtectorMutex.try_lock() ){ |
|||
if( m_bDataIsActive ){ |
|||
EVT_PTR =(EVENT_CONTAINER *) malloc(sizeof(EVENT_CONTAINER)); |
|||
if( EVT_PTR ) { |
|||
memset( EVT_PTR, 0, sizeof(EVENT_CONTAINER)); |
|||
EVT_PTR->m_eClass = EVT_CLASS_IMAGE; |
|||
EVT_PTR->m_eType = EVT_READY; |
|||
if( IM_RESULT *tData = m_fImageAnalyzer( m_oWorkingMat ) ){ |
|||
//generate detection event
|
|||
EVT_PTR->m_pEvtData = tData; |
|||
} else { |
|||
//generate NOT detection event
|
|||
EVT_PTR->m_pEvtData = NULL; |
|||
}; |
|||
}; |
|||
m_pActiveJob = NULL; |
|||
m_bDataIsActive = false; |
|||
}; |
|||
m_mBufferProtectorMutex.unlock(); |
|||
}; |
|||
if( EVT_PTR != NULL ) { |
|||
m_pEvtHeap->broadcast( EVT_PTR ); |
|||
EVT_PTR = NULL; |
|||
}; |
|||
}; |
|||
}; |
|||
|
|||
bool IM_DlibWorker::enqueueJob( IM_JOB *ptr ){ |
|||
if( ptr ) { |
|||
char tPath[1024]; |
|||
char p1[3]; |
|||
char p2[3]; |
|||
char p3[3]; |
|||
LOG( ptr->md5 ); |
|||
memcpy( p1, ptr->md5 , 2); p1[2]=(char)0; |
|||
memcpy( p2, ptr->md5+2, 2); p2[2]=(char)0; |
|||
memcpy( p3, ptr->md5+4, 2); p3[2]=(char)0; |
|||
switch( ptr->image_type ) { |
|||
case IM_ITEM_TYPE_JPEG: sprintf( tPath, "%s/%s/%s/%s/%s.jpg", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break; |
|||
case IM_ITEM_TYPE_PNG: sprintf( tPath, "%s/%s/%s/%s/%s.png", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break; |
|||
case IM_ITEM_TYPE_GIF: sprintf( tPath, "%s/%s/%s/%s/%s.gif", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break; |
|||
case IM_ITEM_TYPE_AGIF: sprintf( tPath, "%s/%s/%s/%s/%s.gif", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break; |
|||
case IM_ITEM_TYPE_TIFF: sprintf( tPath, "%s/%s/%s/%s/%s.tiff", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break; |
|||
}; |
|||
#ifdef DEBUG
|
|||
LOG( tPath ); |
|||
#endif
|
|||
Mat Frame = cv::imread( tPath, IMREAD_COLOR ); |
|||
try{ |
|||
while( m_bThreadStatus < TH_ENDED ) { |
|||
if( m_mBufferProtectorMutex.try_lock() ) { |
|||
Frame.copyTo( m_oWorkingMat ); |
|||
#ifdef DEBUG
|
|||
cv::imwrite("cur-test-img.jpg", m_oWorkingMat ); |
|||
//save_jpeg( m_oInputImg, "cur-test-img.jpg", 75 );
|
|||
#endif
|
|||
m_bDataIsActive = true; |
|||
m_pActiveJob = ptr; |
|||
m_mBufferProtectorMutex.unlock(); |
|||
return true; |
|||
} else SLEEP(5); |
|||
}; |
|||
} catch ( exception e ){ |
|||
LOG_ERROR( "Failure during Image Read!" ); |
|||
}; |
|||
}; |
|||
return false; |
|||
}; |
|||
|
|||
#undef LOG
|
|||
#undef LOG_ERROR
|
|||
@ -0,0 +1,118 @@ |
|||
#ifndef __IMAGE_MILL_DLIB_WORKER_HEADER__ |
|||
#define __IMAGE_MILL_DLIB_WORKER_HEADER__ |
|||
|
|||
#include "../../lib/components/base/basicThread.h" |
|||
#include "../../lib/components/base/basicMutex.h" |
|||
#include "../../lib/components/base/basicSettingsProvider.h" |
|||
#include "../../lib/components/base/basicEventHeap.h" |
|||
|
|||
#include "IM_DataStructs.h" |
|||
#include "IM_DataBaseAdapter.h" |
|||
|
|||
#define DLIB |
|||
|
|||
#ifdef DLIB |
|||
#define GPU |
|||
//#include <darknet/darknet.h> |
|||
//#include <darknet/yolo_v2_class.hpp> |
|||
#undef GPU |
|||
#endif |
|||
|
|||
#include <opencv2/opencv.hpp> |
|||
#include <opencv2/core.hpp> |
|||
#include <opencv2/imgcodecs.hpp> |
|||
#include <opencv2/highgui.hpp> |
|||
#include <opencv2/dnn/dnn.hpp> |
|||
|
|||
#include <dlib/dnn.h> |
|||
//#include <dlib/gui_widgets.h> |
|||
#include <dlib/clustering.h> |
|||
#include <dlib/string.h> |
|||
#include <dlib/image_io.h> |
|||
#include <dlib/image_processing/frontal_face_detector.h> |
|||
#include <dlib/opencv.h> |
|||
|
|||
|
|||
using namespace cv; |
|||
using namespace dlib; |
|||
using namespace std; |
|||
|
|||
template <template <int,template<typename>class,int,typename> class block, int N, template<typename>class BN, typename SUBNET> |
|||
using residual = add_prev1<block<N,BN,1,tag1<SUBNET>>>; |
|||
|
|||
template <template <int,template<typename>class,int,typename> class block, int N, template<typename>class BN, typename SUBNET> |
|||
using residual_down = add_prev2<avg_pool<2,2,2,2,skip1<tag2<block<N,BN,2,tag1<SUBNET>>>>>>; |
|||
|
|||
template <int N, template <typename> class BN, int stride, typename SUBNET> |
|||
using block = BN<con<N,3,3,1,1,relu<BN<con<N,3,3,stride,stride,SUBNET>>>>>; |
|||
|
|||
template <int N, typename SUBNET> using ares = relu<residual<block,N,affine,SUBNET>>; |
|||
template <int N, typename SUBNET> using ares_down = relu<residual_down<block,N,affine,SUBNET>>; |
|||
|
|||
template <typename SUBNET> using alevel0 = ares_down<256,SUBNET>; |
|||
template <typename SUBNET> using alevel1 = ares<256,ares<256,ares_down<256,SUBNET>>>; |
|||
template <typename SUBNET> using alevel2 = ares<128,ares<128,ares_down<128,SUBNET>>>; |
|||
template <typename SUBNET> using alevel3 = ares<64,ares<64,ares<64,ares_down<64,SUBNET>>>>; |
|||
template <typename SUBNET> using alevel4 = ares<32,ares<32,ares<32,SUBNET>>>; |
|||
|
|||
using anet_type = loss_metric<fc_no_bias<128,avg_pool_everything< |
|||
alevel0< |
|||
alevel1< |
|||
alevel2< |
|||
alevel3< |
|||
alevel4< |
|||
max_pool<3,3,2,2,relu<affine<con<32,7,7,2,2, |
|||
input_rgb_image_sized<150> |
|||
>>>>>>>>>>>>; |
|||
|
|||
// ---------------------------------------------------------------------------------------- |
|||
|
|||
|
|||
std::vector<matrix<rgb_pixel>> jitter_image( const matrix<rgb_pixel>& img ); |
|||
|
|||
/** |
|||
* TODO: Add class description |
|||
* |
|||
* @author Gagua |
|||
*/ |
|||
class IM_DlibWorker : public basicThread{ |
|||
private: |
|||
|
|||
frontal_face_detector m_oFaceDetector; |
|||
shape_predictor m_oShapePredictor; |
|||
anet_type m_oNet; |
|||
IM_DataBaseAdapter * m_pDBA; |
|||
//matrix<rgb_pixel> m_oInputImg; |
|||
//std::vector<matrix<rgb_pixel>> m_vFacesImg; |
|||
|
|||
basicLogCollection * m_pLog; |
|||
config_setting_t * m_pSettings; |
|||
basicEventHeap * m_pEvtHeap; |
|||
cv::Mat m_oWorkingMat; |
|||
float m_fDetectionProbability; |
|||
bool m_bUseShapePredictor; |
|||
bool m_bUseFaceRecognition; |
|||
char m_pPicturesBase[1024]; |
|||
char m_pFacesBase[1024]; |
|||
char m_pShapePredictorPath[1024]; |
|||
char m_pNetModelPath[1024]; |
|||
char m_sChownUser[64]; |
|||
char m_sChownGroup[64]; |
|||
basicMutex m_mBufferProtectorMutex; |
|||
IM_JOB * m_pActiveJob; |
|||
bool m_bDataIsActive; |
|||
CSTR m_fSaveFace( matrix<rgb_pixel> &Picture, CSTR md5, uint32_t index ); |
|||
IM_RESULT * m_fImageAnalyzer( cv::Mat &Picture ); |
|||
protected: |
|||
virtual void m_fThreadProc( void );//getLayerNames() |
|||
public: |
|||
// Constructor |
|||
explicit IM_DlibWorker( config_setting_t * Settings = NULL ); |
|||
// Destructor |
|||
virtual ~IM_DlibWorker(); |
|||
bool create( void ); |
|||
bool enqueueJob( IM_JOB *ptr ); |
|||
}; |
|||
|
|||
|
|||
#endif |
|||
@ -0,0 +1,251 @@ |
|||
#include "IM_DataBaseAdapter.h"
|
|||
#include "../../lib/alg/generic/md5.h"
|
|||
|
|||
#define LOG( X ) m_pLog->Log( "IMDBA", this, X )
|
|||
#ifdef DEBUG
|
|||
#define LOG_ERROR( X ) {\
|
|||
char _tBfrErrMSG234[256];\ |
|||
sprintf( _tBfrErrMSG234, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\ |
|||
m_pLog->Log( "IMDBA", this, _LOG_ERROR, _tBfrErrMSG234 );\ |
|||
} |
|||
#else
|
|||
#define LOG_ERROR( X ) m_pLog->Log( "IMDBA", this, _LOG_ERROR, X );
|
|||
#endif
|
|||
|
|||
IM_DataBaseAdapter* IM_DataBaseAdapter::_instance = NULL; |
|||
|
|||
/**
|
|||
* Returns the single instance of the object. |
|||
*/ |
|||
IM_DataBaseAdapter* IM_DataBaseAdapter::getInstance( config_setting_t * Settings ) { |
|||
// check if the instance has been created yet
|
|||
if( NULL == _instance ){ |
|||
// if not, then create it
|
|||
_instance = new IM_DataBaseAdapter( Settings ); |
|||
}; |
|||
// return the single instance
|
|||
return _instance; |
|||
}; |
|||
|
|||
// Constructor implementation
|
|||
inline IM_DataBaseAdapter::IM_DataBaseAdapter( config_setting_t * Settings ){ |
|||
m_pLog = basicLogCollection::getInstance(); |
|||
m_pSettings = basicSettingsProvider::getInstance()->getSubNode( Settings, "DBC" ); |
|||
m_bIsConnected = false; |
|||
if( m_pSettings!= NULL ) { |
|||
config_setting_t * tSetting; |
|||
char tDBHost[128]; |
|||
char tDBName[128]; |
|||
char tDBUser[128]; |
|||
char tDBPass[128]; |
|||
uint16_t tDBPort = 3306; |
|||
tSetting = config_setting_get_member( m_pSettings, "DATABASE_HOST" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "DATABASE_HOST", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "localhost" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No DB Host Setting! Using default!"); |
|||
}; |
|||
sprintf(tDBHost, "%s", config_setting_get_string(tSetting)); |
|||
tSetting = config_setting_get_member( m_pSettings, "DATABASE_NAME" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "DATABASE_NAME", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "dfsl_gunter" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No DB Database Setting! Using default!"); |
|||
}; |
|||
sprintf(tDBName, "%s", config_setting_get_string(tSetting)); |
|||
tSetting = config_setting_get_member( m_pSettings, "DATABASE_USER" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "DATABASE_USER", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "dbroot" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No DB User Setting! Using default!"); |
|||
}; |
|||
sprintf(tDBUser, "%s", config_setting_get_string(tSetting)); |
|||
tSetting = config_setting_get_member( m_pSettings, "DATABASE_PASSWORD" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "DATABASE_PASSWORD", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "123567" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No DB Password Setting! Using default!"); |
|||
}; |
|||
sprintf(tDBPass, "%s", config_setting_get_string(tSetting)); |
|||
tSetting = config_setting_get_member( m_pSettings, "DATABASE_PORT" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "DATABASE_PORT", CONFIG_TYPE_INT ); |
|||
config_setting_set_int( tSetting, 3306 ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No DB Port Setting! Using default!"); |
|||
}; |
|||
tDBPort = config_setting_get_int( tSetting ); |
|||
basicSettingsProvider::getInstance()->validate(); |
|||
m_pConnectorClass = new MySQL_Connector( tDBName, tDBHost, tDBUser, tDBPass, tDBPort ); |
|||
m_bIsConnected = ( m_pConnectorClass != NULL ); |
|||
} else { |
|||
LOG_ERROR("No Settings Provided!"); |
|||
}; |
|||
}; |
|||
|
|||
// Destructor implementation
|
|||
inline IM_DataBaseAdapter::~IM_DataBaseAdapter(){ |
|||
if( m_pConnectorClass ) delete( m_pConnectorClass ); |
|||
}; |
|||
|
|||
IM_ITEM_DATA *IM_DataBaseAdapter::getItemDataById( uint32_t itemID ){ |
|||
IM_ITEM_DATA *tVal = NULL; |
|||
if( m_pConnectorClass ) { |
|||
char tQBuf[CTEXT]; |
|||
AAssoc *result; |
|||
sprintf(tQBuf, "SELECT `id`, `md5`, `width`, `height`, `4cc` FROM `items` WHERE `type`=2 AND `id`=%d", itemID ); |
|||
#ifdef DEBUG
|
|||
LOG(tQBuf); |
|||
#endif
|
|||
result = m_pConnectorClass->Query( tQBuf ); |
|||
if( result!= NULL ) { |
|||
if( result->size() > 0 ) { |
|||
Assoc *cArr; |
|||
tVal = (IM_ITEM_DATA*) malloc(sizeof(IM_ITEM_DATA)); |
|||
if( tVal != NULL ) { |
|||
Assoc::iterator it; |
|||
|
|||
memset( tVal, 0, sizeof(IM_ITEM_DATA) ); |
|||
cArr = result->at(0); |
|||
it = cArr->find("id"); |
|||
if( it != cArr->end() ){ |
|||
tVal->item_id = atoi( it->second.c_str() ); |
|||
}; |
|||
it = cArr->find("md5"); |
|||
if( it != cArr->end() ){ |
|||
strncpy( tVal->md5, it->second.c_str(), 32 ); |
|||
}; |
|||
it = cArr->find("width"); |
|||
if( it != cArr->end() ){ |
|||
tVal->width = atoi( it->second.c_str() ); |
|||
}; |
|||
it = cArr->find("height"); |
|||
if( it != cArr->end() ){ |
|||
tVal->height = atoi( it->second.c_str() ); |
|||
}; |
|||
it = cArr->find("4cc"); |
|||
if( it != cArr->end() ){ |
|||
if( strstr( it->second.c_str(),"JPEG" ) ) tVal->type = IM_ITEM_TYPE_JPEG; |
|||
if( strstr( it->second.c_str(),"PNG" ) ) tVal->type = IM_ITEM_TYPE_PNG; |
|||
if( strstr( it->second.c_str(),"GIF" ) ) tVal->type = IM_ITEM_TYPE_GIF; |
|||
if( strstr( it->second.c_str(),"TIFF" ) ) tVal->type = IM_ITEM_TYPE_TIFF; |
|||
if( strstr( it->second.c_str(),"AGIF" ) ) tVal->type = IM_ITEM_TYPE_AGIF; |
|||
}; |
|||
}; |
|||
}; |
|||
}; |
|||
deleteResult( result ); |
|||
}; |
|||
return tVal; |
|||
}; |
|||
|
|||
IM_ITEM_DATA *IM_DataBaseAdapter::getItemDataByMd5( CSTR md5 ){ |
|||
IM_ITEM_DATA *tVal = NULL; |
|||
if( m_pConnectorClass ) { |
|||
char tQBuf[CTEXT]; |
|||
AAssoc *result; |
|||
sprintf(tQBuf, "SELECT `id`, `md5`, `width`, `height`, `4cc` FROM `items` WHERE `type`=2 AND `md5`='%s'", md5 ); |
|||
#ifdef DEBUG
|
|||
LOG(tQBuf); |
|||
#endif
|
|||
result = m_pConnectorClass->Query( tQBuf ); |
|||
if( result!= NULL ) { |
|||
if( result->size() > 0 ) { |
|||
Assoc *cArr; |
|||
tVal = (IM_ITEM_DATA*) malloc(sizeof(IM_ITEM_DATA)); |
|||
if( tVal != NULL ) { |
|||
Assoc::iterator it; |
|||
|
|||
memset( tVal, 0, sizeof(IM_ITEM_DATA) ); |
|||
cArr = result->at(0); |
|||
it = cArr->find("id"); |
|||
if( it != cArr->end() ){ |
|||
tVal->item_id = atoi( it->second.c_str() ); |
|||
}; |
|||
it = cArr->find("md5"); |
|||
if( it != cArr->end() ){ |
|||
strncpy( tVal->md5, it->second.c_str(), 32 ); |
|||
}; |
|||
it = cArr->find("width"); |
|||
if( it != cArr->end() ){ |
|||
tVal->width = atoi( it->second.c_str() ); |
|||
}; |
|||
it = cArr->find("height"); |
|||
if( it != cArr->end() ){ |
|||
tVal->height = atoi( it->second.c_str() ); |
|||
}; |
|||
it = cArr->find("4cc"); |
|||
if( it != cArr->end() ){ |
|||
if( strstr( it->second.c_str(),"JPEG" ) ) tVal->type = IM_ITEM_TYPE_JPEG; |
|||
if( strstr( it->second.c_str(),"PNG" ) ) tVal->type = IM_ITEM_TYPE_PNG; |
|||
if( strstr( it->second.c_str(),"GIF" ) ) tVal->type = IM_ITEM_TYPE_GIF; |
|||
if( strstr( it->second.c_str(),"TIFF" ) ) tVal->type = IM_ITEM_TYPE_TIFF; |
|||
if( strstr( it->second.c_str(),"AGIF" ) ) tVal->type = IM_ITEM_TYPE_AGIF; |
|||
}; |
|||
}; |
|||
}; |
|||
}; |
|||
deleteResult( result ); |
|||
}; |
|||
return tVal; |
|||
}; |
|||
|
|||
void IM_DataBaseAdapter::insertItemROI( uint32_t itemID, uint32_t classID, float weight, uint32_t x, uint32_t y, uint32_t w, uint32_t h ){ |
|||
if( m_pConnectorClass ) { |
|||
char tQBuf[CTEXT]; |
|||
sprintf(tQBuf, "INSERT INTO `item_rois` SET `item_id`=%d, `class_id`=%d, `probability`=%.5f, `x`=%d, `y`=%d, `width`=%d, `height`=%d", itemID, classID, weight, x, y, w, h ); |
|||
#ifdef DEBUG
|
|||
LOG(tQBuf); |
|||
#endif
|
|||
m_pConnectorClass->SilentQuery( tQBuf ); |
|||
}; |
|||
}; |
|||
|
|||
uint32_t IM_DataBaseAdapter::insertItemFace( uint32_t itemID, CSTR md5, uint32_t x, uint32_t y, uint32_t w, uint32_t h ){ |
|||
uint32_t RetVal = 0; |
|||
if( m_pConnectorClass ) { |
|||
char tQBuf[CTEXT]; |
|||
sprintf(tQBuf, "INSERT INTO `faces_chips` SET `item_id`=%d, `md5`='%s', `x`=%d, `y`=%d, `w`=%d, `h`=%d ON DUPLICATE KEY UPDATE `item_id`=%d, `x`=%d, `y`=%d, `w`=%d", itemID, md5, x, y, w, h, itemID, x, y, w, h ); |
|||
#ifdef DEBUG
|
|||
LOG(tQBuf); |
|||
#endif
|
|||
RetVal = m_pConnectorClass->QueryID( tQBuf ); |
|||
if( RetVal == 0 ) { |
|||
AAssoc *result; |
|||
sprintf(tQBuf, "SELECT `id` FROM `faces_chips` WHERE `md5`='%s' ", md5 ); |
|||
result = m_pConnectorClass->Query( tQBuf ); |
|||
if( result!= NULL ) { |
|||
if( result->size() > 0 ) { |
|||
Assoc *cArr; |
|||
Assoc::iterator it; |
|||
cArr = result->at(0); |
|||
it = cArr->find("id"); |
|||
if( it != cArr->end() ){ |
|||
RetVal = atoi( it->second.c_str() ); |
|||
}; |
|||
}; |
|||
}; |
|||
deleteResult( result ); |
|||
}; |
|||
}; |
|||
return RetVal; |
|||
}; |
|||
|
|||
void IM_DataBaseAdapter::updateItemFace( uint32_t itemID, uint8_t dID, float P ){ |
|||
if( m_pConnectorClass ) { |
|||
char tQBuf[CTEXT]; |
|||
sprintf(tQBuf, "UPDATE `faces_chips` SET `a_%d`=%.5f WHERE `id`=%d", dID, P, itemID ); |
|||
#ifdef DEBUG
|
|||
LOG(tQBuf); |
|||
#endif
|
|||
m_pConnectorClass->SilentQuery( tQBuf ); |
|||
}; |
|||
}; |
|||
|
|||
#undef LOG
|
|||
#undef LOG_ERROR
|
|||
|
|||
@ -0,0 +1,53 @@ |
|||
#ifndef __IM_DATABASEADAPTER_H_INCL__ |
|||
#define __IM_DATABASEADAPTER_H_INCL__ |
|||
|
|||
#include "../../lib/data/mysql/mysql_class.h" |
|||
#include "../../lib/components/base/basicSettingsProvider.h" |
|||
#include "IM_DataStructs.h" |
|||
|
|||
/** |
|||
* TODO: Add class description |
|||
* |
|||
* @author Gagua |
|||
*/ |
|||
class IM_DataBaseAdapter { |
|||
private: |
|||
basicLogCollection * m_pLog; |
|||
config_setting_t * m_pSettings; |
|||
bool m_bIsConnected; |
|||
MySQL_Connector * m_pConnectorClass; |
|||
public: |
|||
// Method to fetch singleton instance. |
|||
static IM_DataBaseAdapter* getInstance( config_setting_t * Settings = NULL ); |
|||
|
|||
// Destructor |
|||
virtual ~IM_DataBaseAdapter(); |
|||
|
|||
IM_ITEM_DATA * getItemDataById( uint32_t itemID ); |
|||
IM_ITEM_DATA * getItemDataByMd5( CSTR md5 ); |
|||
void insertItemROI( uint32_t itemID, uint32_t classID, float weight, uint32_t x, uint32_t y, uint32_t w, uint32_t h ); |
|||
uint32_t insertItemFace( uint32_t itemID, CSTR md5, uint32_t x, uint32_t y, uint32_t w, uint32_t h ); |
|||
void updateItemFace( uint32_t itemID, uint8_t dID, float P ); |
|||
protected: |
|||
// Constructor - protected so users cannot call it. |
|||
explicit IM_DataBaseAdapter( config_setting_t * Settings ); |
|||
|
|||
private: |
|||
// private static member referencing the single instance of the object |
|||
// TODO: Replace IM_DataBaseAdapter with the type of object you want to |
|||
// return the single instance of |
|||
static IM_DataBaseAdapter* _instance; |
|||
|
|||
// Copy constructor |
|||
// Declared but not defined to prevent auto-generated |
|||
// copy constructor. Refer to "Effective C++" by Meyers |
|||
IM_DataBaseAdapter(const IM_DataBaseAdapter& src); |
|||
|
|||
// Assignment operator |
|||
// Declared but not defined to prevent auto-generated |
|||
// assignment operator. Refer to "Effective C++" by Meyers |
|||
IM_DataBaseAdapter& operator=(const IM_DataBaseAdapter& src); |
|||
|
|||
}; |
|||
|
|||
#endif // __IM_DATABASEADAPTER_H_INCL__ |
|||
@ -0,0 +1,30 @@ |
|||
#include "IM_DataStructs.h"
|
|||
|
|||
CSTR buildMd5Path( CSTR base, CSTR md5, mode_t mode, CSTR user, CSTR group ){ |
|||
char tPath[1024]; |
|||
char p1[3]; |
|||
char p2[3]; |
|||
char p3[3]; |
|||
if(!fileExist( base )) return NULL; |
|||
memcpy( p1, md5 , 2); p1[2]=(char)0; |
|||
sprintf( tPath, "%s/%s", base, p1 ); |
|||
if(!fileExist( tPath )) { |
|||
if( mkdir( tPath, mode )==-1) return NULL; |
|||
if( user!= NULL && group!= NULL ) ch_chown( tPath, user, group ); |
|||
}; |
|||
memcpy( p2, md5+2, 2); p2[2]=(char)0; |
|||
sprintf( tPath, "%s/%s/%s", base, p1, p2 ); |
|||
if(!fileExist( tPath )){ |
|||
if( mkdir( tPath, mode )==-1) return NULL; |
|||
if( user!= NULL && group!= NULL ) ch_chown( tPath, user, group ); |
|||
}; |
|||
memcpy( p3, md5+4, 2); p3[2]=(char)0; |
|||
sprintf( tPath, "%s/%s/%s/%s", base, p1, p2, p3 ); |
|||
if(!fileExist( tPath )) { |
|||
if( mkdir( tPath, mode )==-1) return NULL; |
|||
if( user!= NULL && group!= NULL ) ch_chown( tPath, user, group ); |
|||
}; |
|||
return strdup( tPath ); |
|||
}; |
|||
|
|||
|
|||
@ -0,0 +1,60 @@ |
|||
#ifndef __IMAGE_MILL_DATA_STRUCTURES_HEADER__ |
|||
#define __IMAGE_MILL_DATA_STRUCTURES_HEADER__ |
|||
|
|||
#include "../../lib/components/base/basicFunctionality.h" |
|||
#include <queue> |
|||
|
|||
typedef struct S_IM_ITEM_DATA{ |
|||
uint32_t item_id; |
|||
char md5[33]; |
|||
uint8_t process_type; |
|||
uint32_t width; |
|||
uint32_t height; |
|||
uint8_t type; |
|||
}IM_ITEM_DATA; |
|||
|
|||
typedef enum E_IM_ITEM_TYPES{ |
|||
IM_ITEM_TYPE_JPEG = 0, |
|||
IM_ITEM_TYPE_PNG = 1, |
|||
IM_ITEM_TYPE_GIF = 2, |
|||
IM_ITEM_TYPE_AGIF = 3, |
|||
IM_ITEM_TYPE_TIFF = 4 |
|||
}IM_ITEM_TYPES; |
|||
|
|||
typedef enum E_IM_PROCESS_TYPES{ |
|||
IM_PROC_TYPE_DNN = 0, |
|||
IM_PROC_TYPE_FACE = 1 |
|||
}IM_PROCESS_TYPES; |
|||
|
|||
typedef struct S_IM_JOB{ |
|||
uint32_t dbID; |
|||
uint8_t job_type; |
|||
uint8_t image_type; |
|||
uint32_t width; |
|||
uint32_t height; |
|||
uint32_t depth; |
|||
char md5[33]; |
|||
}IM_JOB; |
|||
|
|||
typedef struct S_IM_CLASS_BOUNDARY_BOX{ |
|||
uint32_t classID; |
|||
float weight; |
|||
uint32_t x; |
|||
uint32_t y; |
|||
uint32_t width; |
|||
uint32_t height; |
|||
uint32_t depth; |
|||
}IM_CLASS_BOUNDARY_BOX; |
|||
|
|||
typedef struct S_IM_RESULT{ |
|||
IM_JOB * pJOB; |
|||
uint32_t nBoxCount; |
|||
IM_CLASS_BOUNDARY_BOX * boxes; |
|||
}IM_RESULT; |
|||
|
|||
typedef std::queue<IM_JOB *> IM_JOB_QUEUE; |
|||
|
|||
CSTR buildMd5Path( CSTR base, CSTR md5, mode_t mode = 0755, CSTR user=NULL, CSTR group=NULL ); |
|||
|
|||
|
|||
#endif |
|||
@ -0,0 +1,349 @@ |
|||
#include "IM_DnnWorker.h"
|
|||
#include "../../lib/components/base/basicFunctionality.h"
|
|||
|
|||
#define LOG( X ) m_pLog->Log( "WDNN", this, X )
|
|||
#ifdef DEBUG
|
|||
#define LOG_ERROR( X ) {\
|
|||
char _tBfrErrMSG234[256];\ |
|||
sprintf( _tBfrErrMSG234, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\ |
|||
m_pLog->Log( "WDNN", this, _LOG_ERROR, _tBfrErrMSG234 );\ |
|||
} |
|||
#else
|
|||
#define LOG_ERROR( X ) m_pLog->Log( "WDNN", this, _LOG_ERROR, X );
|
|||
#endif
|
|||
|
|||
// Constructor implementation
|
|||
IM_DnnWorker::IM_DnnWorker( config_setting_t * Settings ) : basicThread(), m_mBufferProtectorMutex(){ |
|||
m_pLog = basicLogCollection::getInstance(); |
|||
m_pSettings = basicSettingsProvider::getInstance()->getSubNode( Settings, "DNN" ); |
|||
m_pEvtHeap = basicEventHeap::getInstance(); |
|||
m_eBackendEngine = cv::dnn::DNN_BACKEND_DEFAULT; |
|||
m_eTargetDevice = cv::dnn::DNN_TARGET_CPU; |
|||
m_pActiveJob = NULL; |
|||
|
|||
#ifdef DARKNET
|
|||
m_pDarknetDetector = NULL; |
|||
#endif
|
|||
|
|||
m_bDataIsActive = false; |
|||
}; |
|||
|
|||
// Destructor implementation
|
|||
IM_DnnWorker::~IM_DnnWorker(){ |
|||
#ifdef DARKNET
|
|||
if( m_pDarknetDetector ) delete( m_pDarknetDetector ); |
|||
#endif
|
|||
}; |
|||
|
|||
bool IM_DnnWorker::create( void ){ |
|||
char tBuff[256]; |
|||
if( m_pSettings == NULL ){ |
|||
return false; |
|||
} else { |
|||
config_setting_t * tSetting; |
|||
tSetting = config_setting_get_member( m_pSettings, "PICTURES_BASE" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "PICTURES_BASE", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "/srv/vault" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Pictures Base Path! Using default!"); |
|||
}; |
|||
sprintf( m_pPicturesBase, "%s", config_setting_get_string(tSetting)); |
|||
tSetting = config_setting_get_member( m_pSettings, "NET_CONFIG_FILE" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "NET_CONFIG_FILE", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "conf/yolo9000.cfg" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Net Config File! Using default!"); |
|||
}; |
|||
sprintf( m_pConfigPath, "%s", config_setting_get_string(tSetting)); |
|||
tSetting = config_setting_get_member( m_pSettings, "NET_WEIGHTS_FILE" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "NET_WEIGHTS_FILE", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "data/yolo9000.weights" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Net Weights File! Using default!"); |
|||
}; |
|||
sprintf( m_pWeightsPath, "%s", config_setting_get_string(tSetting)); |
|||
tSetting = config_setting_get_member( m_pSettings, "DETECTION_PROBABILITY" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "DETECTION_PROBABILITY", CONFIG_TYPE_FLOAT ); |
|||
config_setting_set_float( tSetting, 0.5f ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Probability Set! Using default!"); |
|||
}; |
|||
m_fDetectionProbability = config_setting_get_float(tSetting); |
|||
tSetting = config_setting_get_member( m_pSettings, "USE_CLASS_MAP" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "USE_CLASS_MAP", CONFIG_TYPE_BOOL ); |
|||
config_setting_set_bool( tSetting, 0 ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Class Map Usage Set! Using default!"); |
|||
}; |
|||
m_bUseClassMapping = (bool) config_setting_get_bool(tSetting); |
|||
if( m_bUseClassMapping ) { |
|||
char tMapFileName[1024]; |
|||
FILE *fd; |
|||
tSetting = config_setting_get_member( m_pSettings, "CLASS_MAP_FILE" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "CLASS_MAP_FILE", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "data/coco9k.map" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Class Map File Set! Using default!"); |
|||
}; |
|||
sprintf( tMapFileName, "%s", config_setting_get_string(tSetting) ); |
|||
fd = fopen( tMapFileName, "r" ); |
|||
if( fd ) { |
|||
uint32_t tV; |
|||
uint32_t idx = 0; |
|||
char tB[128]; |
|||
while( !feof(fd) ) { |
|||
if( fgets( tB, 128, fd ) ){ |
|||
tV = atoi( tB )+1; |
|||
m_vClassesMap.push_back( tV ); |
|||
idx++; |
|||
}; |
|||
}; |
|||
fclose( fd ); |
|||
sprintf( tB, "Loadded %d classes map", idx ); |
|||
LOG( tB ); |
|||
} else { |
|||
m_bUseClassMapping = false; |
|||
}; |
|||
}; |
|||
tSetting = config_setting_get_member( m_pSettings, "NET_TARGET_DEVICE" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "NET_TARGET_DEVICE", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "CPU" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Net Target Device! Using default!"); |
|||
}; |
|||
if( strstr( config_setting_get_string(tSetting), "CPU" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_CPU; |
|||
if( strstr( config_setting_get_string(tSetting), "OPENCL_FP16" )!=NULL ){ |
|||
m_eTargetDevice = cv::dnn::DNN_TARGET_OPENCL_FP16; |
|||
} else { |
|||
if( strstr( config_setting_get_string(tSetting), "OPENCL" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_OPENCL; |
|||
}; |
|||
if( strstr( config_setting_get_string(tSetting), "MYRIAD" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_MYRIAD; |
|||
if( strstr( config_setting_get_string(tSetting), "VULKAN" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_VULKAN; |
|||
if( strstr( config_setting_get_string(tSetting), "FPGA" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_FPGA; |
|||
if( strstr( config_setting_get_string(tSetting), "CUDA_FP16" )!=NULL ){ |
|||
m_eTargetDevice = cv::dnn::DNN_TARGET_CUDA_FP16; |
|||
} else { |
|||
if( strstr( config_setting_get_string(tSetting), "CUDA" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_CUDA; |
|||
}; |
|||
if( strstr( config_setting_get_string(tSetting), "HDDL" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_HDDL; |
|||
sprintf( tBuff, "Device: %s", config_setting_get_string(tSetting) ); |
|||
LOG( tBuff ); |
|||
|
|||
tSetting = config_setting_get_member( m_pSettings, "NET_BACKEND_ENGINE" ); |
|||
if( tSetting == NULL ){ |
|||
tSetting = config_setting_add(m_pSettings, "NET_BACKEND_ENGINE", CONFIG_TYPE_STRING ); |
|||
config_setting_set_string( tSetting, "DEFAULT" ); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
LOG("No Net Backend Engine! Using default!"); |
|||
}; |
|||
if( strstr( config_setting_get_string(tSetting), "DEFAULT" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_DEFAULT; |
|||
if( strstr( config_setting_get_string(tSetting), "HALIDE" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_HALIDE; |
|||
if( strstr( config_setting_get_string(tSetting), "INFERENCE" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_INFERENCE_ENGINE; |
|||
if( strstr( config_setting_get_string(tSetting), "OPENCV" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_OPENCV; |
|||
if( strstr( config_setting_get_string(tSetting), "VKCOM" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_VKCOM; |
|||
if( strstr( config_setting_get_string(tSetting), "CUDA" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_CUDA; |
|||
sprintf( tBuff, "Engine: %s", config_setting_get_string(tSetting) ); |
|||
LOG( tBuff ); |
|||
basicSettingsProvider::getInstance()->validate(); |
|||
}; |
|||
sprintf( tBuff, "loading DNN from disk... CONF: %s WEIGHT: %s", m_pConfigPath, m_pWeightsPath ); |
|||
LOG( tBuff ); |
|||
if(!fileExist( m_pConfigPath )) { |
|||
LOG_ERROR("No Config file exists!"); |
|||
return false; |
|||
}; |
|||
if(!fileExist( m_pWeightsPath )) { |
|||
LOG_ERROR("No Weight file exists!"); |
|||
return false; |
|||
}; |
|||
#ifdef DARKNET
|
|||
try { |
|||
m_pDarknetDetector = new Detector( m_pConfigPath, m_pWeightsPath ); |
|||
if( m_pDarknetDetector ) { |
|||
LOG("DarkNet Detector Created"); |
|||
} else { |
|||
LOG_ERROR("Failure during DarkNet Detector Creation!"); |
|||
}; |
|||
} catch ( exception e ) { |
|||
LOG_ERROR( e.what() ); |
|||
}; |
|||
#else
|
|||
m_net = cv::dnn::readNetFromDarknet( m_pConfigPath, m_pWeightsPath ); |
|||
m_net.setPreferableBackend( m_eBackendEngine ); |
|||
m_net.setPreferableTarget( m_eTargetDevice ); |
|||
std::vector<String> outNames = m_net.getUnconnectedOutLayersNames(); |
|||
LOG("OutNames"); |
|||
for( std::vector<String>::iterator idx = outNames.begin(); idx < outNames.end(); idx++ ) { |
|||
LOG( (*idx).c_str() ); |
|||
}; |
|||
#endif
|
|||
return init(); |
|||
}; |
|||
|
|||
IM_RESULT *IM_DnnWorker::m_fImageAnalyzer( Mat &Picture ){ |
|||
Size inpSize; |
|||
bool swapRB = true; //BGR->RGB
|
|||
double scale = 1.0;///255.0;
|
|||
Scalar mean; |
|||
IM_RESULT * retVal = NULL; |
|||
inpSize.width = Picture.cols; |
|||
inpSize.height = Picture.rows; |
|||
#ifndef DARKNET
|
|||
try { |
|||
LOG("Create a 4D blob from a frame"); |
|||
//cv::resize( m_oWorkingMat, m_oWorkingMat, cv::Size(416, 416));
|
|||
Mat blob = cv::dnn::blobFromImage( Picture, scale, Size(416, 416), mean, swapRB, false, CV_8U ); |
|||
|
|||
if( blob.empty() ) { |
|||
LOG_ERROR("Failure Creating Blob!"); |
|||
return retVal; |
|||
}; |
|||
// construct a blob from the input frame and then perform a forward
|
|||
// pass of the YOLO object detector, giving us our bounding boxes
|
|||
// and associated probabilities
|
|||
//blob = cv2.dnn.blobFromImage(frame, 1 / 255.0, (416, 416), swapRB=True, crop=False )
|
|||
//net.setInput(blob)
|
|||
//layerOutputs = net.forward(ln)
|
|||
// Run a model.
|
|||
LOG("Set BLOB to NET"); |
|||
m_net.setInput( blob ); |
|||
//std::vector<Mat> outs;
|
|||
//std::vector<String> outNames = m_net.getUnconnectedOutLayersNames();
|
|||
Mat outMat = m_net.forward( String( "detection_out" )); |
|||
LOG("DONE!"); |
|||
/*
|
|||
if( m_net.getLayer(0)->outputNameToIndex("im_info") != -1 ){ |
|||
// Faster-RCNN or R-FCN
|
|||
//resize( Picture, Picture, inpSize );
|
|||
cv::resize( Picture, Picture, cv::Size(416, 416)); |
|||
Mat imInfo = ( Mat_<float>(1, 3) << inpSize.height, inpSize.width, 1.6f); |
|||
m_net.setInput( imInfo, "im_info" ); |
|||
}; |
|||
*/ |
|||
} catch ( cv::Exception& e ) { |
|||
LOG_ERROR("Catched Exception"); |
|||
LOG_ERROR( e.what() ); |
|||
}; |
|||
#else
|
|||
std::shared_ptr<image_t> img = m_pDarknetDetector->mat_to_image_resize( Picture ); |
|||
std::vector<bbox_t> result_vec; |
|||
//result_vec = detector.detect_resized( * img, inpSize.width, inpSize.height, thresh, true);
|
|||
result_vec = m_pDarknetDetector->detect_resized( *img, inpSize.width, inpSize.height, m_fDetectionProbability, true); |
|||
if( result_vec.size() ) { |
|||
retVal = (IM_RESULT *)malloc(sizeof(IM_RESULT)); |
|||
if( retVal ) { |
|||
retVal->pJOB = m_pActiveJob; |
|||
retVal->nBoxCount = result_vec.size(); |
|||
retVal->boxes = (IM_CLASS_BOUNDARY_BOX *) calloc( retVal->nBoxCount,sizeof(IM_CLASS_BOUNDARY_BOX)); |
|||
if( retVal->boxes ) { |
|||
for( int i=0; i< result_vec.size(); i++ ) { |
|||
bbox_t * b = &(result_vec.at(i)); |
|||
retVal->boxes[i].weight = b->prob; |
|||
retVal->boxes[i].x = b->x; |
|||
retVal->boxes[i].y = b->y; |
|||
retVal->boxes[i].width = b->w; |
|||
retVal->boxes[i].height = b->h; |
|||
if( m_bUseClassMapping ){ |
|||
retVal->boxes[i].classID = m_vClassesMap[b->obj_id]; |
|||
} else { |
|||
retVal->boxes[i].classID = b->obj_id; |
|||
}; |
|||
#ifdef DEBUG
|
|||
char msg[256]; |
|||
sprintf( msg, "[%d] Class: %d Prob: %.2f X:%d Y:%d W:%d H:%d", i, retVal->boxes[i].classID, retVal->boxes[i].weight, b->x, b->y, b->w, b->h ); |
|||
LOG( msg ); |
|||
#endif
|
|||
}; |
|||
} else { |
|||
free(retVal); |
|||
retVal = NULL; |
|||
}; |
|||
}; |
|||
}; |
|||
#endif
|
|||
return retVal; |
|||
}; |
|||
|
|||
void IM_DnnWorker::m_fThreadProc( void ){ |
|||
m_bThreadStatus = TH_WORKING; |
|||
EVENT_CONTAINER *EVT_PTR = NULL; |
|||
while( m_bThreadStatus < TH_ENDED ) { |
|||
while (!m_bDataIsActive && m_bThreadStatus < TH_ENDED ) SLEEP( 20 ); |
|||
if( m_mBufferProtectorMutex.try_lock() ){ |
|||
if( m_bDataIsActive ){ |
|||
EVT_PTR =(EVENT_CONTAINER *) malloc(sizeof(EVENT_CONTAINER)); |
|||
if( EVT_PTR ) { |
|||
memset( EVT_PTR, 0, sizeof(EVENT_CONTAINER)); |
|||
EVT_PTR->m_eClass = EVT_CLASS_IMAGE; |
|||
EVT_PTR->m_eType = EVT_READY; |
|||
if( IM_RESULT *tData = m_fImageAnalyzer( m_oWorkingMat ) ){ |
|||
//generate detection event
|
|||
EVT_PTR->m_pEvtData = tData; |
|||
} else { |
|||
//generate NOT detection event
|
|||
EVT_PTR->m_pEvtData = NULL; |
|||
}; |
|||
}; |
|||
m_pActiveJob = NULL; |
|||
m_bDataIsActive = false; |
|||
}; |
|||
m_mBufferProtectorMutex.unlock(); |
|||
}; |
|||
if( EVT_PTR != NULL ) { |
|||
m_pEvtHeap->broadcast( EVT_PTR ); |
|||
EVT_PTR = NULL; |
|||
}; |
|||
}; |
|||
}; |
|||
|
|||
bool IM_DnnWorker::enqueueJob( IM_JOB *ptr ){ |
|||
if( ptr ) { |
|||
char tPath[1024]; |
|||
char p1[3]; |
|||
char p2[3]; |
|||
char p3[3]; |
|||
LOG( ptr->md5 ); |
|||
memcpy( p1, ptr->md5 , 2); p1[2]=(char)0; |
|||
memcpy( p2, ptr->md5+2, 2); p2[2]=(char)0; |
|||
memcpy( p3, ptr->md5+4, 2); p3[2]=(char)0; |
|||
switch( ptr->image_type ) { |
|||
case IM_ITEM_TYPE_JPEG: sprintf( tPath, "%s/%s/%s/%s/%s.jpg", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break; |
|||
case IM_ITEM_TYPE_PNG: sprintf( tPath, "%s/%s/%s/%s/%s.png", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break; |
|||
case IM_ITEM_TYPE_GIF: sprintf( tPath, "%s/%s/%s/%s/%s.gif", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break; |
|||
case IM_ITEM_TYPE_AGIF: sprintf( tPath, "%s/%s/%s/%s/%s.gif", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break; |
|||
case IM_ITEM_TYPE_TIFF: sprintf( tPath, "%s/%s/%s/%s/%s.tiff", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break; |
|||
}; |
|||
#ifdef DEBUG
|
|||
LOG( tPath ); |
|||
#endif
|
|||
Mat Frame = cv::imread( tPath, IMREAD_COLOR ); |
|||
if( !Frame.empty() ){ |
|||
while( m_bThreadStatus < TH_ENDED ) { |
|||
if( m_mBufferProtectorMutex.try_lock() ) { |
|||
Frame.copyTo( m_oWorkingMat ); |
|||
#ifdef DEBUG
|
|||
cv::imwrite("cur-test-img.jpg", m_oWorkingMat ); |
|||
#endif
|
|||
m_bDataIsActive = true; |
|||
m_pActiveJob = ptr; |
|||
m_mBufferProtectorMutex.unlock(); |
|||
return true; |
|||
} else SLEEP(5); |
|||
}; |
|||
} else { |
|||
LOG_ERROR( "Failure during Image Read!" ); |
|||
}; |
|||
}; |
|||
return false; |
|||
}; |
|||
|
|||
#undef LOG
|
|||
#undef LOG_ERROR
|
|||
|
|||
@ -0,0 +1,66 @@ |
|||
#ifndef __IM_DNNWORKER_H_INCL__ |
|||
#define __IM_DNNWORKER_H_INCL__ |
|||
|
|||
#include "../../lib/components/base/basicThread.h" |
|||
#include "../../lib/components/base/basicMutex.h" |
|||
#include "../../lib/components/base/basicSettingsProvider.h" |
|||
#include "../../lib/components/base/basicEventHeap.h" |
|||
#include "IM_DataStructs.h" |
|||
|
|||
#define DARKNET |
|||
|
|||
#ifdef DARKNET |
|||
#define GPU |
|||
//#include <darknet/darknet.h> |
|||
#include <darknet/yolo_v2_class.hpp> |
|||
#undef GPU |
|||
#endif |
|||
|
|||
#include <opencv2/opencv.hpp> |
|||
#include <opencv2/core.hpp> |
|||
#include <opencv2/imgcodecs.hpp> |
|||
#include <opencv2/highgui.hpp> |
|||
#include <opencv2/dnn/dnn.hpp> |
|||
|
|||
using namespace cv; |
|||
/** |
|||
* TODO: Add class description |
|||
* |
|||
* @author Gagua |
|||
*/ |
|||
class IM_DnnWorker : public basicThread { |
|||
private: |
|||
#ifdef DARKNET |
|||
Detector * m_pDarknetDetector; |
|||
#else |
|||
#endif |
|||
basicLogCollection * m_pLog; |
|||
config_setting_t * m_pSettings; |
|||
cv::dnn::Backend m_eBackendEngine; |
|||
cv::dnn::Target m_eTargetDevice; |
|||
cv::dnn::Net m_net; |
|||
cv::Mat m_oWorkingMat; |
|||
float m_fDetectionProbability; |
|||
bool m_bUseClassMapping; |
|||
std::vector<uint32_t> m_vClassesMap; |
|||
basicEventHeap * m_pEvtHeap; |
|||
char m_pPicturesBase[1024]; |
|||
char m_pConfigPath[1024]; |
|||
char m_pWeightsPath[1024]; |
|||
basicMutex m_mBufferProtectorMutex; |
|||
IM_JOB * m_pActiveJob; |
|||
bool m_bDataIsActive; |
|||
IM_RESULT * m_fImageAnalyzer( Mat &Picture ); |
|||
protected: |
|||
virtual void m_fThreadProc( void );//getLayerNames() |
|||
public: |
|||
// Constructor |
|||
explicit IM_DnnWorker( config_setting_t * Settings = NULL ); |
|||
// Destructor |
|||
virtual ~IM_DnnWorker(); |
|||
bool create( void ); |
|||
bool enqueueJob( IM_JOB *ptr ); |
|||
}; |
|||
|
|||
|
|||
#endif // __IM_DNNWORKER_H_INCL__ |
|||
@ -0,0 +1,148 @@ |
|||
#include "IM_Kernel.h"
|
|||
#include "IM_ClientHandler.h"
|
|||
|
|||
#define LOG( X ) m_pLog->Log( "KRNL", this, X )
|
|||
#ifdef DEBUG
|
|||
#define LOG_ERROR( X ) {\
|
|||
char _tBfrErrMSG234[256];\ |
|||
sprintf( _tBfrErrMSG234, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\ |
|||
m_pLog->Log( "KRNL", this, _LOG_ERROR, _tBfrErrMSG234 );\ |
|||
} |
|||
#else
|
|||
#define LOG_ERROR( X ) m_pLog->Log( "KRNL", this, _LOG_ERROR, X );
|
|||
#endif
|
|||
|
|||
IM_Kernel *IM_Kernel::_instance = NULL; |
|||
|
|||
IM_Kernel *IM_Kernel::getInstance(){ |
|||
if( _instance == NULL ) { |
|||
_instance = new IM_Kernel; |
|||
}; |
|||
return _instance; |
|||
}; |
|||
|
|||
// Constructor implementation
|
|||
inline IM_Kernel::IM_Kernel( config_setting_t *Settings ) : networkServiceEngine(), basicThread(){ |
|||
m_pLog = basicLogCollection::getInstance(); |
|||
m_pSettings = basicSettingsProvider::getInstance()->getSubNode( Settings, "KERNEL" ); |
|||
m_pEvtHeap = basicEventHeap::getInstance(); |
|||
m_bExitCause = 0; |
|||
m_pWorker = NULL; |
|||
m_pRecognizer = NULL; |
|||
m_pDBA = NULL; |
|||
m_pActiveJob = NULL; |
|||
}; |
|||
|
|||
// Destructor implementation
|
|||
inline IM_Kernel::~IM_Kernel(){ |
|||
waitThreadEnd( true ); |
|||
if( m_pWorker ) delete( m_pWorker ); |
|||
if( m_pRecognizer ) delete( m_pRecognizer ); |
|||
if( m_pDBA ) delete( m_pDBA ); |
|||
_instance = NULL; |
|||
}; |
|||
|
|||
bool IM_Kernel::start(){ |
|||
m_pDBA = IM_DataBaseAdapter::getInstance( m_pSettings ); |
|||
if( m_pDBA ==NULL ) { |
|||
LOG_ERROR("Error Creating DataBase Adapter!"); |
|||
return false; |
|||
}; |
|||
m_pWorker = new IM_DnnWorker( m_pSettings ); |
|||
if( m_pWorker ) { |
|||
if( !m_pWorker->create() ){ |
|||
LOG_ERROR( "DNN Worker INIT Failure!" ); |
|||
return false; |
|||
}; |
|||
} else LOG_ERROR( "DNN Worker Create Failure!" ); |
|||
|
|||
m_pRecognizer = new IM_DlibWorker( m_pSettings ); |
|||
if( m_pRecognizer ) { |
|||
if( !m_pRecognizer->create() ){ |
|||
LOG_ERROR( "DLib Worker INIT Failure!" ); |
|||
return false; |
|||
}; |
|||
} else LOG_ERROR( "DLib Worker Create Failure!" ); |
|||
return init(); |
|||
}; |
|||
|
|||
bool IM_Kernel::stop( bool Force ){ |
|||
waitThreadEnd( Force ); |
|||
return true; |
|||
}; |
|||
|
|||
networkClientHandler *IM_Kernel::attachNewClient( int SocketID ){ |
|||
IM_ClientHandler *tVal; |
|||
tVal = new IM_ClientHandler( SocketID, this ); |
|||
return (networkClientHandler *) tVal; |
|||
}; |
|||
|
|||
bool IM_Kernel::detachClient( networkClientHandler *ptr ){ |
|||
delete( (IM_ClientHandler *) ptr ); |
|||
return true; |
|||
}; |
|||
|
|||
|
|||
void IM_Kernel::m_fThreadProc( void ){ |
|||
m_bThreadStatus = TH_WORKING; |
|||
while( m_bThreadStatus < TH_ENDED ) { |
|||
if( m_qJOBS.size() ) { |
|||
if( m_pWorker ){ |
|||
m_pActiveJob = m_qJOBS.front(); |
|||
m_qJOBS.pop(); |
|||
switch( m_pActiveJob->job_type ) { |
|||
case IM_PROC_TYPE_FACE: |
|||
if( !m_pRecognizer->enqueueJob( m_pActiveJob ) ) { |
|||
#ifdef DEBUG
|
|||
LOG("Not Inserted Job Must generate EVT"); |
|||
#endif
|
|||
EVENT_CONTAINER *tEVT; |
|||
tEVT = (EVENT_CONTAINER *)malloc(sizeof(EVENT_CONTAINER)); |
|||
if( tEVT ) { |
|||
memset(tEVT,0,sizeof(EVENT_CONTAINER)); |
|||
tEVT->m_eClass = EVT_CLASS_IMAGE; |
|||
tEVT->m_eType = EVT_READY; |
|||
m_pEvtHeap->broadcast( tEVT ); |
|||
} else { |
|||
LOG_ERROR( "Failure to Emmit EVENT!"); |
|||
}; |
|||
}; |
|||
break; |
|||
default: |
|||
if( !m_pWorker->enqueueJob( m_pActiveJob ) ) { |
|||
#ifdef DEBUG
|
|||
LOG("Not Inserted Job Must generate EVT"); |
|||
#endif
|
|||
EVENT_CONTAINER *tEVT; |
|||
tEVT = (EVENT_CONTAINER *)malloc(sizeof(EVENT_CONTAINER)); |
|||
if( tEVT ) { |
|||
memset(tEVT,0,sizeof(EVENT_CONTAINER)); |
|||
tEVT->m_eClass = EVT_CLASS_IMAGE; |
|||
tEVT->m_eType = EVT_READY; |
|||
m_pEvtHeap->broadcast( tEVT ); |
|||
} else { |
|||
LOG_ERROR( "Failure to Emmit EVENT!"); |
|||
}; |
|||
}; |
|||
}; |
|||
} else LOG_ERROR( "DNN Worker Not Created!" ); |
|||
}; |
|||
SLEEP( DEFAULT_THREAD_SLEEP_TIME ); |
|||
}; |
|||
}; |
|||
|
|||
bool IM_Kernel::enqueueJob( IM_JOB *ptr ){ |
|||
if( m_pWorker ) { |
|||
if( ptr!= NULL ) { |
|||
#ifdef DEBUG
|
|||
LOG( "New Job Enqueued" ); |
|||
#endif
|
|||
m_qJOBS.push( ptr ); |
|||
}; |
|||
} else LOG_ERROR( "DNN Worker Not Created!" ); |
|||
return false; |
|||
}; |
|||
|
|||
#undef LOG
|
|||
#undef LOG_ERROR
|
|||
|
|||
@ -0,0 +1,52 @@ |
|||
#ifndef __IM_KERNEL_H_INCL__ |
|||
#define __IM_KERNEL_H_INCL__ |
|||
|
|||
#include "../../lib/data/net/netServiceEngine.h" |
|||
#include "../../lib/components/base/basicThread.h" |
|||
#include "../../lib/components/base/basicSettingsProvider.h" |
|||
#include "IM_DataStructs.h" |
|||
#include "IM_DnnWorker.h" |
|||
#include "IM_DLibWorker.h" |
|||
#include "IM_DataBaseAdapter.h" |
|||
|
|||
class networkClientHandler; |
|||
|
|||
/** |
|||
* TODO: Add class description |
|||
* |
|||
* @author Gagua |
|||
*/ |
|||
class IM_Kernel : public networkServiceEngine, public basicThread { |
|||
private: |
|||
basicLogCollection * m_pLog; |
|||
config_setting_t * m_pSettings; |
|||
basicEventHeap * m_pEvtHeap; |
|||
IM_DataBaseAdapter * m_pDBA; |
|||
uint8_t m_bExitCause; |
|||
IM_DnnWorker * m_pWorker; |
|||
IM_DlibWorker * m_pRecognizer; |
|||
IM_JOB_QUEUE m_qJOBS; |
|||
IM_JOB * m_pActiveJob; |
|||
protected: |
|||
virtual void m_fThreadProc( void ); |
|||
public: |
|||
|
|||
static IM_Kernel * getInstance(); |
|||
// Destructor |
|||
virtual ~IM_Kernel(); |
|||
bool signalEvent( void ); |
|||
virtual bool start(); |
|||
virtual bool stop( bool Force = false ); |
|||
uint8_t getExitCause( void ){ return m_bExitCause;}; |
|||
virtual networkClientHandler * attachNewClient( int SocketID ); |
|||
virtual bool detachClient( networkClientHandler *ptr ); |
|||
bool enqueueJob( IM_JOB *ptr ); |
|||
//IM_RESULT * getResult( IM_JOB *ptr ); |
|||
private: |
|||
static IM_Kernel * _instance; |
|||
// Constructor |
|||
explicit IM_Kernel( config_setting_t * Settings = NULL ); |
|||
}; |
|||
|
|||
|
|||
#endif // __IM_KERNEL_H_INCL__ |
|||
@ -0,0 +1,9 @@ |
|||
#! /bin/sh |
|||
|
|||
|
|||
#make clean -e "CFG=Debug" |
|||
make -j$(nproc) -e "CFG=Debug" |
|||
|
|||
|
|||
#make clean -e "CFG=Release" |
|||
#make -j$(nproc) -e "CFG=Release" |
|||
@ -0,0 +1,332 @@ |
|||
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd"> |
|||
<Project |
|||
Version="10.0" |
|||
VendorName="SlickEdit" |
|||
TemplateName="GNU C/C++" |
|||
WorkingDir="." |
|||
BuildSystem="automakefile" |
|||
BuildMakeFile="makefile"> |
|||
<Config |
|||
Name="Debug" |
|||
Type="gnuc" |
|||
DebugCallbackName="gdb" |
|||
Version="1" |
|||
OutputFile="%bdimg_mill" |
|||
CompilerConfigName="Latest Version" |
|||
Defines='"/D_OPENCV_" "/DDEBUG" "/DOPENCV"'> |
|||
<Menu> |
|||
<Target |
|||
Name="Compile" |
|||
MenuCaption="&Compile" |
|||
Dialog="_gnuc_options_form Compile" |
|||
CaptureOutputWith="ProcessBuffer" |
|||
Deletable="0" |
|||
OutputExts="*.o" |
|||
SaveOption="SaveCurrent" |
|||
RunFromDir="%rw"> |
|||
<Exec |
|||
CmdLine='g++ -c %xup -x c++ %defd -g -ggdb %~other -o "%bd%n%oe" %i %f' |
|||
OtherOptions="-Wno-write-strings -I../../lib/include `pkg-config opencv4 libavcodec libavdevice libavfilter libavformat libavutil libpostproc libswresample libswscale live555 --cflags`"/> |
|||
</Target> |
|||
<Target |
|||
Name="Link" |
|||
MenuCaption="&Link" |
|||
ShowOnMenu="Never" |
|||
Dialog="_gnuc_options_form Link" |
|||
CaptureOutputWith="ProcessBuffer" |
|||
Deletable="0" |
|||
SaveOption="SaveCurrent" |
|||
RunFromDir="%rw"> |
|||
<Exec CmdLine='g++ %xup -g -ggdb -o "%o" %objs'/> |
|||
</Target> |
|||
<Target |
|||
Name="Build" |
|||
MenuCaption="&Build" |
|||
CaptureOutputWith="ProcessBuffer" |
|||
Deletable="0" |
|||
SaveOption="SaveWorkspaceFiles" |
|||
RunFromDir="%rw"> |
|||
<Exec CmdLine='make -f "makefile" CFG=%b'/> |
|||
</Target> |
|||
<Target |
|||
Name="Rebuild" |
|||
MenuCaption="&Rebuild" |
|||
CaptureOutputWith="ProcessBuffer" |
|||
Deletable="0" |
|||
SaveOption="SaveWorkspaceFiles" |
|||
RunFromDir="%rw"> |
|||
<Exec CmdLine='make -f "makefile" rebuild CFG=%b'/> |
|||
</Target> |
|||
<Target |
|||
Name="Debug" |
|||
MenuCaption="&Debug" |
|||
Dialog="_gnuc_options_form Run/Debug" |
|||
BuildFirst="1" |
|||
CaptureOutputWith="ProcessBuffer" |
|||
Deletable="0" |
|||
SaveOption="SaveNone" |
|||
RunFromDir="%rw"> |
|||
<Exec CmdLine='vsdebugio -prog "%o"'/> |
|||
</Target> |
|||
<Target |
|||
Name="Execute" |
|||
MenuCaption="E&xecute" |
|||
Dialog="_gnuc_options_form Run/Debug" |
|||
BuildFirst="1" |
|||
CaptureOutputWith="ProcessBuffer" |
|||
Deletable="0" |
|||
SaveOption="SaveWorkspaceFiles" |
|||
RunFromDir="%rw"> |
|||
<Exec CmdLine='"%o"'/> |
|||
</Target> |
|||
<Target |
|||
Name="dash" |
|||
MenuCaption="-" |
|||
Deletable="0"> |
|||
<Exec/> |
|||
</Target> |
|||
<Target |
|||
Name="GNU C Options" |
|||
MenuCaption="GNU C &Options..." |
|||
ShowOnMenu="HideIfNoCmdLine" |
|||
Deletable="0" |
|||
SaveOption="SaveNone"> |
|||
<Exec |
|||
CmdLine="gnucoptions" |
|||
Type="Slick-C"/> |
|||
</Target> |
|||
</Menu> |
|||
<List Name="GNUC Options"> |
|||
<Item |
|||
Name="LinkerOutputType" |
|||
Value="Executable"/> |
|||
</List> |
|||
<Includes> |
|||
<Include Dir="/usr/local/include/opencv4"/> |
|||
<Include Dir="../../lib/include"/> |
|||
</Includes> |
|||
<Libs PreObjects="0"> |
|||
<Lib File="-lmysqlclient"/> |
|||
<Lib File="-lssl"/> |
|||
<Lib File="-lcrypto"/> |
|||
<Lib File="-lpthread"/> |
|||
<Lib File="`pkg-config"/> |
|||
<Lib File="--libs"/> |
|||
<Lib File="libcurl"/> |
|||
<Lib File="opencv4"/> |
|||
<Lib File="dlib-1`"/> |
|||
<Lib File="-lconfig"/> |
|||
<Lib File="-ljpeg"/> |
|||
<Lib File="-lc"/> |
|||
<Lib File="-lm"/> |
|||
<Lib File="-lz"/> |
|||
<Lib File="-ldarknet"/> |
|||
</Libs> |
|||
</Config> |
|||
<Config |
|||
Name="Release" |
|||
Type="gnuc" |
|||
DebugCallbackName="gdb" |
|||
Version="1" |
|||
OutputFile="%bdimg_mill" |
|||
CompilerConfigName="Latest Version" |
|||
Defines='"/D_OPENCV_"'> |
|||
<Menu> |
|||
<Target |
|||
Name="Compile" |
|||
MenuCaption="&Compile" |
|||
Dialog="_gnuc_options_form Compile" |
|||
CaptureOutputWith="ProcessBuffer" |
|||
Deletable="0" |
|||
OutputExts="*.o" |
|||
SaveOption="SaveCurrent" |
|||
RunFromDir="%rw"> |
|||
<Exec |
|||
CmdLine='g++ -c %xup -x c++ %defd -O3 %~other -o "%bd%n%oe" %i %f' |
|||
OtherOptions="`pkg-config --cflags opencv4` -s"/> |
|||
</Target> |
|||
<Target |
|||
Name="Link" |
|||
MenuCaption="&Link" |
|||
ShowOnMenu="Never" |
|||
Dialog="_gnuc_options_form Link" |
|||
CaptureOutputWith="ProcessBuffer" |
|||
Deletable="0" |
|||
SaveOption="SaveCurrent" |
|||
RunFromDir="%rw"> |
|||
<Exec |
|||
CmdLine='g++ %xup -O3 %~other -o "%o" %objs' |
|||
OtherOptions=" -s"/> |
|||
</Target> |
|||
<Target |
|||
Name="Build" |
|||
MenuCaption="&Build" |
|||
CaptureOutputWith="ProcessBuffer" |
|||
Deletable="0" |
|||
SaveOption="SaveWorkspaceFiles" |
|||
RunFromDir="%rw"> |
|||
<Exec CmdLine='make -f "makefile" CFG=%b'/> |
|||
</Target> |
|||
<Target |
|||
Name="Rebuild" |
|||
MenuCaption="&Rebuild" |
|||
CaptureOutputWith="ProcessBuffer" |
|||
Deletable="0" |
|||
SaveOption="SaveWorkspaceFiles" |
|||
RunFromDir="%rw"> |
|||
<Exec CmdLine='make -f "makefile" rebuild CFG=%b'/> |
|||
</Target> |
|||
<Target |
|||
Name="Debug" |
|||
MenuCaption="&Debug" |
|||
Dialog="_gnuc_options_form Run/Debug" |
|||
BuildFirst="1" |
|||
CaptureOutputWith="ProcessBuffer" |
|||
Deletable="0" |
|||
SaveOption="SaveNone" |
|||
RunFromDir="%rw"> |
|||
<Exec CmdLine='vsdebugio -prog "%o"'/> |
|||
</Target> |
|||
<Target |
|||
Name="Execute" |
|||
MenuCaption="E&xecute" |
|||
Dialog="_gnuc_options_form Run/Debug" |
|||
BuildFirst="1" |
|||
CaptureOutputWith="ProcessBuffer" |
|||
Deletable="0" |
|||
SaveOption="SaveWorkspaceFiles" |
|||
RunFromDir="%rw"> |
|||
<Exec CmdLine='"%o"'/> |
|||
</Target> |
|||
<Target |
|||
Name="dash" |
|||
MenuCaption="-" |
|||
Deletable="0"> |
|||
<Exec/> |
|||
</Target> |
|||
<Target |
|||
Name="GNU C Options" |
|||
MenuCaption="GNU C &Options..." |
|||
ShowOnMenu="HideIfNoCmdLine" |
|||
Deletable="0" |
|||
SaveOption="SaveNone"> |
|||
<Exec |
|||
CmdLine="gnucoptions" |
|||
Type="Slick-C"/> |
|||
</Target> |
|||
</Menu> |
|||
<List Name="GNUC Options"> |
|||
<Item |
|||
Name="LinkerOutputType" |
|||
Value="Executable"/> |
|||
</List> |
|||
<Includes> |
|||
<Include Dir="/usr/local/include/opencv4"/> |
|||
<Include Dir="../../lib/include"/> |
|||
</Includes> |
|||
<Libs PreObjects="0"> |
|||
<Lib File="-lmysqlclient"/> |
|||
<Lib File="-lssl"/> |
|||
<Lib File="-lcrypto"/> |
|||
<Lib File="-lpthread"/> |
|||
<Lib File="`pkg-config"/> |
|||
<Lib File="--libs"/> |
|||
<Lib File="libavcodec"/> |
|||
<Lib File="libavdevice"/> |
|||
<Lib File="libavfilter"/> |
|||
<Lib File="libavformat"/> |
|||
<Lib File="libavresample"/> |
|||
<Lib File="libavutil"/> |
|||
<Lib File="libswresample"/> |
|||
<Lib File="libswscale"/> |
|||
<Lib File="libconfig++"/> |
|||
<Lib File="libcurl"/> |
|||
<Lib File="opencv4`"/> |
|||
<Lib File="-lGL"/> |
|||
<Lib File="-lGLU"/> |
|||
<Lib File="-lc"/> |
|||
<Lib File="-lm"/> |
|||
<Lib File="-lz"/> |
|||
</Libs> |
|||
</Config> |
|||
<Files> |
|||
<Folder |
|||
Name="Source Files" |
|||
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d" |
|||
GUID="{59361C56-E6B5-4F58-A49A-F30F098578C0}"> |
|||
<F N="../../lib/components/base/basicDualThread.cpp"/> |
|||
<F N="../../lib/components/base/basicEngine.cpp"/> |
|||
<F N="../../lib/components/base/basicEvent.cpp"/> |
|||
<F N="../../lib/components/base/basicEventHandler.cpp"/> |
|||
<F N="../../lib/components/base/basicEventHeap.cpp"/> |
|||
<F N="../../lib/components/base/basicFunctionality.cpp"/> |
|||
<F N="../../lib/components/base/basicLogCollection.cpp"/> |
|||
<F N="../../lib/components/base/basicLoggingService.cpp"/> |
|||
<F N="../../lib/components/base/basicMediaDestination.cpp"/> |
|||
<F N="../../lib/components/base/basicMediaSource.cpp"/> |
|||
<F N="../../lib/components/base/basicMediaViewer.cpp"/> |
|||
<F N="../../lib/components/base/basicMutex.cpp"/> |
|||
<F N="../../lib/components/base/basicObject.cpp"/> |
|||
<F N="../../lib/components/base/basicRing.cpp"/> |
|||
<F N="../../lib/components/base/basicSettings.cpp"/> |
|||
<F N="../../lib/components/base/basicSettingsProvider.cpp"/> |
|||
<F N="../../lib/components/base/basicThread.cpp"/> |
|||
<F N="../../lib/components/base/basicTransport.cpp"/> |
|||
<F N="IM_Backend.cpp"/> |
|||
<F N="IM_ClientHandler.cpp"/> |
|||
<F N="IM_ClientProtocol.cpp"/> |
|||
<F N="IM_DataBaseAdapter.cpp"/> |
|||
<F N="IM_DataStructs.cpp"/> |
|||
<F N="IM_DLibWorker.cpp"/> |
|||
<F N="IM_DnnWorker.cpp"/> |
|||
<F N="IM_Kernel.cpp"/> |
|||
<F N="../../lib/data/json/json_reader.cpp"/> |
|||
<F N="../../lib/data/json/json_value.cpp"/> |
|||
<F N="../../lib/data/json/json_writer.cpp"/> |
|||
<F N="../../lib/alg/generic/md5.cpp"/> |
|||
<F N="../../lib/data/mysql/mysql_class.cpp"/> |
|||
<F N="../../lib/data/net/netClientHandler.cpp"/> |
|||
<F N="../../lib/data/net/netServer.cpp"/> |
|||
<F N="../../lib/components/object/objectConsoleLoggingService.cpp"/> |
|||
<F N="../../lib/components/object/objectFileLoggingService.cpp"/> |
|||
<F N="../../lib/data/protocol/protocol.cpp"/> |
|||
<F N="../../lib/data/net/serverPort.cpp"/> |
|||
<F N="../../lib/data/transport/transportSocket.cpp"/> |
|||
<F N="../../lib/data/protocol/xmlParser.cpp"/> |
|||
</Folder> |
|||
<Folder |
|||
Name="Header Files" |
|||
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if" |
|||
GUID="{02B83E64-7572-484A-94DB-15BE03E07219}"> |
|||
<F N="../../lib/components/base/basicVideoAnalyzer.h"/> |
|||
<F N="IM_Backend.h"/> |
|||
<F N="IM_ClientHandler.h"/> |
|||
<F N="IM_ClientProtocol.h"/> |
|||
<F N="IM_DataBaseAdapter.h"/> |
|||
<F N="IM_DataStructs.h"/> |
|||
<F N="IM_DLibWorker.h"/> |
|||
<F N="IM_DnnWorker.h"/> |
|||
<F N="IM_Kernel.h"/> |
|||
<F N="../../lib/data/net/netClientHandler.h"/> |
|||
<F N="../../lib/data/protocol/protocol.h"/> |
|||
</Folder> |
|||
<Folder |
|||
Name="Resource Files" |
|||
Filters="*.ico;*.cur;*.dlg" |
|||
GUID="{578FBDC0-5593-4211-9EF6-1FE6AEBFC294}"/> |
|||
<Folder |
|||
Name="Bitmaps" |
|||
Filters="*.bmp" |
|||
GUID="{690262FF-E770-4301-8087-ACB2B3180E30}"/> |
|||
<Folder |
|||
Name="Other Files" |
|||
Filters="" |
|||
GUID="{E620F360-BEEE-47C5-8344-97ACA4579F99}"> |
|||
<F |
|||
N="makefile" |
|||
Type="Makefile"/> |
|||
</Folder> |
|||
</Files> |
|||
<List Name="RTE"> |
|||
</List> |
|||
</Project> |
|||
@ -0,0 +1,275 @@ |
|||
# SlickEdit generated file. Do not edit this file except in designated areas.
|
|||
|
|||
# Make command to use for dependencies
|
|||
MAKE=make |
|||
RM=rm |
|||
MKDIR=mkdir |
|||
|
|||
# -----Begin user-editable area-----
|
|||
|
|||
# -----End user-editable area-----
|
|||
|
|||
# If no configuration is specified, "Debug" will be used
|
|||
ifndef CFG |
|||
CFG=Debug |
|||
endif |
|||
|
|||
#
|
|||
# Configuration: Debug
|
|||
#
|
|||
ifeq "$(CFG)" "Debug" |
|||
OUTDIR=Debug |
|||
OUTFILE=$(OUTDIR)/img_mill |
|||
CFG_INC=-I/usr/local/include/opencv4 -I../../lib/include |
|||
CFG_LIB=-lmysqlclient -lssl -lcrypto -lpthread `pkg-config --libs \
|
|||
libcurl opencv4 dlib-1` -lconfig -ljpeg -lc -lm -lz -ldarknet |
|||
CFG_OBJ= |
|||
COMMON_OBJ=$(OUTDIR)/basicDualThread.o $(OUTDIR)/basicEngine.o \
|
|||
$(OUTDIR)/basicEvent.o $(OUTDIR)/basicEventHandler.o \
|
|||
$(OUTDIR)/basicEventHeap.o $(OUTDIR)/basicFunctionality.o \
|
|||
$(OUTDIR)/basicLogCollection.o $(OUTDIR)/basicLoggingService.o \
|
|||
$(OUTDIR)/basicMediaDestination.o $(OUTDIR)/basicMediaSource.o \
|
|||
$(OUTDIR)/basicMediaViewer.o $(OUTDIR)/basicMutex.o \
|
|||
$(OUTDIR)/basicObject.o $(OUTDIR)/basicRing.o \
|
|||
$(OUTDIR)/basicSettings.o $(OUTDIR)/basicSettingsProvider.o \
|
|||
$(OUTDIR)/basicThread.o $(OUTDIR)/basicTransport.o \
|
|||
$(OUTDIR)/IM_Backend.o $(OUTDIR)/IM_ClientHandler.o \
|
|||
$(OUTDIR)/IM_ClientProtocol.o $(OUTDIR)/IM_DataBaseAdapter.o \
|
|||
$(OUTDIR)/IM_DataStructs.o $(OUTDIR)/IM_DLibWorker.o \
|
|||
$(OUTDIR)/IM_DnnWorker.o $(OUTDIR)/IM_Kernel.o \
|
|||
$(OUTDIR)/json_reader.o $(OUTDIR)/json_value.o \
|
|||
$(OUTDIR)/json_writer.o $(OUTDIR)/md5.o $(OUTDIR)/mysql_class.o \
|
|||
$(OUTDIR)/netClientHandler.o $(OUTDIR)/netServer.o \
|
|||
$(OUTDIR)/objectConsoleLoggingService.o \
|
|||
$(OUTDIR)/objectFileLoggingService.o $(OUTDIR)/protocol.o \
|
|||
$(OUTDIR)/serverPort.o $(OUTDIR)/transportSocket.o \
|
|||
$(OUTDIR)/xmlParser.o |
|||
OBJ=$(COMMON_OBJ) $(CFG_OBJ) |
|||
ALL_OBJ=$(OUTDIR)/basicDualThread.o $(OUTDIR)/basicEngine.o \
|
|||
$(OUTDIR)/basicEvent.o $(OUTDIR)/basicEventHandler.o \
|
|||
$(OUTDIR)/basicEventHeap.o $(OUTDIR)/basicFunctionality.o \
|
|||
$(OUTDIR)/basicLogCollection.o $(OUTDIR)/basicLoggingService.o \
|
|||
$(OUTDIR)/basicMediaDestination.o $(OUTDIR)/basicMediaSource.o \
|
|||
$(OUTDIR)/basicMediaViewer.o $(OUTDIR)/basicMutex.o \
|
|||
$(OUTDIR)/basicObject.o $(OUTDIR)/basicRing.o \
|
|||
$(OUTDIR)/basicSettings.o $(OUTDIR)/basicSettingsProvider.o \
|
|||
$(OUTDIR)/basicThread.o $(OUTDIR)/basicTransport.o \
|
|||
$(OUTDIR)/IM_Backend.o $(OUTDIR)/IM_ClientHandler.o \
|
|||
$(OUTDIR)/IM_ClientProtocol.o $(OUTDIR)/IM_DataBaseAdapter.o \
|
|||
$(OUTDIR)/IM_DataStructs.o $(OUTDIR)/IM_DLibWorker.o \
|
|||
$(OUTDIR)/IM_DnnWorker.o $(OUTDIR)/IM_Kernel.o \
|
|||
$(OUTDIR)/json_reader.o $(OUTDIR)/json_value.o \
|
|||
$(OUTDIR)/json_writer.o $(OUTDIR)/md5.o $(OUTDIR)/mysql_class.o \
|
|||
$(OUTDIR)/netClientHandler.o $(OUTDIR)/netServer.o \
|
|||
$(OUTDIR)/objectConsoleLoggingService.o \
|
|||
$(OUTDIR)/objectFileLoggingService.o $(OUTDIR)/protocol.o \
|
|||
$(OUTDIR)/serverPort.o $(OUTDIR)/transportSocket.o \
|
|||
$(OUTDIR)/xmlParser.o -lmysqlclient -lssl -lcrypto -lpthread \
|
|||
`pkg-config --libs libcurl opencv4 dlib-1` -lconfig -ljpeg -lc -lm \
|
|||
-lz -ldarknet |
|||
|
|||
COMPILE=g++ -c -x c++ "-D_OPENCV_" "-DDEBUG" "-DOPENCV" -g -ggdb -Wno-write-strings -I../../lib/include `pkg-config opencv4 libavcodec libavdevice libavfilter libavformat libavutil libpostproc libswresample libswscale live555 --cflags` -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $< |
|||
LINK=g++ -g -ggdb -o "$(OUTFILE)" $(ALL_OBJ) |
|||
|
|||
# Pattern rules
|
|||
$(OUTDIR)/%.o : ../../lib/components/object/%.cpp |
|||
$(COMPILE) |
|||
|
|||
$(OUTDIR)/%.o : ../../lib/data/json/%.cpp |
|||
$(COMPILE) |
|||
|
|||
$(OUTDIR)/%.o : ../../lib/data/transport/%.cpp |
|||
$(COMPILE) |
|||
|
|||
$(OUTDIR)/%.o : ../../lib/data/protocol/%.cpp |
|||
$(COMPILE) |
|||
|
|||
$(OUTDIR)/%.o : ../../lib/data/net/%.cpp |
|||
$(COMPILE) |
|||
|
|||
$(OUTDIR)/%.o : ../../lib/data/mysql/%.cpp |
|||
$(COMPILE) |
|||
|
|||
$(OUTDIR)/%.o : ../../lib/components/base/%.cpp |
|||
$(COMPILE) |
|||
|
|||
$(OUTDIR)/%.o : ../../lib/alg/generic/%.cpp |
|||
$(COMPILE) |
|||
|
|||
$(OUTDIR)/%.o : %.cpp |
|||
$(COMPILE) |
|||
|
|||
# Build rules
|
|||
all: $(OUTFILE) |
|||
|
|||
$(OUTFILE): $(OUTDIR) $(OBJ) |
|||
$(LINK) |
|||
|
|||
$(OUTDIR): |
|||
$(MKDIR) -p "$(OUTDIR)" |
|||
|
|||
# Rebuild this project
|
|||
rebuild: cleanall |
|||
@$(MAKE) -f "$(strip $(MAKEFILE_LIST))" $(MAKEFLAGS) all |
|||
|
|||
# Clean this project
|
|||
clean: |
|||
$(RM) -f $(OUTFILE) |
|||
$(RM) -f $(OBJ) |
|||
|
|||
# Clean this project and all dependencies
|
|||
cleanall: clean |
|||
endif |
|||
|
|||
#
|
|||
# Configuration: Release
|
|||
#
|
|||
ifeq "$(CFG)" "Release" |
|||
OUTDIR=Release |
|||
OUTFILE=$(OUTDIR)/img_mill |
|||
CFG_INC=-I/usr/local/include/opencv4 -I../../lib/include |
|||
CFG_LIB=-lmysqlclient -lssl -lcrypto -lpthread `pkg-config --libs \
|
|||
libavcodec libavdevice libavfilter libavformat libavresample \
|
|||
libavutil libswresample libswscale libconfig++ libcurl opencv4` -lGL \
|
|||
-lGLU -lc -lm -lz |
|||
CFG_OBJ= |
|||
COMMON_OBJ=$(OUTDIR)/basicDualThread.o $(OUTDIR)/basicEngine.o \
|
|||
$(OUTDIR)/basicEvent.o $(OUTDIR)/basicEventHandler.o \
|
|||
$(OUTDIR)/basicEventHeap.o $(OUTDIR)/basicFunctionality.o \
|
|||
$(OUTDIR)/basicLogCollection.o $(OUTDIR)/basicLoggingService.o \
|
|||
$(OUTDIR)/basicMediaDestination.o $(OUTDIR)/basicMediaSource.o \
|
|||
$(OUTDIR)/basicMediaViewer.o $(OUTDIR)/basicMutex.o \
|
|||
$(OUTDIR)/basicObject.o $(OUTDIR)/basicRing.o \
|
|||
$(OUTDIR)/basicSettings.o $(OUTDIR)/basicSettingsProvider.o \
|
|||
$(OUTDIR)/basicThread.o $(OUTDIR)/basicTransport.o \
|
|||
$(OUTDIR)/IM_Backend.o $(OUTDIR)/IM_ClientHandler.o \
|
|||
$(OUTDIR)/IM_ClientProtocol.o $(OUTDIR)/IM_DataBaseAdapter.o \
|
|||
$(OUTDIR)/IM_DataStructs.o $(OUTDIR)/IM_DLibWorker.o \
|
|||
$(OUTDIR)/IM_DnnWorker.o $(OUTDIR)/IM_Kernel.o \
|
|||
$(OUTDIR)/json_reader.o $(OUTDIR)/json_value.o \
|
|||
$(OUTDIR)/json_writer.o $(OUTDIR)/md5.o $(OUTDIR)/mysql_class.o \
|
|||
$(OUTDIR)/netClientHandler.o $(OUTDIR)/netServer.o \
|
|||
$(OUTDIR)/objectConsoleLoggingService.o \
|
|||
$(OUTDIR)/objectFileLoggingService.o $(OUTDIR)/protocol.o \
|
|||
$(OUTDIR)/serverPort.o $(OUTDIR)/transportSocket.o \
|
|||
$(OUTDIR)/xmlParser.o |
|||
OBJ=$(COMMON_OBJ) $(CFG_OBJ) |
|||
ALL_OBJ=$(OUTDIR)/basicDualThread.o $(OUTDIR)/basicEngine.o \
|
|||
$(OUTDIR)/basicEvent.o $(OUTDIR)/basicEventHandler.o \
|
|||
$(OUTDIR)/basicEventHeap.o $(OUTDIR)/basicFunctionality.o \
|
|||
$(OUTDIR)/basicLogCollection.o $(OUTDIR)/basicLoggingService.o \
|
|||
$(OUTDIR)/basicMediaDestination.o $(OUTDIR)/basicMediaSource.o \
|
|||
$(OUTDIR)/basicMediaViewer.o $(OUTDIR)/basicMutex.o \
|
|||
$(OUTDIR)/basicObject.o $(OUTDIR)/basicRing.o \
|
|||
$(OUTDIR)/basicSettings.o $(OUTDIR)/basicSettingsProvider.o \
|
|||
$(OUTDIR)/basicThread.o $(OUTDIR)/basicTransport.o \
|
|||
$(OUTDIR)/IM_Backend.o $(OUTDIR)/IM_ClientHandler.o \
|
|||
$(OUTDIR)/IM_ClientProtocol.o $(OUTDIR)/IM_DataBaseAdapter.o \
|
|||
$(OUTDIR)/IM_DataStructs.o $(OUTDIR)/IM_DLibWorker.o \
|
|||
$(OUTDIR)/IM_DnnWorker.o $(OUTDIR)/IM_Kernel.o \
|
|||
$(OUTDIR)/json_reader.o $(OUTDIR)/json_value.o \
|
|||
$(OUTDIR)/json_writer.o $(OUTDIR)/md5.o $(OUTDIR)/mysql_class.o \
|
|||
$(OUTDIR)/netClientHandler.o $(OUTDIR)/netServer.o \
|
|||
$(OUTDIR)/objectConsoleLoggingService.o \
|
|||
$(OUTDIR)/objectFileLoggingService.o $(OUTDIR)/protocol.o \
|
|||
$(OUTDIR)/serverPort.o $(OUTDIR)/transportSocket.o \
|
|||
$(OUTDIR)/xmlParser.o -lmysqlclient -lssl -lcrypto -lpthread \
|
|||
`pkg-config --libs libavcodec libavdevice libavfilter libavformat \
|
|||
libavresample libavutil libswresample libswscale libconfig++ libcurl \
|
|||
opencv4` -lGL -lGLU -lc -lm -lz |
|||
|
|||
COMPILE=g++ -c -x c++ "-D_OPENCV_" -O3 `pkg-config --cflags opencv4` -s -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $< |
|||
LINK=g++ -O3 -s -o "$(OUTFILE)" $(ALL_OBJ) |
|||
|
|||
# Pattern rules
|
|||
$(OUTDIR)/%.o : ../../lib/components/object/%.cpp |
|||
$(COMPILE) |
|||
|
|||
$(OUTDIR)/%.o : ../../lib/data/json/%.cpp |
|||
$(COMPILE) |
|||
|
|||
$(OUTDIR)/%.o : ../../lib/data/transport/%.cpp |
|||
$(COMPILE) |
|||
|
|||
$(OUTDIR)/%.o : ../../lib/data/protocol/%.cpp |
|||
$(COMPILE) |
|||
|
|||
$(OUTDIR)/%.o : ../../lib/data/net/%.cpp |
|||
$(COMPILE) |
|||
|
|||
$(OUTDIR)/%.o : ../../lib/data/mysql/%.cpp |
|||
$(COMPILE) |
|||
|
|||
$(OUTDIR)/%.o : ../../lib/components/base/%.cpp |
|||
$(COMPILE) |
|||
|
|||
$(OUTDIR)/%.o : ../../lib/alg/generic/%.cpp |
|||
$(COMPILE) |
|||
|
|||
$(OUTDIR)/%.o : %.cpp |
|||
$(COMPILE) |
|||
|
|||
# Build rules
|
|||
all: $(OUTFILE) |
|||
|
|||
$(OUTFILE): $(OUTDIR) $(OBJ) |
|||
$(LINK) |
|||
|
|||
$(OUTDIR): |
|||
$(MKDIR) -p "$(OUTDIR)" |
|||
|
|||
# Rebuild this project
|
|||
rebuild: cleanall |
|||
@$(MAKE) -f "$(strip $(MAKEFILE_LIST))" $(MAKEFLAGS) all |
|||
|
|||
# Clean this project
|
|||
clean: |
|||
$(RM) -f $(OUTFILE) |
|||
$(RM) -f $(OBJ) |
|||
|
|||
# Clean this project and all dependencies
|
|||
cleanall: clean |
|||
endif |
|||
|
|||
#
|
|||
# include dependencies:
|
|||
#
|
|||
$(OUTDIR)/basicDualThread.o: ../../lib/components/base/basicDualThread.cpp ../../lib/components/base/basicDualThread.h |
|||
$(OUTDIR)/basicEngine.o: ../../lib/components/base/basicEngine.cpp ../../lib/components/base/basicEngine.h |
|||
$(OUTDIR)/basicEvent.o: ../../lib/components/base/basicEvent.cpp ../../lib/components/base/basicEvent.h ../../lib/components/base/basicFunctionality.h |
|||
$(OUTDIR)/basicEventHandler.o: ../../lib/components/base/basicEventHandler.cpp ../../lib/components/base/basicEventHandler.h ../../lib/components/base/basicEventHeap.h |
|||
$(OUTDIR)/basicEventHeap.o: ../../lib/components/base/basicEventHeap.cpp ../../lib/components/base/basicEventHeap.h ../../lib/components/base/basicEventHandler.h |
|||
$(OUTDIR)/basicFunctionality.o: ../../lib/components/base/basicFunctionality.cpp ../../lib/components/base/basicFunctionality.h ../../lib/alg/generic/md5.h ../../lib/components/base/basicLogCollection.h |
|||
$(OUTDIR)/basicLogCollection.o: ../../lib/components/base/basicLogCollection.cpp ../../lib/components/base/basicLogCollection.h ../../lib/alg/generic/heapDebug.h |
|||
$(OUTDIR)/basicLoggingService.o: ../../lib/components/base/basicLoggingService.cpp ../../lib/components/base/basicLoggingService.h |
|||
$(OUTDIR)/basicMediaDestination.o: ../../lib/components/base/basicMediaDestination.cpp ../../lib/components/base/basicMediaDestination.h |
|||
$(OUTDIR)/basicMediaSource.o: ../../lib/components/base/basicMediaSource.cpp ../../lib/components/base/basicMediaSource.h |
|||
$(OUTDIR)/basicMediaViewer.o: ../../lib/components/base/basicMediaViewer.cpp ../../lib/components/base/basicMediaViewer.h |
|||
$(OUTDIR)/basicMutex.o: ../../lib/components/base/basicMutex.cpp ../../lib/components/base/basicMutex.h |
|||
$(OUTDIR)/basicObject.o: ../../lib/components/base/basicObject.cpp ../../lib/components/base/basicObject.h ../../lib/alg/generic/md5.h |
|||
$(OUTDIR)/basicRing.o: ../../lib/components/base/basicRing.cpp ../../lib/components/base/basicRing.h |
|||
$(OUTDIR)/basicSettings.o: ../../lib/components/base/basicSettings.cpp ../../lib/components/base/basicSettings.h |
|||
$(OUTDIR)/basicSettingsProvider.o: ../../lib/components/base/basicSettingsProvider.cpp ../../lib/components/base/basicSettingsProvider.h |
|||
$(OUTDIR)/basicThread.o: ../../lib/components/base/basicThread.cpp ../../lib/components/base/basicThread.h |
|||
$(OUTDIR)/basicTransport.o: ../../lib/components/base/basicTransport.cpp ../../lib/components/base/basicTransport.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h |
|||
$(OUTDIR)/IM_Backend.o: IM_Backend.cpp IM_Backend.h ../../lib/components/base/basicSettings.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicMemoryOperation.h ../../lib/components/object/objectFileLoggingService.h ../../lib/components/object/objectConsoleLoggingService.h ../../lib/data/net/netServer.h IM_Kernel.h ../../lib/data/net/netServiceEngine.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicSettingsProvider.h IM_DataStructs.h ../../lib/components/base/basicFunctionality.h IM_DnnWorker.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicEventHeap.h IM_DLibWorker.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicEventHeap.h IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h |
|||
$(OUTDIR)/IM_ClientHandler.o: IM_ClientHandler.cpp IM_ClientHandler.h ../../lib/data/net/netClientHandler.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicEventHandler.h ../../lib/components/base/basicLogCollection.h ../../lib/data/net/serverPort.h ../../lib/data/net/netServiceEngine.h IM_ClientProtocol.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h IM_Kernel.h ../../lib/data/net/netServiceEngine.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicSettingsProvider.h IM_DataStructs.h ../../lib/components/base/basicFunctionality.h IM_DnnWorker.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicEventHeap.h IM_DLibWorker.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicEventHeap.h IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h ../../lib/components/base/basicFunctionality.h ../../lib/data/json/json_tool.h ../../lib/data/protocol/xmlParser.h ../../lib/include/json/value.h ../../lib/include/json/writer.h ../../lib/include/json/reader.h |
|||
$(OUTDIR)/IM_ClientProtocol.o: IM_ClientProtocol.cpp IM_ClientProtocol.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h |
|||
$(OUTDIR)/IM_DataBaseAdapter.o: IM_DataBaseAdapter.cpp IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h ../../lib/alg/generic/md5.h |
|||
$(OUTDIR)/IM_DataStructs.o: IM_DataStructs.cpp IM_DataStructs.h ../../lib/components/base/basicFunctionality.h |
|||
$(OUTDIR)/IM_DLibWorker.o: IM_DLibWorker.cpp IM_DLibWorker.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicEventHeap.h IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h ../../lib/alg/generic/md5.h ../../lib/components/base/basicFunctionality.h |
|||
$(OUTDIR)/IM_DnnWorker.o: IM_DnnWorker.cpp IM_DnnWorker.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicEventHeap.h ../../lib/components/base/basicFunctionality.h |
|||
$(OUTDIR)/IM_Kernel.o: IM_Kernel.cpp IM_Kernel.h ../../lib/data/net/netServiceEngine.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicSettingsProvider.h IM_DataStructs.h ../../lib/components/base/basicFunctionality.h IM_DnnWorker.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicEventHeap.h IM_DLibWorker.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicEventHeap.h IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h IM_ClientHandler.h ../../lib/data/net/netClientHandler.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicEventHandler.h ../../lib/components/base/basicLogCollection.h ../../lib/data/net/serverPort.h ../../lib/data/net/netServiceEngine.h IM_ClientProtocol.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h |
|||
$(OUTDIR)/json_reader.o: ../../lib/data/json/json_reader.cpp ../../lib/data/json/json_tool.h ../../lib/include/json/assertions.h ../../lib/include/json/reader.h ../../lib/include/json/value.h |
|||
$(OUTDIR)/json_value.o: ../../lib/data/json/json_value.cpp ../../lib/include/json/assertions.h ../../lib/include/json/value.h ../../lib/include/json/writer.h ../../lib/data/json/json_valueiterator.inl |
|||
$(OUTDIR)/json_writer.o: ../../lib/data/json/json_writer.cpp ../../lib/data/json/json_tool.h ../../lib/include/json/writer.h |
|||
$(OUTDIR)/md5.o: ../../lib/alg/generic/md5.cpp ../../lib/alg/generic/md5.h |
|||
$(OUTDIR)/mysql_class.o: ../../lib/data/mysql/mysql_class.cpp ../../lib/data/mysql/mysql_class.h |
|||
$(OUTDIR)/netClientHandler.o: ../../lib/data/net/netClientHandler.cpp ../../lib/data/net/netClientHandler.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicEventHandler.h ../../lib/components/base/basicLogCollection.h ../../lib/data/net/serverPort.h ../../lib/data/net/netServiceEngine.h |
|||
$(OUTDIR)/netServer.o: ../../lib/data/net/netServer.cpp ../../lib/data/net/netServer.h ../../lib/data/net/netClientHandler.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicEventHandler.h ../../lib/components/base/basicLogCollection.h ../../lib/data/net/serverPort.h ../../lib/data/net/netServiceEngine.h |
|||
$(OUTDIR)/objectConsoleLoggingService.o: ../../lib/components/object/objectConsoleLoggingService.cpp ../../lib/components/object/objectConsoleLoggingService.h |
|||
$(OUTDIR)/objectFileLoggingService.o: ../../lib/components/object/objectFileLoggingService.cpp ../../lib/components/object/objectFileLoggingService.h |
|||
$(OUTDIR)/protocol.o: ../../lib/data/protocol/protocol.cpp ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h |
|||
$(OUTDIR)/serverPort.o: ../../lib/data/net/serverPort.cpp ../../lib/data/net/serverPort.h |
|||
$(OUTDIR)/transportSocket.o: ../../lib/data/transport/transportSocket.cpp ../../lib/data/transport/transportSocket.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h |
|||
$(OUTDIR)/xmlParser.o: ../../lib/data/protocol/xmlParser.cpp ../../lib/data/protocol/xmlParser.h |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue