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
3d41846c
Commit
3d41846c
authored
Oct 24, 2012
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move frame processing into separate class
parent
56517437
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
178 additions
and
0 deletions
+178
-0
objdetect.hpp
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
+22
-0
isf.cpp
modules/objdetect/src/isf.cpp
+156
-0
No files found.
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
View file @
3d41846c
...
@@ -543,6 +543,28 @@ private:
...
@@ -543,6 +543,28 @@ private:
Filds
*
filds
;
Filds
*
filds
;
};
};
class
CV_EXPORTS
IntegralChannels
{
public
:
//! constrictor form resizing factor.
//! Param shr is a resizing factor. Resize is applied before integral sum computing
IntegralChannels
(
const
int
shr
)
:
shrinkage
(
shr
)
{}
//! Appends specified number of hog first order feature integrals into given vector.
//! Param gray is an input 1-chennel gray image.
//! Param integrals is a vector of integrals. Computed from frame frame hog-channels will be appended to it.
//! Param bins is a number of hog-bins
void
createHogBins
(
const
cv
::
Mat
gray
,
std
::
vector
<
cv
::
Mat
>&
integrals
,
int
bins
)
const
;
//! Converts 3-chennel BGR input frame to Luv and append each channel to the integrals.
//! Param frame is an input 3-chennel BGR colored image.
//! Param integrals is a vector of integrals. Computed from frame frame luv-channels will be appended to it.
void
createLuvBins
(
const
cv
::
Mat
frame
,
std
::
vector
<
cv
::
Mat
>&
integrals
)
const
;
private
:
int
shrinkage
;
};
//////////////// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector //////////////
//////////////// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector //////////////
// struct for detection region of interest (ROI)
// struct for detection region of interest (ROI)
...
...
modules/objdetect/src/isf.cpp
0 → 100644
View file @
3d41846c
/*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) 2008-2012, 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 <precomp.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/core/core.hpp>
template
<
typename
T
>
struct
Decimate
{
int
shrinkage
;
Decimate
(
const
int
sr
)
:
shrinkage
(
sr
)
{}
void
operator
()(
const
cv
::
Mat
&
in
,
cv
::
Mat
&
out
)
const
{
int
cols
=
in
.
cols
/
shrinkage
;
int
rows
=
in
.
rows
/
shrinkage
;
out
.
create
(
rows
,
cols
,
in
.
type
());
CV_Assert
(
cols
*
shrinkage
==
in
.
cols
);
CV_Assert
(
rows
*
shrinkage
==
in
.
rows
);
for
(
int
outIdx_y
=
0
;
outIdx_y
<
rows
;
++
outIdx_y
)
{
T
*
outPtr
=
out
.
ptr
<
T
>
(
outIdx_y
);
for
(
int
outIdx_x
=
0
;
outIdx_x
<
cols
;
++
outIdx_x
)
{
// do desimate
int
inIdx_y
=
outIdx_y
*
shrinkage
;
int
inIdx_x
=
outIdx_x
*
shrinkage
;
int
sum
=
0
;
for
(
int
y
=
inIdx_y
;
y
<
inIdx_y
+
shrinkage
;
++
y
)
for
(
int
x
=
inIdx_x
;
x
<
inIdx_x
+
shrinkage
;
++
x
)
sum
+=
in
.
at
<
T
>
(
y
,
x
);
sum
/=
shrinkage
*
shrinkage
;
outPtr
[
outIdx_x
]
=
cv
::
saturate_cast
<
T
>
(
sum
);
}
}
}
};
void
cv
::
IntegralChannels
::
createHogBins
(
const
cv
::
Mat
gray
,
std
::
vector
<
cv
::
Mat
>&
integrals
,
int
bins
)
const
{
CV_Assert
(
gray
.
type
()
==
CV_8UC1
);
int
h
=
gray
.
rows
;
int
w
=
gray
.
cols
;
CV_Assert
(
!
(
w
%
shrinkage
)
&&
!
(
h
%
shrinkage
));
Decimate
<
uchar
>
decimate
(
shrinkage
);
cv
::
Mat
df_dx
,
df_dy
,
mag
,
angle
;
cv
::
Sobel
(
gray
,
df_dx
,
CV_32F
,
1
,
0
,
3
,
0.125
);
cv
::
Sobel
(
gray
,
df_dy
,
CV_32F
,
0
,
1
,
3
,
0.125
);
cv
::
cartToPolar
(
df_dx
,
df_dy
,
mag
,
angle
,
true
);
mag
*=
(
1.
f
/
sqrt
(
2
));
cv
::
Mat
nmag
;
mag
.
convertTo
(
nmag
,
CV_8UC1
);
angle
/=
60.
f
;
std
::
vector
<
cv
::
Mat
>
hist
;
for
(
int
bin
=
0
;
bin
<
bins
;
++
bin
)
hist
.
push_back
(
cv
::
Mat
::
zeros
(
h
,
w
,
CV_8UC1
));
for
(
int
y
=
0
;
y
<
h
;
++
y
)
{
uchar
*
magnitude
=
nmag
.
ptr
<
uchar
>
(
y
);
float
*
ang
=
angle
.
ptr
<
float
>
(
y
);
for
(
int
x
=
0
;
x
<
w
;
++
x
)
{
hist
[
(
int
)
ang
[
x
]
].
ptr
<
uchar
>
(
y
)[
x
]
=
magnitude
[
x
];
}
}
for
(
int
i
=
0
;
i
<
bins
;
++
i
)
{
cv
::
Mat
shrunk
,
sum
;
decimate
(
hist
[
i
],
shrunk
);
cv
::
integral
(
shrunk
,
sum
,
cv
::
noArray
(),
CV_32S
);
integrals
.
push_back
(
sum
);
}
cv
::
Mat
shrMag
;
decimate
(
nmag
,
shrMag
);
cv
::
integral
(
shrMag
,
mag
,
cv
::
noArray
(),
CV_32S
);
integrals
.
push_back
(
mag
);
}
void
cv
::
IntegralChannels
::
createLuvBins
(
const
cv
::
Mat
frame
,
std
::
vector
<
cv
::
Mat
>&
integrals
)
const
{
CV_Assert
(
frame
.
type
()
==
CV_8UC3
);
CV_Assert
(
!
(
frame
.
cols
%
shrinkage
)
&&
!
(
frame
.
rows
%
shrinkage
));
Decimate
<
uchar
>
decimate
(
shrinkage
);
cv
::
Mat
luv
;
cv
::
cvtColor
(
frame
,
luv
,
CV_BGR2Luv
);
std
::
vector
<
cv
::
Mat
>
splited
;
split
(
luv
,
splited
);
for
(
size_t
i
=
0
;
i
<
splited
.
size
();
++
i
)
{
cv
::
Mat
shrunk
,
sum
;
decimate
(
splited
[
i
],
shrunk
);
cv
::
integral
(
shrunk
,
sum
,
cv
::
noArray
(),
CV_32S
);
integrals
.
push_back
(
sum
);
}
}
\ No newline at end of file
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