intmain(int argc, char** argv){ // load model Net net = readNetFromCaffe(model_text_file, modelFile); net.setPreferableBackend(DNN_BACKEND_OPENCV); net.setPreferableTarget(DNN_TARGET_CPU);
VideoCapture cap = VideoCapture(0); Mat frame; while (true) { bool ret = cap.read(frame); if (!ret) break; Mat blobImage = blobFromImage(frame, 0.007843, Size(300, 300), Scalar(127.5, 127.5, 127.5), true, false); printf("blobImage width : %d, height: %d\n", blobImage.size[2], blobImage.size[3]);
net.setInput(blobImage, "data"); Mat detection = net.forward("detection_out"); vector<double> layersTimings; double freq = getTickFrequency() / 1000; double time = net.getPerfProfile(layersTimings) / freq; printf("execute time : %.2f ms\n", time);