本文整理汇总了C++中PluginLoader::createPluginInstance方法的典型用法代码示例。如果您正苦于以下问题:C++ PluginLoader::createPluginInstance方法的具体用法?C++ PluginLoader::createPluginInstance怎么用?C++ PluginLoader::createPluginInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PluginLoader
的用法示例。
在下文中一共展示了PluginLoader::createPluginInstance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
if (argc < 4) {
cerr << "Invalid number of arguments." << endl;
cout << "Usage: " << argv[0] << " <input_video_file_path> <analytic_plugin_dir_path> <analytic_plugin_filename>" << endl;
cout << "Example: " << argv[0] << "input.mp4 ~/analytic/ analytic_plugin.so" << endl;
return -1;
}
string input_video_file_path = argv[1];
string analytic_plugin_dir_path = argv[2];
string analytic_plugin_filename = argv[3];
ConcurrentQueue<api::Image_t>* pImageInputQueue = new ConcurrentQueue<api::Image_t>(10);
ConcurrentQueue<api::Image_t>* pResultsOutputQueue = new ConcurrentQueue<api::Image_t>(10);
// Load Analytic
api::Analytic* pAnalytic = NULL;
PluginLoader<api::Analytic> loader;
string sPathToAnalyticPlugin = analytic_plugin_dir_path;
if(*sPathToAnalyticPlugin.rbegin() != '/') // last char
{
sPathToAnalyticPlugin.append("/");
}
sPathToAnalyticPlugin.append(analytic_plugin_filename);
try
{
loader.loadPlugin(sPathToAnalyticPlugin);
pAnalytic = loader.createPluginInstance();
}
catch(opencctv::Exception &e)
{
cerr << "Failed to load the Analytic plugin: " << sPathToAnalyticPlugin << endl;
return -1;
}
// Create Consumer thread to write results into a txt file
string sOutputFilename = analytic_plugin_dir_path;
if(*sOutputFilename.rbegin() != '/') // last char
{
sOutputFilename.append("/");
}
sOutputFilename.append(currentDateTime());
sOutputFilename.append(".txt");
ConsumerThread resultsConsumer(sOutputFilename, pResultsOutputQueue);
boost::thread* pConsumerThread = new boost::thread(resultsConsumer);
// Create Producer thread to read frames from input video files
ProducerThread imageProducer(input_video_file_path, pImageInputQueue);
boost::thread* pProducerThread = new boost::thread(imageProducer);
// Run analytic
try
{
if(pAnalytic->init(analytic_plugin_dir_path))
{
pAnalytic->process(pImageInputQueue, pResultsOutputQueue);
}
else
{
cerr << "Failed to initialize the Analytic. init() failed.";
}
}
catch(exception &e)
{
cerr << "Exception in Analytic: " << e.what() << endl;
}
return 0;
}