Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
f126f371
Commit
f126f371
authored
Jan 14, 2015
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move CUDA object detection algorithms to separate module
parent
b2a5e66f
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
624 additions
and
270 deletions
+624
-270
CMakeLists.txt
modules/cuda/CMakeLists.txt
+1
-1
cuda.hpp
modules/cuda/include/opencv2/cuda.hpp
+0
-263
perf_precomp.hpp
modules/cuda/perf/perf_precomp.hpp
+0
-1
precomp.hpp
modules/cuda/src/precomp.hpp
+0
-1
test_precomp.hpp
modules/cuda/test/test_precomp.hpp
+0
-1
CMakeLists.txt
modules/cudaobjdetect/CMakeLists.txt
+9
-0
cudaobjdetect.hpp
modules/cudaobjdetect/include/opencv2/cudaobjdetect.hpp
+329
-0
perf_main.cpp
modules/cudaobjdetect/perf/perf_main.cpp
+47
-0
perf_objdetect.cpp
modules/cudaobjdetect/perf/perf_objdetect.cpp
+0
-0
perf_precomp.hpp
modules/cudaobjdetect/perf/perf_precomp.hpp
+64
-0
cascadeclassifier.cpp
modules/cudaobjdetect/src/cascadeclassifier.cpp
+0
-0
hog.cu
modules/cudaobjdetect/src/cuda/hog.cu
+0
-0
lbp.cu
modules/cudaobjdetect/src/cuda/lbp.cu
+0
-0
lbp.hpp
modules/cudaobjdetect/src/cuda/lbp.hpp
+0
-0
hog.cpp
modules/cudaobjdetect/src/hog.cpp
+0
-0
precomp.hpp
modules/cudaobjdetect/src/precomp.hpp
+62
-0
test_main.cpp
modules/cudaobjdetect/test/test_main.cpp
+45
-0
test_objdetect.cpp
modules/cudaobjdetect/test/test_objdetect.cpp
+0
-0
test_precomp.hpp
modules/cudaobjdetect/test/test_precomp.hpp
+64
-0
CMakeLists.txt
samples/gpu/CMakeLists.txt
+1
-1
cascadeclassifier.cpp
samples/gpu/cascadeclassifier.cpp
+1
-1
hog.cpp
samples/gpu/hog.cpp
+1
-1
No files found.
modules/cuda/CMakeLists.txt
View file @
f126f371
...
...
@@ -6,4 +6,4 @@ set(the_description "CUDA-accelerated Computer Vision")
ocv_warnings_disable
(
CMAKE_CXX_FLAGS /wd4127 /wd4100 /wd4324 /wd4512 /wd4515 -Wundef -Wmissing-declarations -Wshadow -Wunused-parameter
)
ocv_define_module
(
cuda opencv_calib3d opencv_
objdetect opencv_
cudaarithm opencv_cudawarping OPTIONAL opencv_cudalegacy
)
ocv_define_module
(
cuda opencv_calib3d opencv_cudaarithm opencv_cudawarping OPTIONAL opencv_cudalegacy
)
modules/cuda/include/opencv2/cuda.hpp
View file @
f126f371
...
...
@@ -53,274 +53,11 @@
@addtogroup cuda
@{
@defgroup cuda_calib3d Camera Calibration and 3D Reconstruction
@defgroup cuda_objdetect Object Detection
@}
*/
namespace
cv
{
namespace
cuda
{
//////////////// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector //////////////
//! @addtogroup cuda_objdetect
//! @{
struct
CV_EXPORTS
HOGConfidence
{
double
scale
;
std
::
vector
<
Point
>
locations
;
std
::
vector
<
double
>
confidences
;
std
::
vector
<
double
>
part_scores
[
4
];
};
/** @brief The class implements Histogram of Oriented Gradients (@cite Dalal2005) object detector.
Interfaces of all methods are kept similar to the CPU HOG descriptor and detector analogues as much
as possible.
@note
- An example applying the HOG descriptor for people detection can be found at
opencv_source_code/samples/cpp/peopledetect.cpp
- A CUDA example applying the HOG descriptor for people detection can be found at
opencv_source_code/samples/gpu/hog.cpp
- (Python) An example applying the HOG descriptor for people detection can be found at
opencv_source_code/samples/python2/peopledetect.py
*/
struct
CV_EXPORTS
HOGDescriptor
{
enum
{
DEFAULT_WIN_SIGMA
=
-
1
};
enum
{
DEFAULT_NLEVELS
=
64
};
enum
{
DESCR_FORMAT_ROW_BY_ROW
,
DESCR_FORMAT_COL_BY_COL
};
/** @brief Creates the HOG descriptor and detector.
@param win_size Detection window size. Align to block size and block stride.
@param block_size Block size in pixels. Align to cell size. Only (16,16) is supported for now.
@param block_stride Block stride. It must be a multiple of cell size.
@param cell_size Cell size. Only (8, 8) is supported for now.
@param nbins Number of bins. Only 9 bins per cell are supported for now.
@param win_sigma Gaussian smoothing window parameter.
@param threshold_L2hys L2-Hys normalization method shrinkage.
@param gamma_correction Flag to specify whether the gamma correction preprocessing is required or
not.
@param nlevels Maximum number of detection window increases.
*/
HOGDescriptor
(
Size
win_size
=
Size
(
64
,
128
),
Size
block_size
=
Size
(
16
,
16
),
Size
block_stride
=
Size
(
8
,
8
),
Size
cell_size
=
Size
(
8
,
8
),
int
nbins
=
9
,
double
win_sigma
=
DEFAULT_WIN_SIGMA
,
double
threshold_L2hys
=
0.2
,
bool
gamma_correction
=
true
,
int
nlevels
=
DEFAULT_NLEVELS
);
/** @brief Returns the number of coefficients required for the classification.
*/
size_t
getDescriptorSize
()
const
;
/** @brief Returns the block histogram size.
*/
size_t
getBlockHistogramSize
()
const
;
/** @brief Sets coefficients for the linear SVM classifier.
*/
void
setSVMDetector
(
const
std
::
vector
<
float
>&
detector
);
/** @brief Returns coefficients of the classifier trained for people detection (for default window size).
*/
static
std
::
vector
<
float
>
getDefaultPeopleDetector
();
/** @brief Returns coefficients of the classifier trained for people detection (for 48x96 windows).
*/
static
std
::
vector
<
float
>
getPeopleDetector48x96
();
/** @brief Returns coefficients of the classifier trained for people detection (for 64x128 windows).
*/
static
std
::
vector
<
float
>
getPeopleDetector64x128
();
/** @brief Performs object detection without a multi-scale window.
@param img Source image. CV_8UC1 and CV_8UC4 types are supported for now.
@param found_locations Left-top corner points of detected objects boundaries.
@param hit_threshold Threshold for the distance between features and SVM classifying plane.
Usually it is 0 and should be specfied in the detector coefficients (as the last free
coefficient). But if the free coefficient is omitted (which is allowed), you can specify it
manually here.
@param win_stride Window stride. It must be a multiple of block stride.
@param padding Mock parameter to keep the CPU interface compatibility. It must be (0,0).
*/
void
detect
(
const
GpuMat
&
img
,
std
::
vector
<
Point
>&
found_locations
,
double
hit_threshold
=
0
,
Size
win_stride
=
Size
(),
Size
padding
=
Size
());
/** @brief Performs object detection with a multi-scale window.
@param img Source image. See cuda::HOGDescriptor::detect for type limitations.
@param found_locations Detected objects boundaries.
@param hit_threshold Threshold for the distance between features and SVM classifying plane. See
cuda::HOGDescriptor::detect for details.
@param win_stride Window stride. It must be a multiple of block stride.
@param padding Mock parameter to keep the CPU interface compatibility. It must be (0,0).
@param scale0 Coefficient of the detection window increase.
@param group_threshold Coefficient to regulate the similarity threshold. When detected, some
objects can be covered by many rectangles. 0 means not to perform grouping. See groupRectangles .
*/
void
detectMultiScale
(
const
GpuMat
&
img
,
std
::
vector
<
Rect
>&
found_locations
,
double
hit_threshold
=
0
,
Size
win_stride
=
Size
(),
Size
padding
=
Size
(),
double
scale0
=
1.05
,
int
group_threshold
=
2
);
void
computeConfidence
(
const
GpuMat
&
img
,
std
::
vector
<
Point
>&
hits
,
double
hit_threshold
,
Size
win_stride
,
Size
padding
,
std
::
vector
<
Point
>&
locations
,
std
::
vector
<
double
>&
confidences
);
void
computeConfidenceMultiScale
(
const
GpuMat
&
img
,
std
::
vector
<
Rect
>&
found_locations
,
double
hit_threshold
,
Size
win_stride
,
Size
padding
,
std
::
vector
<
HOGConfidence
>
&
conf_out
,
int
group_threshold
);
/** @brief Returns block descriptors computed for the whole image.
@param img Source image. See cuda::HOGDescriptor::detect for type limitations.
@param win_stride Window stride. It must be a multiple of block stride.
@param descriptors 2D array of descriptors.
@param descr_format Descriptor storage format:
- **DESCR_FORMAT_ROW_BY_ROW** - Row-major order.
- **DESCR_FORMAT_COL_BY_COL** - Column-major order.
The function is mainly used to learn the classifier.
*/
void
getDescriptors
(
const
GpuMat
&
img
,
Size
win_stride
,
GpuMat
&
descriptors
,
int
descr_format
=
DESCR_FORMAT_COL_BY_COL
);
Size
win_size
;
Size
block_size
;
Size
block_stride
;
Size
cell_size
;
int
nbins
;
double
win_sigma
;
double
threshold_L2hys
;
bool
gamma_correction
;
int
nlevels
;
protected
:
void
computeBlockHistograms
(
const
GpuMat
&
img
);
void
computeGradient
(
const
GpuMat
&
img
,
GpuMat
&
grad
,
GpuMat
&
qangle
);
double
getWinSigma
()
const
;
bool
checkDetectorSize
()
const
;
static
int
numPartsWithin
(
int
size
,
int
part_size
,
int
stride
);
static
Size
numPartsWithin
(
Size
size
,
Size
part_size
,
Size
stride
);
// Coefficients of the separating plane
float
free_coef
;
GpuMat
detector
;
// Results of the last classification step
GpuMat
labels
,
labels_buf
;
Mat
labels_host
;
// Results of the last histogram evaluation step
GpuMat
block_hists
,
block_hists_buf
;
// Gradients conputation results
GpuMat
grad
,
qangle
,
grad_buf
,
qangle_buf
;
// returns subbuffer with required size, reallocates buffer if nessesary.
static
GpuMat
getBuffer
(
const
Size
&
sz
,
int
type
,
GpuMat
&
buf
);
static
GpuMat
getBuffer
(
int
rows
,
int
cols
,
int
type
,
GpuMat
&
buf
);
std
::
vector
<
GpuMat
>
image_scales
;
};
//////////////////////////// CascadeClassifier ////////////////////////////
/** @brief Cascade classifier class used for object detection. Supports HAAR and LBP cascades. :
@note
- A cascade classifier example can be found at
opencv_source_code/samples/gpu/cascadeclassifier.cpp
- A Nvidea API specific cascade classifier example can be found at
opencv_source_code/samples/gpu/cascadeclassifier_nvidia_api.cpp
*/
class
CV_EXPORTS
CascadeClassifier_CUDA
{
public
:
CascadeClassifier_CUDA
();
/** @brief Loads the classifier from a file. Cascade type is detected automatically by constructor parameter.
@param filename Name of the file from which the classifier is loaded. Only the old haar classifier
(trained by the haar training application) and NVIDIA's nvbin are supported for HAAR and only new
type of OpenCV XML cascade supported for LBP.
*/
CascadeClassifier_CUDA
(
const
String
&
filename
);
~
CascadeClassifier_CUDA
();
/** @brief Checks whether the classifier is loaded or not.
*/
bool
empty
()
const
;
/** @brief Loads the classifier from a file. The previous content is destroyed.
@param filename Name of the file from which the classifier is loaded. Only the old haar classifier
(trained by the haar training application) and NVIDIA's nvbin are supported for HAAR and only new
type of OpenCV XML cascade supported for LBP.
*/
bool
load
(
const
String
&
filename
);
/** @brief Destroys the loaded classifier.
*/
void
release
();
/** @overload */
int
detectMultiScale
(
const
GpuMat
&
image
,
GpuMat
&
objectsBuf
,
double
scaleFactor
=
1.2
,
int
minNeighbors
=
4
,
Size
minSize
=
Size
());
/** @brief Detects objects of different sizes in the input image.
@param image Matrix of type CV_8U containing an image where objects should be detected.
@param objectsBuf Buffer to store detected objects (rectangles). If it is empty, it is allocated
with the default size. If not empty, the function searches not more than N objects, where
N = sizeof(objectsBufer's data)/sizeof(cv::Rect).
@param maxObjectSize Maximum possible object size. Objects larger than that are ignored. Used for
second signature and supported only for LBP cascades.
@param scaleFactor Parameter specifying how much the image size is reduced at each image scale.
@param minNeighbors Parameter specifying how many neighbors each candidate rectangle should have
to retain it.
@param minSize Minimum possible object size. Objects smaller than that are ignored.
The detected objects are returned as a list of rectangles.
The function returns the number of detected objects, so you can retrieve them as in the following
example:
@code
cuda::CascadeClassifier_CUDA cascade_gpu(...);
Mat image_cpu = imread(...)
GpuMat image_gpu(image_cpu);
GpuMat objbuf;
int detections_number = cascade_gpu.detectMultiScale( image_gpu,
objbuf, 1.2, minNeighbors);
Mat obj_host;
// download only detected number of rectangles
objbuf.colRange(0, detections_number).download(obj_host);
Rect* faces = obj_host.ptr<Rect>();
for(int i = 0; i < detections_num; ++i)
cv::rectangle(image_cpu, faces[i], Scalar(255));
imshow("Faces", image_cpu);
@endcode
@sa CascadeClassifier::detectMultiScale
*/
int
detectMultiScale
(
const
GpuMat
&
image
,
GpuMat
&
objectsBuf
,
Size
maxObjectSize
,
Size
minSize
=
Size
(),
double
scaleFactor
=
1.1
,
int
minNeighbors
=
4
);
bool
findLargestObject
;
bool
visualizeInPlace
;
Size
getClassifierSize
()
const
;
private
:
struct
CascadeClassifierImpl
;
CascadeClassifierImpl
*
impl
;
struct
HaarCascade
;
struct
LbpCascade
;
friend
class
CascadeClassifier_CUDA_LBP
;
};
//! @} cuda_objdetect
//////////////////////////// Labeling ////////////////////////////
//! @addtogroup cuda
...
...
modules/cuda/perf/perf_precomp.hpp
View file @
f126f371
...
...
@@ -56,7 +56,6 @@
#include "opencv2/cuda.hpp"
#include "opencv2/calib3d.hpp"
#include "opencv2/objdetect.hpp"
#ifdef GTEST_CREATE_SHARED_LIBRARY
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
...
...
modules/cuda/src/precomp.hpp
View file @
f126f371
...
...
@@ -47,7 +47,6 @@
#include "opencv2/cudaarithm.hpp"
#include "opencv2/cudawarping.hpp"
#include "opencv2/calib3d.hpp"
#include "opencv2/objdetect.hpp"
#include "opencv2/core/private.cuda.hpp"
#include "opencv2/core/utility.hpp"
...
...
modules/cuda/test/test_precomp.hpp
View file @
f126f371
...
...
@@ -60,7 +60,6 @@
#include "opencv2/core.hpp"
#include "opencv2/core/opengl.hpp"
#include "opencv2/calib3d.hpp"
#include "opencv2/objdetect.hpp"
#include "cvconfig.h"
...
...
modules/cudaobjdetect/CMakeLists.txt
0 → 100644
View file @
f126f371
if
(
IOS
OR
(
NOT HAVE_CUDA AND NOT BUILD_CUDA_STUBS
))
ocv_module_disable
(
cudaobjdetect
)
endif
()
set
(
the_description
"CUDA-accelerated Object Detection"
)
ocv_warnings_disable
(
CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef -Wmissing-declarations -Wshadow
)
ocv_define_module
(
cudaobjdetect opencv_objdetect opencv_cudaarithm opencv_cudawarping OPTIONAL opencv_cudalegacy
)
modules/cudaobjdetect/include/opencv2/cudaobjdetect.hpp
0 → 100644
View file @
f126f371
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef __OPENCV_CUDAOBJDETECT_HPP__
#define __OPENCV_CUDAOBJDETECT_HPP__
#ifndef __cplusplus
# error cudaobjdetect.hpp header must be compiled as C++
#endif
#include "opencv2/core/cuda.hpp"
/**
@addtogroup cuda
@{
@defgroup cuda_objdetect Object Detection
@}
*/
namespace
cv
{
namespace
cuda
{
//! @addtogroup cuda_objdetect
//! @{
//
// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector
//
struct
CV_EXPORTS
HOGConfidence
{
double
scale
;
std
::
vector
<
Point
>
locations
;
std
::
vector
<
double
>
confidences
;
std
::
vector
<
double
>
part_scores
[
4
];
};
/** @brief The class implements Histogram of Oriented Gradients (@cite Dalal2005) object detector.
Interfaces of all methods are kept similar to the CPU HOG descriptor and detector analogues as much
as possible.
@note
- An example applying the HOG descriptor for people detection can be found at
opencv_source_code/samples/cpp/peopledetect.cpp
- A CUDA example applying the HOG descriptor for people detection can be found at
opencv_source_code/samples/gpu/hog.cpp
- (Python) An example applying the HOG descriptor for people detection can be found at
opencv_source_code/samples/python2/peopledetect.py
*/
struct
CV_EXPORTS
HOGDescriptor
{
enum
{
DEFAULT_WIN_SIGMA
=
-
1
};
enum
{
DEFAULT_NLEVELS
=
64
};
enum
{
DESCR_FORMAT_ROW_BY_ROW
,
DESCR_FORMAT_COL_BY_COL
};
/** @brief Creates the HOG descriptor and detector.
@param win_size Detection window size. Align to block size and block stride.
@param block_size Block size in pixels. Align to cell size. Only (16,16) is supported for now.
@param block_stride Block stride. It must be a multiple of cell size.
@param cell_size Cell size. Only (8, 8) is supported for now.
@param nbins Number of bins. Only 9 bins per cell are supported for now.
@param win_sigma Gaussian smoothing window parameter.
@param threshold_L2hys L2-Hys normalization method shrinkage.
@param gamma_correction Flag to specify whether the gamma correction preprocessing is required or
not.
@param nlevels Maximum number of detection window increases.
*/
HOGDescriptor
(
Size
win_size
=
Size
(
64
,
128
),
Size
block_size
=
Size
(
16
,
16
),
Size
block_stride
=
Size
(
8
,
8
),
Size
cell_size
=
Size
(
8
,
8
),
int
nbins
=
9
,
double
win_sigma
=
DEFAULT_WIN_SIGMA
,
double
threshold_L2hys
=
0.2
,
bool
gamma_correction
=
true
,
int
nlevels
=
DEFAULT_NLEVELS
);
/** @brief Returns the number of coefficients required for the classification.
*/
size_t
getDescriptorSize
()
const
;
/** @brief Returns the block histogram size.
*/
size_t
getBlockHistogramSize
()
const
;
/** @brief Sets coefficients for the linear SVM classifier.
*/
void
setSVMDetector
(
const
std
::
vector
<
float
>&
detector
);
/** @brief Returns coefficients of the classifier trained for people detection (for default window size).
*/
static
std
::
vector
<
float
>
getDefaultPeopleDetector
();
/** @brief Returns coefficients of the classifier trained for people detection (for 48x96 windows).
*/
static
std
::
vector
<
float
>
getPeopleDetector48x96
();
/** @brief Returns coefficients of the classifier trained for people detection (for 64x128 windows).
*/
static
std
::
vector
<
float
>
getPeopleDetector64x128
();
/** @brief Performs object detection without a multi-scale window.
@param img Source image. CV_8UC1 and CV_8UC4 types are supported for now.
@param found_locations Left-top corner points of detected objects boundaries.
@param hit_threshold Threshold for the distance between features and SVM classifying plane.
Usually it is 0 and should be specfied in the detector coefficients (as the last free
coefficient). But if the free coefficient is omitted (which is allowed), you can specify it
manually here.
@param win_stride Window stride. It must be a multiple of block stride.
@param padding Mock parameter to keep the CPU interface compatibility. It must be (0,0).
*/
void
detect
(
const
GpuMat
&
img
,
std
::
vector
<
Point
>&
found_locations
,
double
hit_threshold
=
0
,
Size
win_stride
=
Size
(),
Size
padding
=
Size
());
/** @brief Performs object detection with a multi-scale window.
@param img Source image. See cuda::HOGDescriptor::detect for type limitations.
@param found_locations Detected objects boundaries.
@param hit_threshold Threshold for the distance between features and SVM classifying plane. See
cuda::HOGDescriptor::detect for details.
@param win_stride Window stride. It must be a multiple of block stride.
@param padding Mock parameter to keep the CPU interface compatibility. It must be (0,0).
@param scale0 Coefficient of the detection window increase.
@param group_threshold Coefficient to regulate the similarity threshold. When detected, some
objects can be covered by many rectangles. 0 means not to perform grouping. See groupRectangles .
*/
void
detectMultiScale
(
const
GpuMat
&
img
,
std
::
vector
<
Rect
>&
found_locations
,
double
hit_threshold
=
0
,
Size
win_stride
=
Size
(),
Size
padding
=
Size
(),
double
scale0
=
1.05
,
int
group_threshold
=
2
);
void
computeConfidence
(
const
GpuMat
&
img
,
std
::
vector
<
Point
>&
hits
,
double
hit_threshold
,
Size
win_stride
,
Size
padding
,
std
::
vector
<
Point
>&
locations
,
std
::
vector
<
double
>&
confidences
);
void
computeConfidenceMultiScale
(
const
GpuMat
&
img
,
std
::
vector
<
Rect
>&
found_locations
,
double
hit_threshold
,
Size
win_stride
,
Size
padding
,
std
::
vector
<
HOGConfidence
>
&
conf_out
,
int
group_threshold
);
/** @brief Returns block descriptors computed for the whole image.
@param img Source image. See cuda::HOGDescriptor::detect for type limitations.
@param win_stride Window stride. It must be a multiple of block stride.
@param descriptors 2D array of descriptors.
@param descr_format Descriptor storage format:
- **DESCR_FORMAT_ROW_BY_ROW** - Row-major order.
- **DESCR_FORMAT_COL_BY_COL** - Column-major order.
The function is mainly used to learn the classifier.
*/
void
getDescriptors
(
const
GpuMat
&
img
,
Size
win_stride
,
GpuMat
&
descriptors
,
int
descr_format
=
DESCR_FORMAT_COL_BY_COL
);
Size
win_size
;
Size
block_size
;
Size
block_stride
;
Size
cell_size
;
int
nbins
;
double
win_sigma
;
double
threshold_L2hys
;
bool
gamma_correction
;
int
nlevels
;
protected
:
void
computeBlockHistograms
(
const
GpuMat
&
img
);
void
computeGradient
(
const
GpuMat
&
img
,
GpuMat
&
grad
,
GpuMat
&
qangle
);
double
getWinSigma
()
const
;
bool
checkDetectorSize
()
const
;
static
int
numPartsWithin
(
int
size
,
int
part_size
,
int
stride
);
static
Size
numPartsWithin
(
Size
size
,
Size
part_size
,
Size
stride
);
// Coefficients of the separating plane
float
free_coef
;
GpuMat
detector
;
// Results of the last classification step
GpuMat
labels
,
labels_buf
;
Mat
labels_host
;
// Results of the last histogram evaluation step
GpuMat
block_hists
,
block_hists_buf
;
// Gradients conputation results
GpuMat
grad
,
qangle
,
grad_buf
,
qangle_buf
;
// returns subbuffer with required size, reallocates buffer if nessesary.
static
GpuMat
getBuffer
(
const
Size
&
sz
,
int
type
,
GpuMat
&
buf
);
static
GpuMat
getBuffer
(
int
rows
,
int
cols
,
int
type
,
GpuMat
&
buf
);
std
::
vector
<
GpuMat
>
image_scales
;
};
//
// CascadeClassifier
//
/** @brief Cascade classifier class used for object detection. Supports HAAR and LBP cascades. :
@note
- A cascade classifier example can be found at
opencv_source_code/samples/gpu/cascadeclassifier.cpp
- A Nvidea API specific cascade classifier example can be found at
opencv_source_code/samples/gpu/cascadeclassifier_nvidia_api.cpp
*/
class
CV_EXPORTS
CascadeClassifier_CUDA
{
public
:
CascadeClassifier_CUDA
();
/** @brief Loads the classifier from a file. Cascade type is detected automatically by constructor parameter.
@param filename Name of the file from which the classifier is loaded. Only the old haar classifier
(trained by the haar training application) and NVIDIA's nvbin are supported for HAAR and only new
type of OpenCV XML cascade supported for LBP.
*/
CascadeClassifier_CUDA
(
const
String
&
filename
);
~
CascadeClassifier_CUDA
();
/** @brief Checks whether the classifier is loaded or not.
*/
bool
empty
()
const
;
/** @brief Loads the classifier from a file. The previous content is destroyed.
@param filename Name of the file from which the classifier is loaded. Only the old haar classifier
(trained by the haar training application) and NVIDIA's nvbin are supported for HAAR and only new
type of OpenCV XML cascade supported for LBP.
*/
bool
load
(
const
String
&
filename
);
/** @brief Destroys the loaded classifier.
*/
void
release
();
/** @overload */
int
detectMultiScale
(
const
GpuMat
&
image
,
GpuMat
&
objectsBuf
,
double
scaleFactor
=
1.2
,
int
minNeighbors
=
4
,
Size
minSize
=
Size
());
/** @brief Detects objects of different sizes in the input image.
@param image Matrix of type CV_8U containing an image where objects should be detected.
@param objectsBuf Buffer to store detected objects (rectangles). If it is empty, it is allocated
with the default size. If not empty, the function searches not more than N objects, where
N = sizeof(objectsBufer's data)/sizeof(cv::Rect).
@param maxObjectSize Maximum possible object size. Objects larger than that are ignored. Used for
second signature and supported only for LBP cascades.
@param scaleFactor Parameter specifying how much the image size is reduced at each image scale.
@param minNeighbors Parameter specifying how many neighbors each candidate rectangle should have
to retain it.
@param minSize Minimum possible object size. Objects smaller than that are ignored.
The detected objects are returned as a list of rectangles.
The function returns the number of detected objects, so you can retrieve them as in the following
example:
@code
cuda::CascadeClassifier_CUDA cascade_gpu(...);
Mat image_cpu = imread(...)
GpuMat image_gpu(image_cpu);
GpuMat objbuf;
int detections_number = cascade_gpu.detectMultiScale( image_gpu,
objbuf, 1.2, minNeighbors);
Mat obj_host;
// download only detected number of rectangles
objbuf.colRange(0, detections_number).download(obj_host);
Rect* faces = obj_host.ptr<Rect>();
for(int i = 0; i < detections_num; ++i)
cv::rectangle(image_cpu, faces[i], Scalar(255));
imshow("Faces", image_cpu);
@endcode
@sa CascadeClassifier::detectMultiScale
*/
int
detectMultiScale
(
const
GpuMat
&
image
,
GpuMat
&
objectsBuf
,
Size
maxObjectSize
,
Size
minSize
=
Size
(),
double
scaleFactor
=
1.1
,
int
minNeighbors
=
4
);
bool
findLargestObject
;
bool
visualizeInPlace
;
Size
getClassifierSize
()
const
;
private
:
struct
CascadeClassifierImpl
;
CascadeClassifierImpl
*
impl
;
struct
HaarCascade
;
struct
LbpCascade
;
friend
class
CascadeClassifier_CUDA_LBP
;
};
//! @}
}}
// namespace cv { namespace cuda {
#endif
/* __OPENCV_CUDAOBJDETECT_HPP__ */
modules/cudaobjdetect/perf/perf_main.cpp
0 → 100644
View file @
f126f371
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "perf_precomp.hpp"
using
namespace
perf
;
CV_PERF_TEST_CUDA_MAIN
(
cudaobjdetect
)
modules/cuda/perf/perf_objdetect.cpp
→
modules/cuda
objdetect
/perf/perf_objdetect.cpp
View file @
f126f371
File moved
modules/cudaobjdetect/perf/perf_precomp.hpp
0 → 100644
View file @
f126f371
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wextra"
# endif
#endif
#ifndef __OPENCV_PERF_PRECOMP_HPP__
#define __OPENCV_PERF_PRECOMP_HPP__
#include "opencv2/ts.hpp"
#include "opencv2/ts/cuda_perf.hpp"
#include "opencv2/cudaobjdetect.hpp"
#include "opencv2/objdetect.hpp"
#ifdef GTEST_CREATE_SHARED_LIBRARY
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
#endif
#endif
modules/cuda/src/cascadeclassifier.cpp
→
modules/cuda
objdetect
/src/cascadeclassifier.cpp
View file @
f126f371
File moved
modules/cuda/src/cuda/hog.cu
→
modules/cuda
objdetect
/src/cuda/hog.cu
View file @
f126f371
File moved
modules/cuda/src/cuda/lbp.cu
→
modules/cuda
objdetect
/src/cuda/lbp.cu
View file @
f126f371
File moved
modules/cuda/src/cuda/lbp.hpp
→
modules/cuda
objdetect
/src/cuda/lbp.hpp
View file @
f126f371
File moved
modules/cuda/src/hog.cpp
→
modules/cuda
objdetect
/src/hog.cpp
View file @
f126f371
File moved
modules/cudaobjdetect/src/precomp.hpp
0 → 100644
View file @
f126f371
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#include <limits>
#include "opencv2/cudaobjdetect.hpp"
#include "opencv2/cudaarithm.hpp"
#include "opencv2/cudawarping.hpp"
#include "opencv2/objdetect.hpp"
#include "opencv2/core/private.cuda.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/opencv_modules.hpp"
#ifdef HAVE_OPENCV_CUDALEGACY
# include "opencv2/cudalegacy/private.hpp"
#endif
#endif
/* __OPENCV_PRECOMP_H__ */
modules/cudaobjdetect/test/test_main.cpp
0 → 100644
View file @
f126f371
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "test_precomp.hpp"
CV_CUDA_TEST_MAIN
(
"gpu"
)
modules/cuda/test/test_objdetect.cpp
→
modules/cuda
objdetect
/test/test_objdetect.cpp
View file @
f126f371
File moved
modules/cudaobjdetect/test/test_precomp.hpp
0 → 100644
View file @
f126f371
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wextra"
# endif
#endif
#ifndef __OPENCV_TEST_PRECOMP_HPP__
#define __OPENCV_TEST_PRECOMP_HPP__
#include <fstream>
#include "opencv2/ts.hpp"
#include "opencv2/ts/cuda_test.hpp"
#include "opencv2/cudaobjdetect.hpp"
#include "opencv2/objdetect.hpp"
#include "cvconfig.h"
#endif
samples/gpu/CMakeLists.txt
View file @
f126f371
...
...
@@ -3,7 +3,7 @@ SET(OPENCV_CUDA_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc op
opencv_calib3d opencv_cuda opencv_superres
opencv_cudaarithm opencv_cudafilters opencv_cudawarping opencv_cudaimgproc
opencv_cudafeatures2d opencv_cudaoptflow opencv_cudabgsegm
opencv_cudastereo opencv_cudalegacy
)
opencv_cudastereo opencv_cudalegacy
opencv_cudaobjdetect
)
ocv_check_dependencies
(
${
OPENCV_CUDA_SAMPLES_REQUIRED_DEPS
}
)
...
...
samples/gpu/cascadeclassifier.cpp
View file @
f126f371
...
...
@@ -9,7 +9,7 @@
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/cuda.hpp"
#include "opencv2/cuda
objdetect
.hpp"
#include "opencv2/cudaimgproc.hpp"
#include "opencv2/cudawarping.hpp"
...
...
samples/gpu/hog.cpp
View file @
f126f371
...
...
@@ -5,7 +5,7 @@
#include <iomanip>
#include <stdexcept>
#include <opencv2/core/utility.hpp>
#include "opencv2/cuda.hpp"
#include "opencv2/cuda
objdetect
.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/objdetect.hpp"
#include "opencv2/imgproc.hpp"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment