Commit 2e58b63537d6c4d5487dcf808eae33ff6498359d

Authored by Josh Klontz
1 parent 0eadbbd1

remove integral

openbr/plugins/imgproc/integral.cpp deleted
1   -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2   - * Copyright 2012 The MITRE Corporation *
3   - * *
4   - * Licensed under the Apache License, Version 2.0 (the "License"); *
5   - * you may not use this file except in compliance with the License. *
6   - * You may obtain a copy of the License at *
7   - * *
8   - * http://www.apache.org/licenses/LICENSE-2.0 *
9   - * *
10   - * Unless required by applicable law or agreed to in writing, software *
11   - * distributed under the License is distributed on an "AS IS" BASIS, *
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13   - * See the License for the specific language governing permissions and *
14   - * limitations under the License. *
15   - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16   -
17   -#include <opencv2/imgproc/imgproc.hpp>
18   -
19   -#include <openbr/plugins/openbr_internal.h>
20   -
21   -namespace br
22   -{
23   -
24   -/*!
25   - * \ingroup transforms
26   - * \brief Computes integral image.
27   - * \author Josh Klontz \cite jklontz
28   - */
29   -class IntegralTransform : public UntrainableTransform
30   -{
31   - Q_OBJECT
32   -
33   - void project(const Template &src, Template &dst) const
34   - {
35   - cv::integral(src, dst);
36   - }
37   -};
38   -
39   -BR_REGISTER(Transform, IntegralTransform)
40   -
41   -} // namespace br
42   -
43   -#include "imgproc/integral.moc"
openbr/plugins/imgproc/integralhist.cpp deleted
1   -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2   - * Copyright 2012 The MITRE Corporation *
3   - * *
4   - * Licensed under the Apache License, Version 2.0 (the "License"); *
5   - * you may not use this file except in compliance with the License. *
6   - * You may obtain a copy of the License at *
7   - * *
8   - * http://www.apache.org/licenses/LICENSE-2.0 *
9   - * *
10   - * Unless required by applicable law or agreed to in writing, software *
11   - * distributed under the License is distributed on an "AS IS" BASIS, *
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13   - * See the License for the specific language governing permissions and *
14   - * limitations under the License. *
15   - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16   -
17   -#include <openbr/plugins/openbr_internal.h>
18   -
19   -using namespace cv;
20   -
21   -namespace br
22   -{
23   -
24   -/*!
25   - * \ingroup transforms
26   - * \brief An integral histogram
27   - * \author Josh Klontz \cite jklontz
28   - */
29   -class IntegralHistTransform : public UntrainableTransform
30   -{
31   - Q_OBJECT
32   - Q_PROPERTY(int bins READ get_bins WRITE set_bins RESET reset_bins STORED false)
33   - Q_PROPERTY(int radius READ get_radius WRITE set_radius RESET reset_radius STORED false)
34   - BR_PROPERTY(int, bins, 256)
35   - BR_PROPERTY(int, radius, 16)
36   -
37   - void project(const Template &src, Template &dst) const
38   - {
39   - const Mat &m = src.m();
40   - if (m.type() != CV_8UC1) qFatal("IntegralHist requires 8UC1 matrices.");
41   -
42   - Mat integral(m.rows/radius+1, (m.cols/radius+1)*bins, CV_32SC1);
43   - integral.setTo(0);
44   - for (int i=1; i<integral.rows; i++) {
45   - for (int j=1; j<integral.cols; j+=bins) {
46   - for (int k=0; k<bins; k++) integral.at<qint32>(i, j+k) += integral.at<qint32>(i-1, j +k);
47   - for (int k=0; k<bins; k++) integral.at<qint32>(i, j+k) += integral.at<qint32>(i , j-bins+k);
48   - for (int k=0; k<bins; k++) integral.at<qint32>(i, j+k) -= integral.at<qint32>(i-1, j-bins+k);
49   - for (int k=0; k<radius; k++)
50   - for (int l=0; l<radius; l++)
51   - integral.at<qint32>(i, j+m.at<quint8>((i-1)*radius+k,(j/bins-1)*radius+l))++;
52   - }
53   - }
54   - dst = integral;
55   - }
56   -};
57   -
58   -BR_REGISTER(Transform, IntegralHistTransform)
59   -
60   -} // namespace br
61   -
62   -#include "imgproc/integralhist.moc"
openbr/plugins/imgproc/integralsampler.cpp deleted
1   -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2   - * Copyright 2012 The MITRE Corporation *
3   - * *
4   - * Licensed under the Apache License, Version 2.0 (the "License"); *
5   - * you may not use this file except in compliance with the License. *
6   - * You may obtain a copy of the License at *
7   - * *
8   - * http://www.apache.org/licenses/LICENSE-2.0 *
9   - * *
10   - * Unless required by applicable law or agreed to in writing, software *
11   - * distributed under the License is distributed on an "AS IS" BASIS, *
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13   - * See the License for the specific language governing permissions and *
14   - * limitations under the License. *
15   - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16   -
17   -#include <Eigen/Dense>
18   -
19   -#include <openbr/plugins/openbr_internal.h>
20   -
21   -using namespace cv;
22   -
23   -namespace br
24   -{
25   -
26   -/*!
27   - * \ingroup transforms
28   - * \brief Sliding window feature extraction from a multi-channel integral image.
29   - * \author Josh Klontz \cite jklontz
30   - */
31   -class IntegralSamplerTransform : public UntrainableTransform
32   -{
33   - Q_OBJECT
34   - Q_PROPERTY(int scales READ get_scales WRITE set_scales RESET reset_scales STORED false)
35   - Q_PROPERTY(float scaleFactor READ get_scaleFactor WRITE set_scaleFactor RESET reset_scaleFactor STORED false)
36   - Q_PROPERTY(float stepFactor READ get_stepFactor WRITE set_stepFactor RESET reset_stepFactor STORED false)
37   - Q_PROPERTY(int minSize READ get_minSize WRITE set_minSize RESET reset_minSize STORED false)
38   - Q_PROPERTY(bool secondOrder READ get_secondOrder WRITE set_secondOrder RESET reset_secondOrder STORED false)
39   - BR_PROPERTY(int, scales, 6)
40   - BR_PROPERTY(float, scaleFactor, 2)
41   - BR_PROPERTY(float, stepFactor, 0.75)
42   - BR_PROPERTY(int, minSize, 8)
43   - BR_PROPERTY(bool, secondOrder, false)
44   -
45   - void project(const Template &src, Template &dst) const
46   - {
47   - typedef Eigen::Map< const Eigen::Matrix<qint32,Eigen::Dynamic,1> > InputDescriptor;
48   - typedef Eigen::Map< const Eigen::Matrix<float,Eigen::Dynamic,1> > SecondOrderInputDescriptor;
49   - typedef Eigen::Map< Eigen::Matrix<float,Eigen::Dynamic,1> > OutputDescriptor;
50   -
51   - const Mat &m = src.m();
52   - if (m.depth() != CV_32S) qFatal("Expected CV_32S matrix depth.");
53   - const int channels = m.channels();
54   - const int rowStep = channels * m.cols;
55   -
56   - int descriptors = 0;
57   - float idealSize = min(m.rows, m.cols)-1;
58   - for (int scale=0; scale<scales; scale++) {
59   - const int currentSize(idealSize);
60   - const int numDown = 1+(m.rows-currentSize-1)/int(idealSize*stepFactor);
61   - const int numAcross = 1+(m.cols-currentSize-1)/int(idealSize*stepFactor);
62   - descriptors += numDown*numAcross;
63   - if (secondOrder) descriptors += numDown*(numAcross-1) + (numDown-1)*numAcross;
64   - idealSize /= scaleFactor;
65   - if (idealSize < minSize) break;
66   - }
67   - Mat n(descriptors, channels, CV_32FC1);
68   -
69   - const qint32 *dataIn = (qint32*)m.data;
70   - float *dataOut = (float*)n.data;
71   - idealSize = min(m.rows, m.cols)-1;
72   - int index = 0;
73   - for (int scale=0; scale<scales; scale++) {
74   - const int currentSize(idealSize);
75   - const int currentStep(idealSize*stepFactor);
76   - for (int i=currentSize; i<m.rows; i+=currentStep) {
77   - for (int j=currentSize; j<m.cols; j+=currentStep) {
78   - InputDescriptor a(dataIn+((i-currentSize)*rowStep+(j-currentSize)*channels), channels, 1);
79   - InputDescriptor b(dataIn+((i-currentSize)*rowStep+ j *channels), channels, 1);
80   - InputDescriptor c(dataIn+(i *rowStep+(j-currentSize)*channels), channels, 1);
81   - InputDescriptor d(dataIn+(i *rowStep+ j *channels), channels, 1);
82   - OutputDescriptor y(dataOut+(index*channels), channels, 1);
83   - y = (d-b-c+a).cast<float>()/(currentSize*currentSize);
84   - index++;
85   - }
86   - }
87   - if (secondOrder) {
88   - const int numDown = 1+(m.rows-currentSize-1)/currentStep;
89   - const int numAcross = 1+(m.cols-currentSize-1)/currentStep;
90   - const float *dataIn = n.ptr<float>(index - numDown*numAcross);
91   - for (int i=0; i<numDown; i++) {
92   - for (int j=0; j<numAcross; j++) {
93   - SecondOrderInputDescriptor a(dataIn + (i*numAcross+j)*channels, channels, 1);
94   - if (j < numAcross-1) {
95   - OutputDescriptor y(dataOut+(index*channels), channels, 1);
96   - y = a - SecondOrderInputDescriptor(dataIn + (i*numAcross+j+1)*channels, channels, 1);
97   - index++;
98   - }
99   - if (i < numDown-1) {
100   - OutputDescriptor y(dataOut+(index*channels), channels, 1);
101   - y = a - SecondOrderInputDescriptor(dataIn + ((i+1)*numAcross+j)*channels, channels, 1);
102   - index++;
103   - }
104   - }
105   - }
106   - }
107   - idealSize /= scaleFactor;
108   - if (idealSize < minSize) break;
109   - }
110   -
111   - if (descriptors != index)
112   - qFatal("Allocated %d descriptors but computed %d.", descriptors, index);
113   -
114   - dst.m() = n;
115   - }
116   -};
117   -
118   -BR_REGISTER(Transform, IntegralSamplerTransform)
119   -
120   -} // namespace br
121   -
122   -#include "imgproc/integralsampler.moc"