Browse Source

Working ImgMill - fixed DLib sm_37 computation issue with CUDA

pull/7/head
Evgeny Gagua 11 months ago
parent
commit
ce8bd34259
  1. 6
      Projects/img_mill/IM_ClientHandler.cpp
  2. 47
      Projects/img_mill/IM_DLibWorker.cpp
  3. 2
      Projects/img_mill/IM_DnnWorker.cpp
  4. 2
      Projects/img_mill/IM_DnnWorker.h

6
Projects/img_mill/IM_ClientHandler.cpp

@ -12,15 +12,15 @@
#define LOG( X ) m_pLog->Log( "NCH", this, X )
#define LOG( X ) m_pLog->Log( "CH", 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 );\
m_pLog->Log( "CH", this, _LOG_ERROR, _tBfrErrMSG234 );\
}
#else
#define LOG_ERROR( X ) m_pLog->Log( "NCH", this, _LOG_ERROR, X );
#define LOG_ERROR( X ) m_pLog->Log( "CH", this, _LOG_ERROR, X );
#endif
// Constructor implementation

47
Projects/img_mill/IM_DLibWorker.cpp

@ -308,7 +308,33 @@ IM_RESULT *IM_DlibWorker::m_fImageAnalyzer( cv::Mat &Pic ){
};
idx++;
};
if( faces.size() ) {
retVal = (IM_RESULT *)malloc(sizeof(IM_RESULT));
if( retVal ) {
retVal->pJOB = m_pActiveJob;
retVal->nBoxCount = faces.size();
retVal->boxes = (IM_CLASS_BOUNDARY_BOX *) calloc( retVal->nBoxCount,sizeof(IM_CLASS_BOUNDARY_BOX));
if( retVal->boxes ) {
for( int i=0; i< faces.size(); i++ ) {
//bbox_t * b = &(faces.at(i));
retVal->boxes[i].weight = 1.0;
retVal->boxes[i].x = 0;
retVal->boxes[i].y =0;
retVal->boxes[i].width = 0;
retVal->boxes[i].height = 0;
retVal->boxes[i].classID =0;
#ifdef DEBUG
char msg[256];
sprintf( msg, "[%d] Face: %d Prob: %.2f", i, retVal->boxes[i].classID, retVal->boxes[i].weight );
LOG( msg );
#endif
};
} else {
free(retVal);
retVal = NULL;
};
};
};
if( m_bUseShapePredictor ) {
//if (faces.size() == 0){
// cout << "No faces found in image!" << endl;
@ -404,9 +430,11 @@ void IM_DlibWorker::m_fThreadProc( void ){
EVT_PTR->m_eClass = EVT_CLASS_IMAGE;
EVT_PTR->m_eType = EVT_READY;
if( IM_RESULT *tData = m_fImageAnalyzer( m_oWorkingMat ) ){
LOG("Y DETECT EVT!");
//generate detection event
EVT_PTR->m_pEvtData = tData;
} else {
LOG("N DETECT EVT!");
//generate NOT detection event
EVT_PTR->m_pEvtData = NULL;
};
@ -429,6 +457,7 @@ bool IM_DlibWorker::enqueueJob( IM_JOB *ptr ){
char p1[3];
char p2[3];
char p3[3];
bool delete_source = false;
LOG( ptr->md5 );
memcpy( p1, ptr->md5 , 2); p1[2]=(char)0;
memcpy( p2, ptr->md5+2, 2); p2[2]=(char)0;
@ -438,18 +467,32 @@ bool IM_DlibWorker::enqueueJob( IM_JOB *ptr ){
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_AVIF:{
char tSrc[1024];
char cmd[4096];
sprintf( tSrc, "%s/%s/%s/%s/%s.avif", m_pPicturesBase, p1, p2, p3, ptr->md5 );
//Workaround AVIF files
sprintf( tPath, "%s/%s/%s/%s/%s.png", m_pPicturesBase, p1, p2, p3, ptr->md5 );
sprintf( cmd, "magick convert \"%s\" \"%s\"", tSrc, tPath );
system( cmd );
delete_source = fileExist( tPath );
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 ( delete_source ) unlink( tPath );
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 );
cv::imwrite("cur-dlib-test-img.jpg", m_oWorkingMat );
//save_jpeg( m_oInputImg, "cur-test-img.jpg", 75 );
#endif
m_bDataIsActive = true;

2
Projects/img_mill/IM_DnnWorker.cpp

@ -348,7 +348,7 @@ bool IM_DnnWorker::enqueueJob( IM_JOB *ptr ){
if( m_mBufferProtectorMutex.try_lock() ) {
Frame.copyTo( m_oWorkingMat );
#ifdef DEBUG
cv::imwrite("cur-test-img.jpg", m_oWorkingMat );
cv::imwrite("cur-dnn-test-img.jpg", m_oWorkingMat );
#endif
m_bDataIsActive = true;
m_pActiveJob = ptr;

2
Projects/img_mill/IM_DnnWorker.h

@ -7,7 +7,7 @@
#include "../../lib/components/base/basicEventHeap.h"
#include "IM_DataStructs.h"
//#define DARKNET
#define DARKNET
#ifdef DARKNET
#define GPU

Loading…
Cancel
Save