3#include "../_cexports/c_minos.h"
5#include "../global.hpp"
7#include "../matrix_2d.hpp"
8#include "../point_2d.hpp"
10#include "../area_2d.hpp"
12#include "search_result.hpp"
29 inline HandleGuard<Minos::TrainingSet>::HandleGuard(
void *handle) noexcept
30 : HandleGuard<Minos::TrainingSet>(handle, [](
void *h) { CVB_CALL_CAPI(
ReleaseObject(h)); })
47 friend class InstanceInfoCollectionGeneric;
48 friend class ImageInstanceInfoCollection;
54 InstanceInfo(
const InstanceInfo &other) =
delete;
55 InstanceInfo &operator=(
const InstanceInfo &other) =
delete;
56 InstanceInfo(InstanceInfo &&other) =
delete;
57 InstanceInfo &operator=(InstanceInfo &&other) =
delete;
58 virtual ~InstanceInfo() =
default;
60 InstanceInfo(
const SharedHandleGuard<TrainingSet> &sguardTrSet, CExports::MTSINSTANCE nativeHandle, PrivateTag)
61 : sguardTrSet_(sguardTrSet)
62 , nativeHandle_(nativeHandle)
74 return static_cast<int>(CVB_CALL_CAPI(InstanceIndex(
Handle())));
85 return Internal::DoHandleCallObjectOut<class Image>(CVB_CALL_CAPI(CreateImageFromInstance(
Handle())));
95 double GetCorrelation ()
const
116 double dX = CVB_CALL_CAPI(InstanceX(
Handle()));
117 double dY = CVB_CALL_CAPI(InstanceY(
Handle()));
138 return nativeHandle_;
142 SharedHandleGuard<TrainingSet> sguardTrSet_;
143 CExports::MTSINSTANCE nativeHandle_;
45 class InstanceInfo {
…};
156 return (lhs.Handle() == rhs.Handle());
169 return (!(lhs == rhs));
175 auto ReadInfos(
const T &collection) ->
std::vector<
decltype(collection.ReadInfo(0))>
177 auto count = collection.Count();
178 std::vector<
decltype(collection.ReadInfo(0))> info;
179 for (
decltype(count) i = 0; i < count; ++i)
181 info.push_back(collection.ReadInfo(i));
187 template <
class Tcol,
class Tobj>
188 int IndexOf(
const Tcol &collection,
const Tobj &obj)
190 auto count = collection.Count();
191 for (
decltype(count) i = 0; i <
count; ++i)
193 auto readInfo = collection.ReadInfo(i);
194 if (*readInfo == obj)
206 class InstanceInfoCollectionGeneric
209 explicit InstanceInfoCollectionGeneric(
const SharedHandleGuard<TrainingSet> &sguard)
214 InstanceInfoCollectionGeneric(
const InstanceInfoCollectionGeneric &other) =
delete;
215 InstanceInfoCollectionGeneric &operator=(
const InstanceInfoCollectionGeneric &other) =
delete;
216 InstanceInfoCollectionGeneric(InstanceInfoCollectionGeneric &&other) =
delete;
217 InstanceInfoCollectionGeneric &operator=(InstanceInfoCollectionGeneric &&other) =
delete;
218 virtual ~InstanceInfoCollectionGeneric() =
default;
240 auto instHandle = GetInstanceNativeHandle(index);
241 if (instHandle ==
nullptr)
243 Utilities::SystemInfo::ThrowLastError();
245 return std::make_unique<InstanceInfo>(shandle_, instHandle, InstanceInfo::PrivateTag{});
256 return Private::ReadInfos(*
this);
270 return Private::IndexOf(*
this, obj);
286 auto count =
Count();
287 for (
decltype(count) i = 0; i < count; ++i)
291 CVB_CALL_CAPI_CHECKED(RemoveMTSInstance(instance.
Handle()));
315 virtual int GetCount()
const = 0;
316 virtual CExports::MTSINSTANCE GetInstanceNativeHandle(
int index)
const = 0;
319 SharedHandleGuard<TrainingSet> shandle_;
206 class InstanceInfoCollectionGeneric {
…};
325 class InstanceInfoCollection :
public InstanceInfoCollectionGeneric
328 explicit InstanceInfoCollection(
const SharedHandleGuard<TrainingSet> &sguard)
329 : InstanceInfoCollectionGeneric(sguard)
330 , collectionParent_(sguard.Handle())
335 int GetCount()
const override
337 return static_cast<int>(CVB_CALL_CAPI(NumMTSInstances(collectionParent_)));
340 CExports::MTSINSTANCE GetInstanceNativeHandle(
int index)
const override
342 return CVB_CALL_CAPI(MTSInstance(collectionParent_, index));
346 CExports::MTSINSTANCE collectionParent_;
325 class InstanceInfoCollection :
public InstanceInfoCollectionGeneric {
…};
352 class ImageInstanceInfoCollection :
public InstanceInfoCollectionGeneric
355 ImageInstanceInfoCollection(
const SharedHandleGuard<TrainingSet> &sguard, CExports::MTSIMAGE collectionParent)
356 : InstanceInfoCollectionGeneric(sguard)
357 , collectionParent_(collectionParent)
376 double dX = location.
X();
377 double dY = location.
Y();
378 CExports::MTSINSTANCE instance =
nullptr;
379 CVB_CALL_CAPI_CHECKED(NewMTSInstanceTyped(collectionParent_, name.c_str(), askForce, dX, dY, instance));
380 if (instance ==
nullptr)
384 return std::make_unique<InstanceInfo>(shandle_, instance, InstanceInfo::PrivateTag{});
388 int GetCount()
const override
390 return static_cast<int>(CVB_CALL_CAPI(NumMTSImageInstances(collectionParent_)));
393 CExports::MTSINSTANCE GetInstanceNativeHandle(
int index)
const override
395 return CVB_CALL_CAPI(MTSImageInstance(collectionParent_, index));
399 CExports::MTSIMAGE collectionParent_;
352 class ImageInstanceInfoCollection :
public InstanceInfoCollectionGeneric {
…};
405 class ModelInstanceInfoCollection :
public InstanceInfoCollectionGeneric
408 ModelInstanceInfoCollection(
const SharedHandleGuard<TrainingSet> &sguard, CExports::MTSMODEL collectionParent)
409 : InstanceInfoCollectionGeneric(sguard)
410 , collectionParent_(collectionParent)
415 int GetCount()
const override
417 return static_cast<int>(CVB_CALL_CAPI(NumMTSModelInstances(collectionParent_)));
420 CExports::MTSINSTANCE GetInstanceNativeHandle(
int index)
const override
422 return CVB_CALL_CAPI(MTSModelInstance(collectionParent_, index));
426 CExports::MTSMODEL collectionParent_;
405 class ModelInstanceInfoCollection :
public InstanceInfoCollectionGeneric {
…};
434 friend class InstanceInfo;
435 friend class ImageInfoCollection;
442 ImageInfo(
const ImageInfo &other) =
delete;
443 ImageInfo &operator=(
const ImageInfo &other) =
delete;
444 ImageInfo(ImageInfo &&other) =
delete;
445 ImageInfo &operator=(ImageInfo &&other) =
delete;
446 virtual ~ImageInfo() =
default;
448 ImageInfo(
const SharedHandleGuard<TrainingSet> &sguardTrSet,
int index, PrivateTag)
449 : sguardTrSet_(sguardTrSet)
450 , nativeHandle_(CVB_CALL_CAPI(MTSImage(sguardTrSet.Handle(), index)))
451 , instances_(sguardTrSet_, nativeHandle_)
453 if (nativeHandle_ ==
nullptr)
455 Utilities::SystemInfo::ThrowLastError();
468 return static_cast<int>(CVB_CALL_CAPI(MTSImageIndex(
Handle())));
479 return Internal::DoBoolCallObjectOut<class Image>([&](
void *&resimg) {
480 resimg = CVB_CALL_CAPI(GetImageFromImage(
Handle()));
495 CVB_CALL_CAPI_CHECKED(TransformMTSImage(
Handle(),
reinterpret_cast<const CExports::TMatrix &
>(matrix)));
508 CExports::RESULTS hSearchResults =
nullptr;
509 CVB_CALL_CAPI_CHECKED(
510 MTSImageCheck(
Handle(), threshold,
static_cast<int>(density * 1000.0),
nullptr,
nullptr, hSearchResults));
511 ReleaseObjectGuard hSearchResHolder(hSearchResults);
512 return Private::SearchResultsToArray(hSearchResults);
537 return nativeHandle_;
541 SharedHandleGuard<TrainingSet> sguardTrSet_;
542 CExports::MTSIMAGE nativeHandle_;
556 return (lhs.Handle() == rhs.Handle());
569 return (!(lhs == rhs));
574 auto imageIndex = CVB_CALL_CAPI(GetImageFromInstance(
Handle()));
575 return std::make_unique<ImageInfo>(sguardTrSet_, CVB_CALL_CAPI(MTSImageIndex(imageIndex)),
576 ImageInfo::PrivateTag{});
582 class ImageInfoCollection
585 explicit ImageInfoCollection(
const SharedHandleGuard<TrainingSet> &sguard)
590 ImageInfoCollection(
const ImageInfoCollection &other) =
delete;
591 ImageInfoCollection &operator=(
const ImageInfoCollection &other) =
delete;
592 ImageInfoCollection(ImageInfoCollection &&other) =
delete;
593 ImageInfoCollection &operator=(ImageInfoCollection &&other) =
delete;
594 virtual ~ImageInfoCollection() =
default;
604 return static_cast<int>(CVB_CALL_CAPI(NumMTSImages(shandle_.Handle())));
616 return std::make_unique<ImageInfo>(shandle_, index, ImageInfo::PrivateTag{});
627 return Private::ReadInfos(*
this);
641 return Private::IndexOf(*
this, obj);
655 auto h = CVB_CALL_CAPI(NewMTSImageIndex(shandle_.Handle(), plane.
Parent().
Handle(), plane.
Plane()));
658 Utilities::SystemInfo::ThrowLastError();
675 auto count =
Count();
676 for (
decltype(count) i = 0; i < count; ++i)
680 CVB_CALL_CAPI_CHECKED(RemoveMTSImage(image.
Handle()));
704 SharedHandleGuard<TrainingSet> shandle_;
582 class ImageInfoCollection {
…};
712 friend class InstanceInfo;
713 friend class ModelInfoCollection;
719 ModelInfo(
const ModelInfo &other) =
delete;
720 ModelInfo &operator=(
const ModelInfo &other) =
delete;
721 ModelInfo(ModelInfo &&other) =
delete;
722 ModelInfo &operator=(ModelInfo &&other) =
delete;
723 virtual ~ModelInfo() =
default;
725 ModelInfo(
const SharedHandleGuard<TrainingSet> &sguardTrSet,
int index, PrivateTag)
726 : sguardTrSet_(sguardTrSet)
727 , nativeHandle_(CVB_CALL_CAPI(MTSModel(sguardTrSet.Handle(), index)))
728 , instances_(sguardTrSet_, nativeHandle_)
730 if (nativeHandle_ ==
nullptr)
732 Utilities::SystemInfo::ThrowLastError();
745 return static_cast<int>(CVB_CALL_CAPI(MTSModelIndex(
Handle())));
756 return Internal::DoBoolCallObjectOut<class Image>([&](
void *&resimg) {
757 resimg = CVB_CALL_CAPI(GetImageFromModel(
Handle()));
769 const Char *name =
nullptr;
770 CVB_CALL_CAPI(GetModelNameTyped(
Handle(), name));
786 CVB_CALL_CAPI_CHECKED(SetModelNameTyped(
Handle(), name.c_str()));
797 CVB_CALL_CAPI_CHECKED(GetModelAdvance(
Handle(), advX, advY));
808 CVB_CALL_CAPI_CHECKED(SetModelAdvance(
Handle(), advanceVector.
X(), advanceVector.
Y()));
819 Area2D featureWindowNative;
820 CVB_CALL_CAPI_CHECKED(GetFeatureWindow(
Handle(),
reinterpret_cast<CExports::TArea &
>(featureWindowNative)));
822 featureWindowNative.
P1().
X(), featureWindowNative.
P2().
Y()));
834 CVB_CALL_CAPI_CHECKED(
SetFeatureWindow(
Handle(),
reinterpret_cast<CExports::TArea &
>(featureWindowNative)));
844 return Image()->CoordinateSystem().Translation();
854 auto cs =
Image()->CoordinateSystem();
855 cs.Translation() = origin;
856 Image()->CoordinateSystem() = cs;
857 CVB_CALL_CAPI_CHECKED(TranslateModelOrigin(
Handle()));
884 double density = 1.0)
886 CExports::RESULTS hSearchResults =
nullptr;
887 CVB_CALL_CAPI_CHECKED(MTSModelImageCheck(
Handle(), trainingSetImage.
Handle(), threshold,
888 static_cast<int>(density * 1000.0),
nullptr,
nullptr, hSearchResults));
889 ReleaseObjectGuard hSearchResHolder(hSearchResults);
890 return Private::SearchResultsToArray(hSearchResults);
904 CExports::RESULTS hSearchResults =
nullptr;
905 CVB_CALL_CAPI_CHECKED(
906 MTSModelCheck(
Handle(), threshold,
static_cast<int>(density * 1000.0),
nullptr,
nullptr, hSearchResults));
907 ReleaseObjectGuard hSearchResHolder(hSearchResults);
908 return Private::SearchResultsToArray(hSearchResults);
923 int left = INT_MAX, top = INT_MAX, right = INT_MAX, bottom = INT_MAX;
925 for (
auto &&i : instances_.ReadInfos())
927 auto loc_x =
static_cast<int>(
std::lround(i->Location().X()));
932 auto loc_y =
static_cast<int>(
std::lround(i->Location().Y()));
937 auto srcimg_w = i->SourceImage()->Image()->Width();
938 if (srcimg_w - loc_x < right)
940 right = srcimg_w - loc_x - 1;
942 auto srcimg_h = i->SourceImage()->Image()->Height();
943 if (srcimg_h - loc_y < bottom)
945 bottom = srcimg_h - loc_y - 1;
951 return Rect<int>(left, top, right, bottom);
967 return Rect<int>(left, top, right, bottom);
979 return nativeHandle_;
983 SharedHandleGuard<TrainingSet> sguardTrSet_;
984 CExports::MTSMODEL nativeHandle_;
998 return (lhs.Handle() == rhs.Handle());
1011 return (!(lhs == rhs));
1016 auto modelIndex = CVB_CALL_CAPI(GetModelFromInstance(nativeHandle_));
1017 return std::make_unique<ModelInfo>(sguardTrSet_, CVB_CALL_CAPI(MTSModelIndex(modelIndex)),
1018 ModelInfo::PrivateTag{});
1024 class ModelInfoCollection
1027 explicit ModelInfoCollection(
const SharedHandleGuard<TrainingSet> &sguard)
1032 ModelInfoCollection(
const ModelInfoCollection &)
noexcept =
delete;
1033 ModelInfoCollection &operator=(
const ModelInfoCollection &)
noexcept =
delete;
1034 ModelInfoCollection(ModelInfoCollection &&other)
noexcept =
delete;
1035 ModelInfoCollection &operator=(ModelInfoCollection &&other)
noexcept =
delete;
1036 ~ModelInfoCollection() =
default;
1046 return static_cast<int>(CVB_CALL_CAPI(NumMTSModels(shandle_.Handle())));
1058 return std::make_unique<ModelInfo>(shandle_, index, ModelInfo::PrivateTag{});
1069 return Private::ReadInfos(*
this);
1083 return Private::IndexOf(*
this, obj);
1095 auto count =
Count();
1096 for (
decltype(count) i = 0; i < count; ++i)
1120 auto instance = CVB_CALL_CAPI(NewMTSModelTyped(image.
Handle(), name.c_str(), location.
X(), location.
Y(),
1121 reinterpret_cast<CExports::TArea &
>(featureWindowNative)));
1122 if (instance ==
nullptr)
1124 Utilities::SystemInfo::ThrowLastError();
1141 auto count =
Count();
1142 for (
decltype(count) i = 0; i < count; ++i)
1146 CVB_CALL_CAPI_CHECKED(RemoveMTSModel(model.
Handle()));
1177 CVB_CALL_CAPI_CHECKED(SetMTSGlobalAdvance(shandle_.Handle(),
true, vec.
X(), vec.
Y()));
1181 SharedHandleGuard<TrainingSet> shandle_;
1024 class ModelInfoCollection {
…};
1193 , fileName_(srcFileName)
1194 , instances_(shandle_)
1201 static CExports::MTS CreateInternal()
1203 CExports::MTS mts = CVB_CALL_CAPI(CreateMTS(3, 0.6));
1206 Utilities::SystemInfo::ThrowLastError();
1212 static CExports::MTS LoadInternal(
const String &fileName)
1214 CExports::MTS mts =
nullptr;
1216 CVB_CALL_CAPI_CHECKED(LoadMTSFileTyped(fileName.c_str(), mts));
1226 : TrainingSet(HandleGuard<TrainingSet>(CreateInternal()))
1236 : TrainingSet(HandleGuard<TrainingSet>(LoadInternal(fileName)), fileName)
1255 return std::make_unique<TrainingSet>(fileName);
1267 return Internal::DoBoolCallObjectOut<TrainingSet>([&](
void *&restset) {
1269 return CVB_CALL_CAPI(MemoryToMTS(
const_cast<void *
>(buffer),
static_cast<long>(size),
1280 template <
class RANGE>
1281 static typename TypedRange<std::unique_ptr<TrainingSet>,
std::uint8_t, RANGE>::type
1284 auto bufferRange = MakeRangeAdapter<std::uint8_t>(buffer);
1285 return FromBuffer(bufferRange.Data(), bufferRange.Size());
1297 return shandle_.Handle();
1310 if (!guard.Handle())
1326 CVB_CALL_CAPI_CHECKED(WriteMTSFileTyped(
Handle(), fileName.c_str()));
1327 fileName_ = fileName;
1338 auto sizeNeeded = CVB_CALL_CAPI(GetMTSSize(
Handle()));
1340 CVB_CALL_CAPI_CHECKED(MTSToMemory(
Handle(), buffer.data(), sizeNeeded));
1353 return Internal::DoBoolCallObjectOut<TrainingSet>([&](
void *&resclas) {
1356 return CVB_CALL_CAPI(
1357 MTSTransform(
Handle(),
reinterpret_cast<const CExports::TMatrix &
>(transformation), resclas));
1372 CExports::RESULTS hSearchResults =
nullptr;
1373 CVB_CALL_CAPI_CHECKED(MTSConsistencyCheck(
Handle(), threshold,
static_cast<int>(density * 1000.0),
nullptr,
1374 nullptr, hSearchResults));
1375 ReleaseObjectGuard hSearchResHolder(hSearchResults);
1376 return Private::SearchResultsToArray(hSearchResults);
1390 return static_cast<int>(CVB_CALL_CAPI(NumMTSClasses(
Handle())));
1413 return instances_.Count();
1462 CExports::cvbbool_t retval =
false;
1463 CVB_CALL_CAPI_CHECKED(GetMTSModified(
Handle(), retval));
1476 CVB_CALL_CAPI_CHECKED(SetMTSModified(
Handle(), isModified));
1486 CExports::cvbdim_t left = 0, top = 0, right = 0, bottom = 0;
1487 CVB_CALL_CAPI_CHECKED(GetMTSExtent(
Handle(), left, top, right, bottom));
1488 return Rect<int>(
static_cast<int>(left),
static_cast<int>(top),
static_cast<int>(right),
1489 static_cast<int>(bottom));
1501 CVB_CALL_CAPI_CHECKED(GetMTSLastFeatureWnd(
Handle(),
reinterpret_cast<CExports::TArea &
>(area)));
1512 const Char *comment =
nullptr;
1513 CVB_CALL_CAPI(MTSCommentTyped(
Handle(), comment));
1514 return (comment !=
nullptr) ?
String(comment) :
String();
1524 CVB_CALL_CAPI_CHECKED(SetMTSCommentTyped(
Handle(), comment.c_str()));
1537 CVB_CALL_CAPI_CHECKED(GetMTSCorelParams(
Handle(), expectationRadius, correlationThreshold));
1538 return expectationRadius;
1562 CVB_CALL_CAPI_CHECKED(GetMTSCorelParams(
Handle(), expectationRadius, correlationThreshold));
1563 return correlationThreshold;
1579 SharedHandleGuard<TrainingSet> shandle_;
1580 mutable String fileName_;
1187 class TrainingSet {
…};
Structure that represents an area of interest in the image.
Definition area_2d.hpp:21
Point2D< double > P2() const noexcept
Gets P2 of the area (top right corner).
Definition area_2d.hpp:137
Point2D< double > P0() const noexcept
Gets P0 of the area (top left corner).
Definition area_2d.hpp:97
Point2D< double > P1() const noexcept
Gets P1 of the area (lower left corner).
Definition area_2d.hpp:117
void * Handle() const noexcept
Classic API image handle.
Definition decl_image.hpp:232
Image plane information container.
Definition decl_image_plane.hpp:29
int Plane() const noexcept
Plane index in the image, to which this plane refers to.
Definition decl_image_plane.hpp:147
const Image & Parent() const noexcept
Image to which this plane descriptor refers to.
Definition detail_image_plane.hpp:87
Double precision 2x2 matrix class.
Definition matrix_2d.hpp:16
Class that maintains the collection of Training Images inside a Minos Training Set.
Definition training_set.hpp:583
void Add(const ImagePlane &plane)
Add a new training set image to the parent training set.
Definition training_set.hpp:653
std::vector< std::unique_ptr< ImageInfo > > ReadInfos() const
Retrieves all the items stored in the collection.
Definition training_set.hpp:625
int Count() const
Retrieves the number of elements in the collection.
Definition training_set.hpp:602
int IndexOf(const ImageInfo &obj) const
Determine the index of an image information object inside this collection.
Definition training_set.hpp:639
bool Remove(const ImageInfo &image)
Remove a training set image along with its instances from the training set.
Definition training_set.hpp:673
std::unique_ptr< ImageInfo > ReadInfo(int index) const
Retrieves the indexed image information block.
Definition training_set.hpp:614
bool RemoveAt(int index)
Remove a training set image along with its instances from the training set.
Definition training_set.hpp:698
Image that has been added to a training set.
Definition training_set.hpp:433
std::vector< SearchResult > CheckConsistency(double threshold, double density=1.0)
Test this image for potentially forgotten instances to be trained.
Definition training_set.hpp:506
void TransformImageAndInstances(Matrix2D matrix)
Transform this image and all instances trained from this image using a 2x2 matrix.
Definition training_set.hpp:491
std::unique_ptr< class Image > Image() const
Image representation of this object.
Definition training_set.hpp:477
int Index() const
Index of this object in the parent's collection.
Definition training_set.hpp:466
ImageInstanceInfoCollection & Instances()
The instances belonging to this model.
Definition training_set.hpp:523
void * Handle() const noexcept
Classic API MTSIMAGE handle.
Definition training_set.hpp:535
Class that maintains the collection of Training Images inside a Minos Training Set.
Definition training_set.hpp:353
std::unique_ptr< InstanceInfo > Add(const String &name, bool askForce, Point2D< double > location)
Extract a new instance from the parent image and added it to the model with the specified name.
Definition training_set.hpp:374
std::unique_ptr< InstanceInfo > ReadInfo(int index) const
Retrieves the indexed instance information block.
Definition training_set.hpp:238
int Count() const
Retrieves the number of elements in the collection.
Definition training_set.hpp:226
std::vector< std::unique_ptr< InstanceInfo > > ReadInfos() const
Retrieves all the items stored in the collection.
Definition training_set.hpp:254
bool Remove(const InstanceInfo &instance)
Remove an instance from the training set.
Definition training_set.hpp:284
int IndexOf(const InstanceInfo &obj) const
Determine the index of an image information object inside this collection.
Definition training_set.hpp:268
bool RemoveAt(int index)
Remove an instance from the training set.
Definition training_set.hpp:309
Class that maintains the collection of Training Images inside a Minos Training Set.
Definition training_set.hpp:326
Instance information that has been added to a training set.
Definition training_set.hpp:46
std::unique_ptr< ModelInfo > Model() const
The Training Set Model into which this instance has been trained.
Definition training_set.hpp:1014
std::unique_ptr< class Image > Image() const
Image representation of this object.
Definition training_set.hpp:83
int Index() const
Index of this object in the parent's collection.
Definition training_set.hpp:72
Point2D< double > Location() const
Position in the SourceImage from which this instance has been extracted.
Definition training_set.hpp:114
std::unique_ptr< ImageInfo > SourceImage() const
Retrieve the correlation between this instance image and the model image.
Definition training_set.hpp:572
void * Handle() const noexcept
Classic API MTSINSTANCE handle.
Definition training_set.hpp:136
Class that maintains the collection of Training Images inside a Minos Training Set.
Definition training_set.hpp:1025
bool Remove(const ModelInfo &model)
Remove a model (and all the instances extracted for that model!) from the training set.
Definition training_set.hpp:1139
std::vector< std::unique_ptr< ModelInfo > > ReadInfos() const
Retrieves all the items stored in the collection.
Definition training_set.hpp:1067
std::unique_ptr< ModelInfo > ReadInfo(int index) const
Retrieves the indexed model information block.
Definition training_set.hpp:1056
int Count() const
Retrieves the number of elements in the collection.
Definition training_set.hpp:1044
bool Contains(const String &name)
Check if the collection contains a model with the specified name.
Definition training_set.hpp:1093
int IndexOf(const ModelInfo &obj) const
Determine the index of an image information object inside this collection.
Definition training_set.hpp:1081
void SetGlobalAdvanceVector(Point2D< double > vec)
Set an advance vector for all available models.
Definition training_set.hpp:1175
void Add(const ImageInfo &image, const String &name, Point2D< double > location, Rect< int > featureWindow)
Add a new model (plus the first instance of that model) to the training set.
Definition training_set.hpp:1116
bool RemoveAt(int index)
Remove a model (and all the instances extracted for that model!) from the training set.
Definition training_set.hpp:1164
Model that has been added to a training set.
Definition training_set.hpp:711
const ModelInstanceInfoCollection & Instances() const
The instances belonging to this model.
Definition training_set.hpp:868
std::vector< SearchResult > CheckConsistency(double threshold, double density=1.0)
Test all images in the parent training set for instances of this model that might have been forgotten...
Definition training_set.hpp:902
Rect< int > GetExtractableArea(const ImageInfo &image) const
Determine the maximum area from which an instance of this model may be extracted from a given trainin...
Definition training_set.hpp:961
Point2D< double > AdvanceVector() const
Get the advance vector associated with this model.
Definition training_set.hpp:794
Point2D< double > Origin() const
Get the origin of the model in terms of coordinates inside the feature window.
Definition training_set.hpp:842
std::vector< SearchResult > CheckConsistency(const ImageInfo &trainingSetImage, double threshold, double density=1.0)
Test the image referenced by trainingSetImage for instances of this model that might have been forgot...
Definition training_set.hpp:883
void SetAdvanceVector(Point2D< double > advanceVector)
Set the advance vector associated with this model.
Definition training_set.hpp:806
std::unique_ptr< class Image > Image() const
Image representation of this object.
Definition training_set.hpp:754
String Name() const
Get the name of the model.
Definition training_set.hpp:767
void SetFeatureWindow(Rect< int > featureWindow)
Set the feature window for this model.
Definition training_set.hpp:830
int Index() const
Index of this object in the parent's collection.
Definition training_set.hpp:743
void SetOrigin(Point2D< double > origin)
Set the origin of the model in terms of coordinates inside the feature window.
Definition training_set.hpp:852
Rect< int > GetMaxFeatureWindow() const
Retrieve the maximum values that may be set as feature window for this model.
Definition training_set.hpp:921
void SetName(const String &name)
Set the name of the model.
Definition training_set.hpp:784
Rect< int > FeatureWindow() const
Get the feature window for this model.
Definition training_set.hpp:816
void * Handle() const noexcept
Classic API MTSMODEL handle.
Definition training_set.hpp:977
Class that maintains the collection of Training Images inside a Minos Training Set.
Definition training_set.hpp:406
A Minos Training Set from which a classifier can be generated.
Definition training_set.hpp:1188
static TypedRange< std::unique_ptr< TrainingSet >, std::uint8_t, RANGE >::type FromBuffer(const RANGE &buffer)
Recreate a serialized Minos training set from a byte array.
Definition training_set.hpp:1282
std::unique_ptr< TrainingSet > Transform(Matrix2D transformation)
Generate a new training set by transforming this training set with a 2x2 transformation matrix.
Definition training_set.hpp:1351
std::vector< SearchResult > CheckConsistency(double threshold, double density=1.0)
Test all images in the parent training set for instances of this model that might have been forgotten...
Definition training_set.hpp:1370
double CorrelationThreshold() const
Gets the correlation threshold. The correlation value under which Minos proposes generating a new mod...
Definition training_set.hpp:1558
int ClassCount() const
The number of identifiable classes inside this training set.
Definition training_set.hpp:1388
static std::unique_ptr< TrainingSet > FromBuffer(const void *buffer, size_t size)
Recreate a serialized Minos training set from a byte array.
Definition training_set.hpp:1265
void SetIsModified(bool isModified)
Set a flag that informs about unsaved modifications to the training set.
Definition training_set.hpp:1474
ModelInfoCollection & Models()
The models contained in this training set.
Definition training_set.hpp:1437
TrainingSet(const String &fileName)
Load a saved training set from a file.
Definition training_set.hpp:1235
static std::unique_ptr< TrainingSet > FromHandle(HandleGuard< TrainingSet > &&guard)
Creates training set from a classic API handle.
Definition training_set.hpp:1308
TrainingSet()
Create an empty training set.
Definition training_set.hpp:1225
String Comment() const
Get the comment assigned to the training set at generation time.
Definition training_set.hpp:1510
std::vector< std::uint8_t > ToBuffer() const
Serializes the training set into a buffer.
Definition training_set.hpp:1336
void SetExpectationRadius(double expectationRadius)
Set the expectation radius - the radius that is searched for the best occurrence of a sample,...
Definition training_set.hpp:1547
void Save(const String &fileName) const
Write the training set to a file.
Definition training_set.hpp:1324
Rect< int > Extent() const
Extent of the classes in the training set relative to the anchor point.
Definition training_set.hpp:1484
bool IsModified() const
Get a flag that informs about unsaved modifications to the training set.
Definition training_set.hpp:1460
void SetComment(String comment)
Set the comment assigned to the training set at generation time.
Definition training_set.hpp:1522
int InstancesTotal() const
Total number of instances currently trained in this training set.
Definition training_set.hpp:1411
static std::unique_ptr< TrainingSet > Load(const String &fileName)
Load a saved training set from a file.
Definition training_set.hpp:1253
Rect< int > LastFeatureWindow() const
Feature window of the last model that has been created for the training set.
Definition training_set.hpp:1497
void SetCorrelationThreshold(double correlationThreshold)
Set the correlation threshold - the correlation value below which Minos will suggest the generation o...
Definition training_set.hpp:1573
String FileName() const
Name of the file, from which this training set was loaded (empty string if this image list was neithe...
Definition training_set.hpp:1448
void * Handle() const noexcept
Classic API CLF handle.
Definition training_set.hpp:1295
ImageInfoCollection & Images()
The images contained in this training set.
Definition training_set.hpp:1424
InstanceInfoCollection & Instances()
The instances contained in this training set.
Definition training_set.hpp:1401
double ExpectationRadius() const
Get the expectation radius - the radius that is searched for the best occurrence of a sample,...
Definition training_set.hpp:1533
Multi-purpose 2D vector class.
Definition point_2d.hpp:20
T X() const noexcept
Gets the x-component of the point.
Definition point_2d.hpp:84
T Y() const noexcept
Gets the y-component of the point.
Definition point_2d.hpp:104
Rectangle object.
Definition rect.hpp:24
T Bottom() const noexcept
Gets bottom row of the rectangle (still inside the rectangle).
Definition rect.hpp:144
T Top() const noexcept
Gets first row of the rectangle.
Definition rect.hpp:104
T Right() const noexcept
Gets rightmost column of the rectangle (still inside the rectangle).
Definition rect.hpp:124
T Left() const noexcept
Gets first column of the rectangle.
Definition rect.hpp:84
cvbbool_t ShareObject(OBJ Object)
cvbbool_t ReleaseObject(OBJ &Object)
Namespace for the Minos package.
Definition classifier.hpp:29
bool operator==(const ClassifierModelInfo &lhs, const ClassifierModelInfo &rhs) noexcept
Comparison operator for ClassifierModelInfo objects.
Definition classifier.hpp:163
std::shared_ptr< TrainingSet > TrainingSetPtr
Convenience shared pointer for TrainingSet.
Definition training_set.hpp:1587
bool operator!=(const ClassifierModelInfo &lhs, const ClassifierModelInfo &rhs) noexcept
Comparison operator for ClassifierModelInfo objects.
Definition classifier.hpp:150
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
char Char
Character type for wide characters or unicode characters.
Definition string.hpp:63
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49
Point2D< int > Round(const Point2D< T > &rhs) noexcept
Round to an integer point.
Definition point_2d.hpp:371