Evo 7.12.0-TM26061101
Evo LPR Engine
Loading...
Searching...
No Matches
C++

C++ APIs. More...

Files

file  Basic.h
 C/C++ header file common to all type of engines and functionalities.
file  Engine.hpp
 C++ header file common to all type of engines.
file  SSEngine.hpp
 C++ header file for Snapshot Engine.
file  TSSEngine.hpp
 C++ header file for Triggered Snapshot Engine.
file  FAVEngine.hpp
 C++ header file for Fully Automatic Video Engine.
file  Picture.hpp
 C++ header file for pictures.
file  GenICam.hpp
 C++ header file for GenICam.
file  CamCalib.hpp
 C++ header file for Camera Calibration.

Detailed Description

To use the engines in applications, the following files are required.

  • Snapshot Engine
    • 'SSEngine.hpp' header file
    • On Windows, 'EvoEngine.lib', 'EvoSSE.lib' import libraries.
    • On Linux, 'libEvoEngine.so', 'libEvoSSE.so' shared libraries.
  • Triggered Snapshot Engine
    • 'TSSEngine.hpp' header file
    • On Windows, 'EvoEngine.lib', 'EvoTSSE.lib' import libraries.
    • On Linux, 'libEvoEngine.so', 'libEvoTSSE.so' shared libraries.
  • Fully Automatic Video Engine
    • 'FAVEngine.hpp' header file
    • On Windows, 'EvoEngine.lib', 'EvoFAVE.lib' import libraries.
    • On Linux, 'libEvoEngine.so', 'libEvoFAVE.so' shared libraries.

To use additional functionalities, the following files are required

  • GenICam
    • 'GenICam.hpp' header file
    • On Windows, 'EvoGIC.lib' import library
    • On Linux, 'libEvoGIC.so' shared library.
  • Camera Calibrations
    • 'CamCalib.hpp' header file
    • On Windows, 'EvoCC.lib' import library
    • On Linux, 'libEvoCC.so' shared library.

For their paths, refer to SDK contents.

Example for Snapshot Engine

#include <cassert>
#include <cstdlib>
#include <iostream>
// Include the header file for the C++ API.
#include <Evo/SSEngine.hpp>
using namespace std;
int main(int argc, char *argv[])
{
const char *imgPath = NULL; // Sample Image File Path.
const char *dataDir = NULL; // SDK's data directory
if (argc < 2)
{
cerr << "Usage: TestSSEngCpp [sdk_data_dir] image_file" << endl;
return EXIT_FAILURE;
}
else if (argc == 2)
{
imgPath = argv[1];
}
else
{
dataDir = argv[1];
imgPath = argv[2];
}
EvoRC rc;
size_t numDev;
Evo::DDI::Ptr ddi; // DNN Device Information
// 1. Initialize Evo engine library. Optionally can get DDI object
rc = Evo::Initialize(NULL, dataDir, &ddi);
assert(rc == EVORC_OK);
// [+] Optionally examine the DDI.
numDev = ddi->GetNumDev(); // Get total number of available DNN devices.
cout << endl << "<< Supported DNN Devices >>" << endl;
for (size_t i = 0; i < numDev; i++)
{
// At first, select a specific device.
rc = ddi->SelectDev(i);
assert(rc == EVORC_OK);
// Get ID of the selected DNN device.
cout << " ID: " << ddi->GetDevID() << endl;
// Get full name of the selected device.
cout << " Full Name: " << ddi->GetFullName() << endl;
if (i < (numDev - 1U))
cout << " --------------------------------------------" << endl;
}
cout << endl;
ddi.reset();
// [-]
Evo::SSEngine::Ptr sse;
// 2. Create a Snapshot Engine.
assert(sse);
// 3. Initialize the engine.
rc = sse->Init("KOR", NULL);
assert(rc == EVORC_OK);
// [+] 4. If required, set or get engine parameters of interest.
EvoRect searchRect;
rc = sse->GetParam(EVOPARAM_SEARCH_RECT, &searchRect);
assert(rc == EVORC_OK);
//searchRect.x = 0;
//searchRect.y = 0;
searchRect.width = 0;
searchRect.height = 0;
rc = sse->SetParam(EVOPARAM_SEARCH_RECT, &searchRect);
assert(rc == EVORC_OK);
// [-]
//
// Repeat the stpes 5 ~ 6.
//
Evo::LPI::Ptr lpi;
// 5. Run the engine with input image.
lpi = sse->Run(imgPath);
rc = Evo::GetLastRC(); // Get the return code.
assert(rc == EVORC_OK);
// In case any license plate was found.
if (lpi)
{
//
// 6. Examine the LPI.
//
// Get total number of the found license plates.
size_t num = lpi->GetNumLP();
for (size_t i = 0; i < num; i++)
{
// [+]Get string
char bufCP[512] = { 0 }; // Buffer for string encoded in CodePage
const char *strUTF8 = NULL; // String encoded in UTF8
rc = lpi->SelectLP(i);
assert(rc == EVORC_OK);
strUTF8 = lpi->GetStr();
#ifdef _WIN64
rc = Evo::CvtUTF8ToCP(strUTF8, bufCP, sizeof(bufCP));
assert(rc == EVORC_OK);
cout << bufCP << endl;
#else // __linux__
cout << bufUTF8 << endl;
#endif
// [+] Get the bounding box.
const EvoRect &bbox = lpi->GetPos();
cout << " --> Position: " << bbox.x << ", " << bbox.y << ", " << bbox.width << ", " << bbox.height << endl;
// [-]
// [+] Get the type and its confidence.
EvoLPT type;
float confidence;
lpi->GetType(type, confidence);
cout << " --> Type: " << type << " (" << confidence << "%)" << endl;
// [-]
}
lpi.reset();
}
// Deinitialize the engine.
sse->Deinit();
sse.reset();
return EXIT_SUCCESS;
}
@ EVOPARAM_SEARCH_RECT
Definition Basic.h:224
EvoRC
Return Codes.
Definition Basic.h:59
int EvoLPT
License Plate Type.
Definition Basic.h:598
C++ header file for Snapshot Engine.
static EVOSSE_DECLSPEC Ptr Create(void)
EvoRC GetLastRC(void)
EvoRC CvtUTF8ToCP(const char *utf8, char *cpBuf, size_t bufLen)
EvoRC Initialize(const char *drmd=NULL, const char *dataDir=NULL, DDI::Ptr *ddi=NULL)
Rectangle Descriptor.
Definition Basic.h:463
int height
Height Size.
Definition Basic.h:467
int x
X Coordinate of Top-Left.
Definition Basic.h:464
int y
Y Coordinate of Top-Left.
Definition Basic.h:465
int width
Width Size.
Definition Basic.h:466

Example for Triggered Snapshot Engine

#include <cassert>
#include <string>
#include <iostream>
// Include the header file for the C++ API.
using namespace std;
static void Trigger(Evo::TSSEngine::Ptr &tsse, const char *imgDir, int num)
{
EvoRC rc;
string path(imgDir);
Evo::LPI::Ptr lpi;
Evo::Picture::Ptr pic; // Must be reset.
// Get picture and result for the triggered event.
lpi = tsse->Trigger(pic);
assert(rc == EVORC_OK && pic);
// In case any license plate was found.
if (lpi)
{
//
// Examine the LPI.
//
// Get total number of license plates.
size_t numLPs = lpi->GetNumLP();
// Enumerate all the license plates.
for (size_t i = 0; i < numLPs; i++)
{
char bufCP[512] = { 0 }; // Buffer for string encoded in CodePage
const char *strUTF8 = NULL; // String encoded in UTF-8
// At first, select a specific LP.
rc = lpi->SelectLP(i);
assert(rc == EVORC_OK);
// [+] Get text string.
strUTF8 = lpi->GetStr();
#ifdef _WIN64
rc = Evo::CvtUTF8ToCP(strUTF8, bufCP, sizeof(bufCP));
assert(rc == EVORC_OK);
cout << endl << bufCP << endl;
#else // __linux__
cout << endl << strUTF8 << endl;
#endif
// [-]
// [+] Get bounding box.
const EvoRect &bbox = lpi->GetPos();
cout << " --> Position: " << bbox.x << ", " << bbox.y << ", " << bbox.width << ", " << bbox.height << endl;
// [-]
// [+] Get type.
EvoLPT type;
float confidence;
lpi->GetType(type, confidence);
cout << " --> Type: " << type << " (" << confidence << "%)" << endl;
// [-]
}
lpi.reset();
}
#ifdef _WIN64
path += '\\';
#else // __linux__
path += '/';
#endif
path += to_string(num) + ".jpg";
// Save the output image.
pic->SaveInJPEG(path.c_str());
pic.reset();
}
int main(int argc, char *argv[])
{
const char *dataDir = NULL; // SDK's data directory
const char *imgDir = NULL; // Directory for the captured images to be saved.
const char *url = NULL; // For example, "rtsp://192.168.1.100/media.smp";
if (argc < 3)
{
fprintf(stderr, "%s [sdk_data_dir] video_source_url image_dir\n", argv[0]);
return EXIT_FAILURE;
}
else if (argc == 3)
{
url = argv[1];
imgDir = argv[2];
}
else
{
dataDir = argv[1];
url = argv[2];
imgDir = argv[3];
}
EvoRC rc;
size_t numDev;
Evo::DDI::Ptr ddi; // DNN Device Information
// 1. Initialize Evo engine library. Optionally can get DDI object
rc = Evo::Initialize(NULL, dataDir, &ddi);
assert(rc == EVORC_OK);
// [+] Optionally examine the DDI.
numDev = ddi->GetNumDev(); // Get total number of available DNN devices.
cout << "<< Supported DNN Devices >>" << endl;
for (size_t i = 0; i < numDev; i++)
{
const char *id;
size_t numDMDF;
// At first, select a specific device.
rc = ddi->SelectDev(i);
assert(rc == EVORC_OK);
// Get ID of the selected DNN device.
cout << " ID: " << ddi->GetDevID() << endl;
// Get full name of the selected device.
cout << " Full Name: " << ddi->GetFullName() << endl;
if (i < (numDev - 1U))
cout << " --------------------------------------------" << endl;
}
cout << endl;
// Must release the DDI object.
ddi.reset();
// [-]
Evo::TSSEngine::Ptr tsse;
// 2. Create a Triggered Snapshot Engine.
assert(rc == EVORC_OK && tsse);
// 3. Initialize the engine with video source url or GenICam device.
rc = tsse->Init("KOR", NULL, url);
assert(rc == EVORC_OK);
// [+] 4. If required, set or get the engine parameters of interest.
EvoOutput output;
rc = tsse->GetParam(EVOPARAM_OUTPUT, &output);
assert(rc == EVORC_OK);
// [-]
int num = 1;
time_t baseTime = time(NULL);
// This emulates asynchronous trigger event using timer.
while (difftime(time(NULL), baseTime) <= 5.0)
{
if (time_t(difftime(time(NULL), baseTime)) == time_t(num))
{
// 5. Handle the trigger event.
Trigger(tsse, imgDir, num++);
}
}
// Deinitialize the engine.
tsse->Deinit();
tsse.reset();
return EXIT_SUCCESS;
}
@ EVOPARAM_OUTPUT
Definition Basic.h:205
C++ header file for Triggered Snapshot Engine.
static EVOTSSE_DECLSPEC Ptr Create(void)
Engine's Output Configurations.
Definition Basic.h:301

Example for Fully Automatic Video Engine

#include <cassert>
#include <ctime>
#include <string>
#include <iostream>
// Include the header file for the C++ API.
using namespace std;
static void HandleResult(const Evo::LPI::Ptr &lpi, const Evo::GOP::Ptr &gop, const char *imgDir)
{
EvoRC rc;
EvoLPT type;
float confidence;
EvoHeadDir heading;
string path(imgDir);
char bufCP[512] = { 0 }; // Buffer for string encoded in CodePage
const char *strUTF8 = NULL; // String encoded in UTF-8
size_t numPic = gop->GetNumPic();
// In case of FAVEngine, the LPI has always single item.
assert(lpi->GetNumLP() == 1U);
// Get text string.
strUTF8 = lpi->GetStr();
#ifdef _WIN64
rc = Evo::CvtUTF8ToCP(strUTF8, bufCP, sizeof(bufCP));
assert(rc == EVORC_OK);
cout << "String: " << bufCP << endl;
#else // __linux__
cout << "String: " << strUTF8 << endl;
#endif
// Get type.
lpi->GetType(type, confidence);
cout << "Type: " << type << " (" << confidence << "%)" << endl;
// Get bounding box of each picture.
for (size_t i = 0; i < numPic; i++)
{
EvoRect bbox;
time_t timeRaw;
int64_t timeUTC, timeMS;
struct tm *timeInfo = NULL;
rc = gop->SelectPic(i);
assert(rc == EVORC_OK);
// Get bounding box of each picture.
bbox = gop->GetPosInPic();
cout << "Position: "
<< bbox.x << ", "
<< bbox.y << ", "
<< bbox.width << ", "
<< bbox.height << endl;
// Get time of each picture.
timeUTC = gop->GetPicTime();
timeMS = timeUTC % 1000;
timeRaw = time_t(timeUTC / 1000);
timeInfo = localtime(&timeRaw);
cout << "Time: "
<< timeInfo->tm_year + 1900 << '-'
<< timeInfo->tm_mon + 1 << '-'
<< timeInfo->tm_mday << ' '
<< timeInfo->tm_hour << ':'
<< timeInfo->tm_min << ':'
<< timeInfo->tm_sec << '.'
<< timeMS << endl;
}
// Get automobile's heading direction
heading = gop->GetHeadDir();
cout << "Heading Directon: " << heading << endl;
cout << endl;
#ifdef _WIN64
path += '\\' + string(bufCP);
#else // __linux__
path += '/' + string(bufUTF8);
#endif
if (numPic < 2U)
{
path += ".jpg";
rc = gop->SavePicInJPEG(path.c_str());
}
else
{
path += ".tiff";
rc = gop->SaveAllInTIFF(path.c_str());
}
assert(rc == EVORC_OK);
}
int main(int argc, char *argv[])
{
string viType; // Video Input Type, 'IPProto' or 'GenICam'.
const char *dataDir = NULL; // SDK's data directory
const char *imgDir = NULL; // Directory for the captured images to be saved.
//const char *url = "rtsp://192.168.1.100/media.smp";
const char *url = "F:\\Temp1\\2014-11-24_.mkv";
struct {
Evo::GIC::Admin::Ptr admin; // GenICam Administrator
Evo::GIC::Dev::Ptr dev; // GenICam Device
} gc = { NULL, NULL };
if (argc < 3)
{
fprintf(stderr, "%s [SDK_Data_Dir] Video_Input_Type Image_Dir\n", argv[0]);
return EXIT_FAILURE;
}
else if (argc == 3)
{
viType = argv[1];
imgDir = argv[2];
}
else
{
dataDir = argv[1];
viType = argv[2];
imgDir = argv[3];
}
EvoRC rc;
unsigned numDev;
Evo::DDI::Ptr ddi; // DNN Device Information
// 1. Initialize Evo engine library. Optionally can get DDI object.
rc = Evo::Initialize(NULL, dataDir, &ddi);
assert(rc == EVORC_OK);
// [+] Optionally examine the DDI.
numDev = ddi->GetNumDev(); // Get total number of available DNN devices.
cout << "<< Supported DNN Devices >>" << endl;
for (size_t i = 0; i < numDev; i++)
{
// At first, select a specific device.
rc = ddi->SelectDev(i);
assert(rc == EVORC_OK);
// Get ID of the selected DNN device.
cout << " ID: " << ddi->GetDevID() << endl;
// Get full name of the selected device.
cout << " Full Name: " << ddi->GetFullName() << endl;
if (i < (numDev - 1U))
cout << " --------------------------------------------" << endl;
}
cout << endl;
ddi.reset();
// [-]
if (viType == "GenICam")
{
gc.admin = Evo::GIC::Admin::Get();
assert(gc.admin);
gc.admin->UpdateDevList();
numDev = gc.admin->GetNumDev();
assert(Evo::GetLastRC() == EVORC_OK);
if (numDev <= 0)
{
gc.admin.reset();
return EXIT_FAILURE;
}
else
{
unsigned numDS;
for (unsigned i = 0; i < numDev; i++)
{
const char *str;
rc = gc.admin->SelectDev(i);
assert(rc == EVORC_OK);
cout << "[Current Device: " << i << "]" << endl;
str = gc.admin->GetDevIfc();
assert(Evo::GetLastRC() == EVORC_OK);
cout << "Interface: " << str << endl;
str = gc.admin->GetDevVendor();
assert(Evo::GetLastRC() == EVORC_OK);
cout << "Vendor: " << str << endl;
str = gc.admin->GetDevModel();
assert(Evo::GetLastRC() == EVORC_OK);
cout << "Model: " << str << endl;
str = gc.admin->GetDevSerialNo();
assert(Evo::GetLastRC() == EVORC_OK);
cout << "SerialNo: " << str << endl;
str = gc.admin->GetDevID();
assert(Evo::GetLastRC() == EVORC_OK);
cout << "ID: " << str << endl;
}
cout << endl;
rc = gc.admin->SelectDev(0);
assert(rc == EVORC_OK);
gc.dev = gc.admin->OpenDev();
assert(Evo::GetLastRC() == EVORC_OK);
numDS = gc.dev->GetNumDataStreams();
assert(Evo::GetLastRC() == EVORC_OK);
if (numDS > 0)
cout << "Number of data streams: " << numDS << endl;
else
{
gc.dev.reset();
gc.admin.reset();
return EXIT_FAILURE;
}
}
}
Evo::FAVEngine::Ptr fave;
// 2. Create a Fully Automatic Video Engine.
assert(rc == EVORC_OK && fave != NULL);
// 3. Initialize the engine with video source url or GenICam device.
if (viType == "IPProto")
rc = fave->Init("KOR", NULL, url);
else // In case of 'GenICam'
rc = fave->Init("KOR", NULL, gc.dev, 0);
assert(rc == EVORC_OK);
// [+] 4. If required, set or get the engine parameters of interest.
EvoOutput output;
rc = fave->GetParam(EVOPARAM_OUTPUT, &output);
assert(rc == EVORC_OK);
output.headDir = EVO_TRUE;
rc = fave->SetParam(EVOPARAM_OUTPUT, &output);
assert(rc == EVORC_OK);
// [-]
// 5. Get the LPI and realted images.
for (int num = 0; num < 3; num++)
{
Evo::LPI::Ptr lpi;
Evo::GOP::Ptr gop; // Must be reset.
lpi = fave->PopLPI(gop);
// When errors occured.
if (lpi == nullptr && gop == nullptr)
{
// Check the video stream has been closed.
if (Evo::GetLastRC() == EVORC_NO_MORE_DATA)
cerr << "The video stream closed." << endl;
else
exit(EXIT_FAILURE);
break;
}
HandleResult(lpi, gop, imgDir);
}
// Deinitialize the engine.
fave->Deinit();
fave.reset();
if (viType == "GenICam")
{
gc.dev.reset(); // At first, destroy the GenICam device.
gc.admin.reset();
}
return EXIT_SUCCESS;
}
EvoHeadDir
Automobile's Heading Directions.
Definition Basic.h:277
C++ header file for Fully Automatic Video Engine.
static EVOFAVE_DECLSPEC Ptr Create(void)
static EVOGIC_DECLSPEC Ptr Get(void)
EvoBool headDir
Definition Basic.h:305

Example for camera calibration

#include <cassert>
#include <cstdlib>
#include <iostream>
// Include the header file for the C++ API.
#include <Evo/SSEngine.hpp>
#include <Evo/CamCalib.hpp>
using namespace std;
int main(int argc, char *argv[])
{
const char *dataDir = NULL; // SDK's data directory
const char *calibName = NULL; // Camera Calibration Name
const char *imgPath = NULL; // Image file path.
if (argc < 3)
{
cerr << "Usage: TestSSEngCpp [sdk_data_dir] camera_calib_name image_file" << endl;
return EXIT_FAILURE;
}
else if (argc == 3)
{
calibName = argv[1];
imgPath = argv[2];
}
else
{
dataDir = argv[1];
calibName = argv[2];
imgPath = argv[3];
}
EvoRC rc;
EvoSize maxResol;
Evo::SSEngine::Ptr sse;
Evo::CC::Fisheye::Ptr fisheyeModel; // Fisheye Camera Model
// 1. Initialize Evo engine library.
rc = Evo::Initialize("latency", dataDir);
assert(rc == EVORC_OK);
// 2. Create fisheye camera model.
fisheyeModel = Evo::CC::Fisheye::Create(calibName);
assert(fisheyeModel);
// [+] Optionally, get/set the camera properties
// such as focal length and output size.
maxResol = fisheyeModel->GetMaxResol();
maxResol.width += 200;
rc = fisheyeModel->SetOutputSize(maxResol);
assert(rc == EVORC_OK);
// [-]
// 3. Create a snapshot engine.
assert(sse != NULL);
// [-]
// 4. Initialize the engine.
rc = sse->Init("KOR", "FP32:CPU");
assert(rc == EVORC_OK);
Evo::LPI::Ptr lpi;
Evo::Picture::Ptr pic;
//
// If there are more input images, repeat the stpes 5 ~ 8.
//
// 5. Get rectified image.
pic = fisheyeModel->Rectify(imgPath);
assert(pic);
// 6. Run the engine with the rectified image.
lpi = sse->Run(pic->GetImage());
rc = Evo::GetLastRC(); // Get the return code.
assert(rc == EVORC_OK);
// In case any license plate was found.
if (lpi)
{
//
// 7. Examine the LPI.
//
// Get total number of the found license plates.
size_t num = lpi->GetNumLP();
for (size_t i = 0; i < num; i++)
{
// At first, select a specific license plate.
rc = lpi->SelectLP(i);
assert(rc == EVORC_OK);
// [+]Get string
char bufCP[512] = { 0 }; // Buffer for string encoded in CodePage
const char *strUTF8;; // String encoded in UTF8
strUTF8 = lpi->GetStr();
#ifdef _WIN64
rc = Evo::CvtUTF8ToCP(strUTF8, bufCP, sizeof(bufCP));
assert(rc == EVORC_OK);
cout << bufCP << endl;
#else // __linux__
cout << strUTF8 << endl;
#endif
// [+] Get the bounding box.
const EvoRect &bbox = lpi->GetPos();
cout << " --> Position: " << bbox.x << ", " << bbox.y << ", " << bbox.width << ", " << bbox.height << endl;
// [-]
// [+] Get the type and its confidence.
EvoLPT type;
float confidence;
lpi->GetType(type, confidence);
cout << " --> Type: " << type << " (" << confidence << "%)" << endl;
// [-]
}
lpi.reset();
}
// If required, save the rectified image.
rc = pic->SaveInJPEG("F:\\Temp3\\rectified_image.jpg");
assert(rc == EVORC_OK);
pic.reset();
// Deinitialize the engine.
sse->Deinit();
sse.reset();
return EXIT_SUCCESS;
}
C++ header file for Camera Calibration.
static EVOCC_DECLSPEC Ptr Create(const char *calibName)
Size Descriptor.
Definition Basic.h:436
int width
Width Size.
Definition Basic.h:437