1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

This commit is contained in:
Alexander Alekhin
2018-11-10 20:10:57 +00:00
90 changed files with 6261 additions and 6657 deletions
@@ -88,7 +88,7 @@ JNIEXPORT jlong JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker
//trackingDetector->setMinObjectSize(Size(faceSize, faceSize));
}
}
catch(cv::Exception& e)
catch(const cv::Exception& e)
{
LOGD("nativeCreateObject caught cv::Exception: %s", e.what());
jclass je = jenv->FindClass("org/opencv/core/CvException");
@@ -121,7 +121,7 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_
delete (DetectorAgregator*)thiz;
}
}
catch(cv::Exception& e)
catch(const cv::Exception& e)
{
LOGD("nativeestroyObject caught cv::Exception: %s", e.what());
jclass je = jenv->FindClass("org/opencv/core/CvException");
@@ -147,7 +147,7 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_
{
((DetectorAgregator*)thiz)->tracker->run();
}
catch(cv::Exception& e)
catch(const cv::Exception& e)
{
LOGD("nativeStart caught cv::Exception: %s", e.what());
jclass je = jenv->FindClass("org/opencv/core/CvException");
@@ -173,7 +173,7 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_
{
((DetectorAgregator*)thiz)->tracker->stop();
}
catch(cv::Exception& e)
catch(const cv::Exception& e)
{
LOGD("nativeStop caught cv::Exception: %s", e.what());
jclass je = jenv->FindClass("org/opencv/core/CvException");
@@ -203,7 +203,7 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_
//((DetectorAgregator*)thiz)->trackingDetector->setMinObjectSize(Size(faceSize, faceSize));
}
}
catch(cv::Exception& e)
catch(const cv::Exception& e)
{
LOGD("nativeStop caught cv::Exception: %s", e.what());
jclass je = jenv->FindClass("org/opencv/core/CvException");
@@ -233,7 +233,7 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_
((DetectorAgregator*)thiz)->tracker->getObjects(RectFaces);
*((Mat*)faces) = Mat(RectFaces, true);
}
catch(cv::Exception& e)
catch(const cv::Exception& e)
{
LOGD("nativeCreateObject caught cv::Exception: %s", e.what());
jclass je = jenv->FindClass("org/opencv/core/CvException");
@@ -63,11 +63,11 @@ void dumpCLinfo()
i, name.c_str(), (type==CL_DEVICE_TYPE_GPU ? "GPU" : "CPU"), extensions.c_str() );
}
}
catch(cl::Error& e)
catch(const cl::Error& e)
{
LOGE( "OpenCL info: error while gathering OpenCL info: %s (%d)", e.what(), e.err() );
}
catch(std::exception& e)
catch(const std::exception& e)
{
LOGE( "OpenCL info: error while gathering OpenCL info: %s", e.what() );
}
@@ -130,11 +130,11 @@ extern "C" void initCL()
LOGE("Can't init OpenCV with OpenCL TAPI");
haveOpenCL = true;
}
catch(cl::Error& e)
catch(const cl::Error& e)
{
LOGE("cl::Error: %s (%d)", e.what(), e.err());
}
catch(std::exception& e)
catch(const std::exception& e)
{
LOGE("std::exception: %s", e.what());
}
+1 -1
View File
@@ -192,7 +192,7 @@ int main(int argc, char *argv[])
imshow("Original", img);
waitKey();
}
catch (Exception& e)
catch (const Exception& e)
{
cout << "Feature : " << *itDesc << "\n";
cout << e.msg << endl;
+1 -1
View File
@@ -523,7 +523,7 @@ int main(int argc, char *argv[])
imshow(winName, result);
imshow("Original", img);
}
catch (Exception& e)
catch (const Exception& e)
{
cout << "Feature: " << *itDesc << "\n";
cout << e.msg << endl;
+1 -1
View File
@@ -177,7 +177,7 @@ int showImageQRCodeDetect(string in, string out)
{
imwrite(out, color_src, compression_params);
}
catch (cv::Exception& ex)
catch (const cv::Exception& ex)
{
cout << "Exception converting image to PNG format: ";
cout << ex.what() << '\n';
+4 -4
View File
@@ -147,15 +147,15 @@ int main(int argc, char *argv[])
desMethCmp.push_back(cumSumDist2);
waitKey();
}
catch (Exception& e)
{
catch (const Exception& e)
{
cout << e.msg << endl;
cout << "Cumulative distance cannot be computed." << endl;
desMethCmp.push_back(-1);
}
}
}
}
catch (Exception& e)
catch (const Exception& e)
{
cout << "Feature : " << *itDesc << "\n";
if (itMatcher != typeAlgoMatch.end())
+1 -1
View File
@@ -141,7 +141,7 @@ int main(int argc, char** argv)
// Read in the data. This can fail if not valid
try {
read_imgList(imgList, images);
} catch (cv::Exception& e) {
} catch (const cv::Exception& e) {
cerr << "Error opening file \"" << imgList << "\". Reason: " << e.msg << endl;
exit(1);
}
+1 -1
View File
@@ -260,7 +260,7 @@ public:
}
} // try
catch (cv::Exception& e)
catch (const cv::Exception& e)
{
std::cerr << "Exception: " << e.what() << std::endl;
return 10;
+1 -1
View File
@@ -378,7 +378,7 @@ public:
}
} // try
catch (cv::Exception& e)
catch (const cv::Exception& e)
{
std::cerr << "Exception: " << e.what() << std::endl;
cleanup();
+1 -1
View File
@@ -225,7 +225,7 @@ public:
}
} // try
catch (cv::Exception& e)
catch (const cv::Exception& e)
{
std::cerr << "Exception: " << e.what() << std::endl;
return 10;
+1 -1
View File
@@ -226,7 +226,7 @@ public:
} // try
catch (cv::Exception& e)
catch (const cv::Exception& e)
{
std::cerr << "Exception: " << e.what() << std::endl;
return 10;
+1 -1
View File
@@ -158,7 +158,7 @@ int d3d_app(int argc, char** argv, std::string& title)
return app.run();
}
catch (cv::Exception& e)
catch (const cv::Exception& e)
{
std::cerr << "Exception: " << e.what() << std::endl;
return 10;
+19 -5
View File
@@ -32,6 +32,8 @@ def createFasterRCNNGraph(modelPath, configPath, outputPath):
width_stride = float(grid_anchor_generator['width_stride'][0])
height_stride = float(grid_anchor_generator['height_stride'][0])
features_stride = float(config['feature_extractor'][0]['first_stage_features_stride'][0])
first_stage_nms_iou_threshold = float(config['first_stage_nms_iou_threshold'][0])
first_stage_max_proposals = int(config['first_stage_max_proposals'][0])
print('Number of classes: %d' % num_classes)
print('Scales: %s' % str(scales))
@@ -47,7 +49,8 @@ def createFasterRCNNGraph(modelPath, configPath, outputPath):
removeIdentity(graph_def)
def to_remove(name, op):
return name.startswith(scopesToIgnore) or not name.startswith(scopesToKeep)
return name.startswith(scopesToIgnore) or not name.startswith(scopesToKeep) or \
(name.startswith('CropAndResize') and op != 'CropAndResize')
removeUnusedNodesAndAttrs(to_remove, graph_def)
@@ -114,10 +117,10 @@ def createFasterRCNNGraph(modelPath, configPath, outputPath):
detectionOut.addAttr('num_classes', 2)
detectionOut.addAttr('share_location', True)
detectionOut.addAttr('background_label_id', 0)
detectionOut.addAttr('nms_threshold', 0.7)
detectionOut.addAttr('nms_threshold', first_stage_nms_iou_threshold)
detectionOut.addAttr('top_k', 6000)
detectionOut.addAttr('code_type', "CENTER_SIZE")
detectionOut.addAttr('keep_top_k', 100)
detectionOut.addAttr('keep_top_k', first_stage_max_proposals)
detectionOut.addAttr('clip', False)
graph_def.node.extend([detectionOut])
@@ -147,9 +150,11 @@ def createFasterRCNNGraph(modelPath, configPath, outputPath):
'SecondStageBoxPredictor/Reshape_1/Reshape', [1, -1], graph_def)
# Replace Flatten subgraph onto a single node.
cropAndResizeNodeName = ''
for i in reversed(range(len(graph_def.node))):
if graph_def.node[i].op == 'CropAndResize':
graph_def.node[i].input.insert(1, 'detection_out/clip_by_value')
cropAndResizeNodeName = graph_def.node[i].name
if graph_def.node[i].name == 'SecondStageBoxPredictor/Reshape':
addConstNode('SecondStageBoxPredictor/Reshape/shape2', [1, -1, 4], graph_def)
@@ -159,11 +164,15 @@ def createFasterRCNNGraph(modelPath, configPath, outputPath):
if graph_def.node[i].name in ['SecondStageBoxPredictor/Flatten/flatten/Shape',
'SecondStageBoxPredictor/Flatten/flatten/strided_slice',
'SecondStageBoxPredictor/Flatten/flatten/Reshape/shape']:
'SecondStageBoxPredictor/Flatten/flatten/Reshape/shape',
'SecondStageBoxPredictor/Flatten_1/flatten/Shape',
'SecondStageBoxPredictor/Flatten_1/flatten/strided_slice',
'SecondStageBoxPredictor/Flatten_1/flatten/Reshape/shape']:
del graph_def.node[i]
for node in graph_def.node:
if node.name == 'SecondStageBoxPredictor/Flatten/flatten/Reshape':
if node.name == 'SecondStageBoxPredictor/Flatten/flatten/Reshape' or \
node.name == 'SecondStageBoxPredictor/Flatten_1/flatten/Reshape':
node.op = 'Flatten'
node.input.pop()
@@ -171,6 +180,11 @@ def createFasterRCNNGraph(modelPath, configPath, outputPath):
'SecondStageBoxPredictor/BoxEncodingPredictor/MatMul']:
node.addAttr('loc_pred_transposed', True)
if node.name.startswith('MaxPool2D'):
assert(node.op == 'MaxPool')
assert(cropAndResizeNodeName)
node.input = [cropAndResizeNodeName]
################################################################################
### Postprocessing
################################################################################
+1 -1
View File
@@ -676,7 +676,7 @@ int App::initVideoSource()
throw std::runtime_error(std::string("specify video source"));
}
catch (std::exception e)
catch (const std::exception e)
{
cerr << "ERROR: " << e.what() << std::endl;
return -1;
+2 -2
View File
@@ -325,7 +325,7 @@ public:
}
catch (cv::Exception& e)
catch (const cv::Exception& e)
{
std::cerr << "Exception: " << e.what() << std::endl;
return 10;
@@ -520,7 +520,7 @@ int main(int argc, char** argv)
app.create();
return app.run();
}
catch (cv::Exception& e)
catch (const cv::Exception& e)
{
cerr << "Exception: " << e.what() << endl;
return 10;
+1 -1
View File
@@ -86,7 +86,7 @@ def main():
frame[y:,x+w:][:SZ, :SZ] = bin_norm[...,np.newaxis]
sample = preprocess_hog([bin_norm])
digit = model.predict(sample)[0]
digit = model.predict(sample)[1].ravel()
cv.putText(frame, '%d'%digit, (x, y), cv.FONT_HERSHEY_PLAIN, 1.0, (200, 0, 0), thickness = 1)
+1 -1
View File
@@ -256,7 +256,7 @@ int main(int argc, char** argv)
std::cout << "Interop " << (doInterop ? "ON " : "OFF") << ": processing time, msec: " << time << std::endl;
}
catch (std::exception& ex)
catch (const std::exception& ex)
{
std::cerr << "ERROR: " << ex.what() << std::endl;
}