mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -27,9 +27,6 @@ endif()
|
||||
project(cpp_samples)
|
||||
ocv_include_modules_recurse(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
||||
file(GLOB_RECURSE cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
if(NOT HAVE_OPENGL)
|
||||
ocv_list_filterout(cpp_samples Qt_sample)
|
||||
endif()
|
||||
if(NOT HAVE_opencv_cudaarithm OR NOT HAVE_opencv_cudafilters)
|
||||
ocv_list_filterout(cpp_samples "/gpu/")
|
||||
endif()
|
||||
|
||||
@@ -86,6 +86,7 @@ int main(int argc, char** argv)
|
||||
Net net = readNet(parser.get<String>("model"), parser.get<String>("config"), parser.get<String>("framework"));
|
||||
net.setPreferableBackend(parser.get<int>("backend"));
|
||||
net.setPreferableTarget(parser.get<int>("target"));
|
||||
std::vector<String> outNames = net.getUnconnectedOutLayersNames();
|
||||
|
||||
// Create a window
|
||||
static const std::string kWinName = "Deep learning object detection in OpenCV";
|
||||
@@ -125,7 +126,7 @@ int main(int argc, char** argv)
|
||||
net.setInput(imInfo, "im_info");
|
||||
}
|
||||
std::vector<Mat> outs;
|
||||
net.forward(outs, getOutputsNames(net));
|
||||
net.forward(outs, outNames);
|
||||
|
||||
postprocess(frame, outs, net);
|
||||
|
||||
@@ -265,17 +266,3 @@ void callback(int pos, void*)
|
||||
{
|
||||
confThreshold = pos * 0.01f;
|
||||
}
|
||||
|
||||
std::vector<String> getOutputsNames(const Net& net)
|
||||
{
|
||||
static std::vector<String> names;
|
||||
if (names.empty())
|
||||
{
|
||||
std::vector<int> outLayers = net.getUnconnectedOutLayers();
|
||||
std::vector<String> layersNames = net.getLayerNames();
|
||||
names.resize(outLayers.size());
|
||||
for (size_t i = 0; i < outLayers.size(); ++i)
|
||||
names[i] = layersNames[outLayers[i] - 1];
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
@@ -78,14 +78,11 @@ if args.classes:
|
||||
net = cv.dnn.readNet(args.model, args.config, args.framework)
|
||||
net.setPreferableBackend(args.backend)
|
||||
net.setPreferableTarget(args.target)
|
||||
outNames = net.getUnconnectedOutLayersNames()
|
||||
|
||||
confThreshold = args.thr
|
||||
nmsThreshold = args.nms
|
||||
|
||||
def getOutputsNames(net):
|
||||
layersNames = net.getLayerNames()
|
||||
return [layersNames[i[0] - 1] for i in net.getUnconnectedOutLayers()]
|
||||
|
||||
def postprocess(frame, outs):
|
||||
frameHeight = frame.shape[0]
|
||||
frameWidth = frame.shape[1]
|
||||
@@ -213,7 +210,7 @@ while cv.waitKey(1) < 0:
|
||||
if net.getLayer(0).outputNameToIndex('im_info') != -1: # Faster-RCNN or R-FCN
|
||||
frame = cv.resize(frame, (inpWidth, inpHeight))
|
||||
net.setInput(np.array([[inpHeight, inpWidth, 1.6]], dtype=np.float32), 'im_info')
|
||||
outs = net.forward(getOutputsNames(net))
|
||||
outs = net.forward(outNames)
|
||||
|
||||
postprocess(frame, outs)
|
||||
|
||||
|
||||
@@ -50,9 +50,6 @@ if((CV_GCC OR CV_CLANG) AND NOT ENABLE_NOISY_WARNINGS)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
|
||||
endif()
|
||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
if(NOT HAVE_OPENGL)
|
||||
ocv_list_filterout(all_samples "opengl")
|
||||
endif()
|
||||
foreach(sample_filename ${all_samples})
|
||||
ocv_define_sample(tgt ${sample_filename} gpu)
|
||||
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
if(APPLE)
|
||||
return()
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
find_package(X11 QUIET)
|
||||
if(NOT X11_FOUND)
|
||||
message(STATUS "OpenGL samples require development files for libX11")
|
||||
return()
|
||||
endif()
|
||||
include_directories(${X11_INCLUDE_DIR})
|
||||
set(SAMPLE_LINKER_DEPS "${X11_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
SET(OPENCV_OPENGL_SAMPLES_REQUIRED_DEPS
|
||||
@@ -24,10 +18,16 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
||||
project(opengl_samples)
|
||||
ocv_include_modules_recurse(${OPENCV_OPENGL_SAMPLES_REQUIRED_DEPS})
|
||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
if(NOT X11_FOUND)
|
||||
ocv_list_filterout(all_samples "opengl_interop")
|
||||
endif()
|
||||
foreach(sample_filename ${all_samples})
|
||||
ocv_define_sample(tgt ${sample_filename} opengl)
|
||||
ocv_target_link_libraries(${tgt}
|
||||
${OPENCV_LINKER_LIBS} ${OPENCV_OPENGL_SAMPLES_REQUIRED_DEPS} ${SAMPLE_LINKER_DEPS})
|
||||
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_OPENGL_SAMPLES_REQUIRED_DEPS})
|
||||
if(sample_filename STREQUAL "opengl_interop.cpp")
|
||||
ocv_target_link_libraries(${tgt} ${X11_LIBRARIES})
|
||||
ocv_target_include_directories(${tgt} ${X11_INCLUDE_DIR})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user