# Adding Instances to Minos TrainingSet

**URL:** <https://forum.commonvisionblox.com/t/adding-instances-to-minos-trainingset/1053>\
**Category:** Programming Questions\
**Created:** [February 10, 2020, 10:46am UTC](https://forum.commonvisionblox.com/t/adding-instances-to-minos-trainingset/1053 "2020-02-10T10:46:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alw](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@alw](https://forum.commonvisionblox.com/u/alw)\
**Post date:** [February 10, 2020, 10:46am UTC](https://forum.commonvisionblox.com/t/adding-instances-to-minos-trainingset/1053/1 "2020-02-10T10:46:23Z")

</div>

Hi,

I am trying to add instances to a Minos TrainingSet I created in the program. The instances are all on the same image. I created the image by copying an image of a coin for testing purposes, so all the instances are identical.  
This works perfectly fine when I am using the TeachBench but not inside my program.

This is the code I use:

```auto
TrainingSet newTrainingSet = new TrainingSet();
newTrainingSet.Images.Add(TrainingImage);

newTrainingSet.CorrelationThreshold = 0.5;
newTrainingSet.ExpectationRadius = 3; 

newTrainingSet.Models.Add(newTrainingSet.Images[0], "SearchTraining", RectCenter[0], TrainingWindow);
TrainingSet.ImageInstanceInfoCollection instanceInfos = new TrainingSet.ImageInstanceInfoCollection(newTrainingSet, newTrainingSet.Handle);

if (RectCenter.Count > 1) 
{
for (int i = 1; i < RectCenter.Count; i ++) 
{
Point2Dd tempRectCenter = new Point2Dd(RectCenter[i]);

string tempModel = newTrainingSet.Models[0].Name;

TrainingSet.InstanceInfo testInstanceInfo = instanceInfos.Add(tempModel, true, ref tempRectCenter);
}
}

```

RectCenter is a List with the locations of the instances.  
TrainingWindow is a Rect with the size of the Training Window.

The message I get is:  
 ![image](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/2414665989b72f8c34fed9629d3858169cfd9bf9.png)

It just does not make any sense to me as the instances are identical and they are not located too close to the image boundaries. There is also not problem when I’m trying it with the TeachBench.

Does anybody have an idea on what the problem is?  
Thanks in advance!  
alw

---

<div class="post-metadata">

**Author:** ![illusive](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/illusive/32/61_2.png) [@illusive](https://forum.commonvisionblox.com/u/illusive)\
**Post date:** [February 12, 2020, 2:01pm UTC](https://forum.commonvisionblox.com/t/adding-instances-to-minos-trainingset/1053/2 "2020-02-12T14:01:24Z")

</div>

Hi @alw

Can you tell me the extent (left/top/right/bottom values) of the model “SearchTraining” and the size of the image from which you are trying to extract?

---

<div class="post-metadata">

**Author:** ![Frank](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/frank/32/42_2.png) [@Frank](https://forum.commonvisionblox.com/u/Frank)\
**Post date:** [February 12, 2020, 2:07pm UTC](https://forum.commonvisionblox.com/t/adding-instances-to-minos-trainingset/1053/3 "2020-02-12T14:07:42Z")

</div>

Just as a quick test, you could also try to lower the correlation threshold and see if it then changes the behavior.

---

<div class="post-metadata">

**Author:** ![alw](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@alw](https://forum.commonvisionblox.com/u/alw)\
**Post date:** [February 12, 2020, 2:57pm UTC](https://forum.commonvisionblox.com/t/adding-instances-to-minos-trainingset/1053/4 "2020-02-12T14:57:44Z")

</div>

Thank you @illusive and @Frank for your responses and your help!

@illusive: The extent of the model is l = -51; t = -51; r = 51; b = 51  
and the size of the image is 737x720

@Frank: I tried that but unfortunately I get the same error message.

---

<div class="post-metadata">

**Author:** ![s-woe](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/s-woe/32/572_2.png) [@s-woe](https://forum.commonvisionblox.com/u/s-woe)\
**Post date:** [February 13, 2020, 10:30am UTC](https://forum.commonvisionblox.com/t/adding-instances-to-minos-trainingset/1053/5 "2020-02-13T10:30:13Z")

</div>

Hi @alw,

instead of

```auto
TrainingSet.InstanceInfo testInstanceInfo = instanceInfos.Add(tempModel, true, ref tempRectCenter);

```

try to add the instances with

```auto
newTrainingSet.Images[0].Instances.Add(tempModel,true, ref tempRectCenter);

```

---

<div class="post-metadata">

**Author:** ![alw](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@alw](https://forum.commonvisionblox.com/u/alw)\
**Post date:** [February 13, 2020, 11:28am UTC](https://forum.commonvisionblox.com/t/adding-instances-to-minos-trainingset/1053/6 "2020-02-13T11:28:06Z")

</div>

Hi @s-woe,

that works! Thanks a lot!
