本文整理汇总了C++中ImageProcessor::process_image方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageProcessor::process_image方法的具体用法?C++ ImageProcessor::process_image怎么用?C++ ImageProcessor::process_image使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageProcessor
的用法示例。
在下文中一共展示了ImageProcessor::process_image方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_video
void test_video() {
VideoCapture cap(CV_CAP_ANY);
ImageProcessor processor;
ImageLoader loader;
NeuralNetwork net;
net.load(NET_FILE_NAME);
//net.visualize_hidden_units(1, 50);
if (!cap.isOpened()) {
cout << "Failed to initialize camera\n";
return;
}
namedWindow("CameraCapture");
namedWindow("ProcessedCapture");
cv::Mat frame;
while (true) {
cap >> frame;
cv::Mat processedFrame = processor.process_image(frame);
if(processedFrame.rows * processedFrame.cols == INPUT_LAYER_SIZE) {
mat input = loader.to_arma_mat(processedFrame);
int label = net.predict(input);
if(label == 0)
putText(frame, "A", Point(500, 300), FONT_HERSHEY_SCRIPT_SIMPLEX, 2, Scalar::all(0), 3, 8);
else if(label == 1)
putText(frame, "E", Point(500, 300), FONT_HERSHEY_SCRIPT_SIMPLEX, 2, Scalar::all(0), 3, 8);
else if(label == 2)
putText(frame, "I", Point(500, 300), FONT_HERSHEY_SCRIPT_SIMPLEX, 2, Scalar::all(0), 3, 8);
else if(label == 3)
putText(frame, "O", Point(500, 300), FONT_HERSHEY_SCRIPT_SIMPLEX, 2, Scalar::all(0), 3, 8);
else if(label == 4)
putText(frame, "U", Point(500, 300), FONT_HERSHEY_SCRIPT_SIMPLEX, 2, Scalar::all(0), 3, 8);
}
imshow("CameraCapture", frame);
imshow("ProcessedCapture", processedFrame);
int key = waitKey(5);
if(key == 13) {
imwrite("captura.jpg", frame);
}
if (key == 27)
break;
}
destroyAllWindows();
}
示例2: main
int main( int argc, char** argv )
{
if(argc == 3)
{
ImageProcessor* proc = new ImageProcessor(argv[2]);
VideoCapture cap;
if(!cap.open(argv[1]))
{
cout << ERROR_STR << "Failed to open " << argv[1] << endl;
return -1;
}
namedWindow("Video output", 1);
namedWindow("Input", 1);
namedWindow("Settings", 1);
createTrackbar("hi", "Settings", &hi, 255);
createTrackbar("lo", "Settings", &lo, 255);
//createTrackbar("min_hue", "Settings", &minhue, 180);
//createTrackbar("max_hue", "Settings", &maxhue, 180);
createTrackbar("sat", "Settings", &minsat, 255);
createTrackbar("val", "Settings", &minval, 255);
namedWindow("Found circles", 1);
for(;;)
{
Mat curFrame;
cap >> curFrame;
if (curFrame.empty())
{
cout << STATUS_STR << "Frame is empty" << endl;
break;
}
else
{
//resize(curFrame, curFrame, Size(), 0.4, 0.4, INTER_AREA);
Mat fr = proc->process_image(curFrame);
imshow("Video output", fr);
imshow("Input", curFrame);
// cout << "hi = " << hi << " lo = " << lo << endl;
if(fr.empty())
{
cout << STATUS_STR << "Processed frame is empty" << endl;
break;
}
}
cvWaitKey(5);
if(waitKey(30) >= 0)
break;
}
}