diff --git a/openbr/plugins/gui/drawopticalflow.cpp b/openbr/plugins/gui/drawopticalflow.cpp deleted file mode 100644 index b864a09..0000000 --- a/openbr/plugins/gui/drawopticalflow.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright 2012 The MITRE Corporation * - * * - * Licensed under the Apache License, Version 2.0 (the "License"); * - * you may not use this file except in compliance with the License. * - * You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, software * - * distributed under the License is distributed on an "AS IS" BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * - * See the License for the specific language governing permissions and * - * limitations under the License. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include -#include - -#include - -using namespace cv; - -namespace br -{ - -/*! - * \ingroup transforms - * \brief Draw a line representing the direction and magnitude of optical flow at the specified points. - * \author Austin Blanton \cite imaus10 - */ -class DrawOpticalFlow : public UntrainableTransform -{ - Q_OBJECT - Q_PROPERTY(QString original READ get_original WRITE set_original RESET reset_original STORED false) - BR_PROPERTY(QString, original, "original") - - void project(const Template &src, Template &dst) const - { - const Scalar color(0,255,0); - Mat flow = src.m(); - dst = src; - if (!dst.file.contains(original)) qFatal("The original img must be saved in the metadata with SaveMat."); - dst.m() = dst.file.get(original); - dst.file.remove(original); - foreach (const Point2f &pt, OpenCVUtils::toPoints(dst.file.points())) { - Point2f dxy = flow.at(pt.y, pt.x); - Point2f newPt(pt.x+dxy.x, pt.y+dxy.y); - line(dst.m(), pt, newPt, color); - } - } -}; - -BR_REGISTER(Transform, DrawOpticalFlow) - -} // namespace br - -#include "gui/drawopticalflow.moc" diff --git a/openbr/plugins/imgproc/sift.cpp b/openbr/plugins/imgproc/sift.cpp deleted file mode 100644 index 5c62327..0000000 --- a/openbr/plugins/imgproc/sift.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright 2012 The MITRE Corporation * - * * - * Licensed under the Apache License, Version 2.0 (the "License"); * - * you may not use this file except in compliance with the License. * - * You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, software * - * distributed under the License is distributed on an "AS IS" BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * - * See the License for the specific language governing permissions and * - * limitations under the License. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include - -#include - -using namespace cv; - -namespace br -{ - -/*! - * \ingroup transforms - * \brief Specialize wrapper OpenCV SIFT wrapper - * \br_link http://docs.opencv.org/modules/nonfree/doc/feature_detection.html - * \author Josh Klontz \cite jklontz - */ -class SIFTDescriptorTransform : public UntrainableTransform -{ - Q_OBJECT - Q_PROPERTY(int size READ get_size WRITE set_size RESET reset_size STORED false) - Q_PROPERTY(QList sizes READ get_sizes WRITE set_sizes RESET reset_sizes STORED false) - Q_PROPERTY(int nFeatures READ get_nFeatures WRITE set_nFeatures RESET reset_nFeatures STORED false) - Q_PROPERTY(int nOctaveLayers READ get_nOctaveLayers WRITE set_nOctaveLayers RESET reset_nOctaveLayers STORED false) - Q_PROPERTY(double contrastThreshold READ get_contrastThreshold WRITE set_contrastThreshold RESET reset_contrastThreshold STORED false) - Q_PROPERTY(double edgeThreshold READ get_edgeThreshold WRITE set_edgeThreshold RESET reset_edgeThreshold STORED false) - Q_PROPERTY(double sigma READ get_sigma WRITE set_sigma RESET reset_sigma STORED false) - BR_PROPERTY(int, size, 1) - BR_PROPERTY(QList, sizes, QList()) - BR_PROPERTY(int, nFeatures, 0) - BR_PROPERTY(int, nOctaveLayers, 3) - BR_PROPERTY(double, contrastThreshold, 0.04) - BR_PROPERTY(double, edgeThreshold, 10) - BR_PROPERTY(double, sigma, 1.6) - - Ptr sift; - - void init() - { - if (sizes.empty()) - sizes.append(size); - sift = SIFT::create(nFeatures, nOctaveLayers, contrastThreshold, edgeThreshold, sigma); - } - - void project(const Template &src, Template &dst) const - { - std::vector keyPoints; - foreach (const QPointF &val, src.file.points()) - foreach (const int r, sizes) - keyPoints.push_back(KeyPoint(val.x(), val.y(), r)); - - Mat m; - sift->detectAndCompute(src.m(), Mat(), keyPoints, m, true); - m.setTo(0, m<0); // SIFT returns large negative values when it goes off the edge of the image. - dst += m; - } -}; - -BR_REGISTER(Transform, SIFTDescriptorTransform) - -} // namespace br - -#include "imgproc/sift.moc" diff --git a/openbr/plugins/video/opticalflow.cpp b/openbr/plugins/video/opticalflow.cpp deleted file mode 100644 index 32bd3a8..0000000 --- a/openbr/plugins/video/opticalflow.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright 2012 The MITRE Corporation * - * * - * Licensed under the Apache License, Version 2.0 (the "License"); * - * you may not use this file except in compliance with the License. * - * You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, software * - * distributed under the License is distributed on an "AS IS" BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * - * See the License for the specific language governing permissions and * - * limitations under the License. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include -#include - -#include -#include - -using namespace cv; - -namespace br -{ - -/*! - * \ingroup transforms - * \brief Gets a one-channel dense optical flow from two images - * \author Austin Blanton \cite imaus10 - */ -class OpticalFlowTransform : public UntrainableMetaTransform -{ - Q_OBJECT - Q_PROPERTY(double pyr_scale READ get_pyr_scale WRITE set_pyr_scale RESET reset_pyr_scale STORED false) - Q_PROPERTY(int levels READ get_levels WRITE set_levels RESET reset_levels STORED false) - Q_PROPERTY(int winsize READ get_winsize WRITE set_winsize RESET reset_winsize STORED false) - Q_PROPERTY(int iterations READ get_iterations WRITE set_iterations RESET reset_iterations STORED false) - Q_PROPERTY(int poly_n READ get_poly_n WRITE set_poly_n RESET reset_poly_n STORED false) - Q_PROPERTY(double poly_sigma READ get_poly_sigma WRITE set_poly_sigma RESET reset_poly_sigma STORED false) - Q_PROPERTY(int flags READ get_flags WRITE set_flags RESET reset_flags STORED false) - Q_PROPERTY(bool useMagnitude READ get_useMagnitude WRITE set_useMagnitude RESET reset_useMagnitude STORED false) - // these defaults are optimized for KTH - BR_PROPERTY(double, pyr_scale, 0.1) - BR_PROPERTY(int, levels, 1) - BR_PROPERTY(int, winsize, 5) - BR_PROPERTY(int, iterations, 10) - BR_PROPERTY(int, poly_n, 7) - BR_PROPERTY(double, poly_sigma, 1.1) - BR_PROPERTY(int, flags, 0) - BR_PROPERTY(bool, useMagnitude, true) - - void project(const Template &src, Template &dst) const - { - // get the two images put there by AggregateFrames - if (src.size() != 2) qFatal("Optical Flow requires two images."); - Mat prevImg = src[0], nextImg = src[1], flow; - if (src[0].channels() != 1) OpenCVUtils::cvtGray(src[0], prevImg); - if (src[1].channels() != 1) OpenCVUtils::cvtGray(src[1], nextImg); - calcOpticalFlowFarneback(prevImg, nextImg, flow, pyr_scale, levels, winsize, iterations, poly_n, poly_sigma, flags); - - if (useMagnitude) { - // the result is two channels - Mat flowOneCh; - std::vector channels(2); - split(flow, channels); - magnitude(channels[0], channels[1], flowOneCh); - dst += flowOneCh; - } else { - dst += flow; - } - dst.file = src.file; - } -}; - -BR_REGISTER(Transform, OpticalFlowTransform) - -} // namespace br - -#include "video/opticalflow.moc"