Commit c27da1c0c2aaafcfaabb6360698852d4cd7acde6

Authored by bklare
1 parent 5a1540b1

Crop image from bounding box

openbr/plugins/imgproc/cropimage.cpp 0 → 100644
  1 +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2 + * Copyright 2015 Rank One Computing 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 Crops the image using the bounding box. If multiple bounding boxes existing
  27 + * all such crops will be appended.
  28 + * \author Brendan Klare \cite bklare
  29 + */
  30 +class CropImageTransform : public UntrainableTransform
  31 +{
  32 + Q_OBJECT
  33 +
  34 + void project(const Template &src, Template &dst) const
  35 + {
  36 + for (int i = 0; i < src.file.rects().size(); i++)
  37 + dst += Mat(src, Rect(src.file.rects()[i].x(), src.file.rects()[i].y(), src.file.rects()[i].width(), src.file.rects()[i].height()));
  38 + }
  39 +};
  40 +
  41 +BR_REGISTER(Transform, CropImageTransform)
  42 +
  43 +} // namespace br
  44 +
  45 +#include "imgproc/cropimage.moc"
... ...