0

I use the Azure Custom Vision SDK ImageRegionCreateEntry Class in Object Detection mode to set the region of each image to be the full image and the method shows success in the code (in full):

string dir = "G:\\folderLocation";
string[] files = Directory.GetFiles(dir);
if (files[i].ToLower().Contains(tagList[y].Name.ToLower()))
{
using (var stream = new MemoryStream(File.ReadAllBytes(files[i])))
{
var createImage = trainingApi.CreateImagesFromData(CV_Project_Guid, stream, new List<Guid>() { thisTag.Id });
//set the region for an image that is 300x400
ImageRegionCreateEntry thisImgEntry = new ImageRegionCreateEntry(createImage.Images[0].Image.Id, createImage.Images[0].Image.Tags[0].TagId, 0, 150, 150, 150);

I check each image in the portal and it does not show the Box of the region limits:

enter image description here

whilst if I set the region manually in the portal and revisit the image it shows the boxed region:

enter image description here

I find missleading when setting the region with the sdk that the tree is gray as if the tree has been identified when the "Region Shown" toggle is On.

Also, if I set the region with the SDK for each image using the full boundries of the image in pixels, the training fails. If I set the region manually, the training succeeds.

Therefore I think the region is not set correctly by the sdk. Can someone please confirm whether when using the SDK and if ImageRegionCreateEntry succeeds, revisiting each image in the portal would show the bounding box?

Sergio Solorzano
  • 476
  • 9
  • 29
  • Can you add more details about your implementation? What did you do with your ImageRegionCreateEntry object? – Nicolas R Jul 23 '22 at 18:29
  • 1
    But I think that your object is incorrect: values should be relative for left / top / width / height should be between 0 and 1, so if you want full image: 0, 0, 1, 1 – Nicolas R Jul 23 '22 at 18:33
  • Hey @NicolasR I've added the code to upload the image, I don't do anything else to it, and uploads correctly to the correct tag. You may be right, I cannot find any documentation to the effect of the measure. I tried values 0,1,1,1 but didn't work either. Shouldn't "top" be 1 also if I want the full image? isn't "top" the value above "left" so that left is the 0,0 coordinate? – Sergio Solorzano Jul 24 '22 at 14:27
  • Hi @NicolasR I tried region 0,0,1,1 but the problems persists - the image does not show the bounding box in portal and training fails. – Sergio Solorzano Jul 24 '22 at 15:02
  • i've raised measure documentation with msft https://github.com/Azure/azure-sdk-for-python/issues/25342 – Sergio Solorzano Jul 24 '22 at 15:28

1 Answers1

2

[0,0,1,1] you cannot see it is because it is exactly the image boundaries, and [0,1,1,1] is drawing outside the bounding. you can try[0.25, 0.25, 0.5, 0.5] it should draw a box at the center. Please follow the doc here to understand how the coordinate works https://learn.microsoft.com/en-us/azure/cognitive-services/custom-vision-service/quickstarts/object-detection?tabs=visual-studio&pivots=programming-language-csharp#upload-and-tag-images

Tong Bai
  • 21
  • 1
  • Thank you. I get the way it's supposed to be calculated, the problem is using the values below I can't see the bounding box on portal and training fails. Only when I set the boundingbox manually, training succeeds. I tried 0.05, 0.05, 0.9, 0.9 and as suggested 0.25, 0.25, 0.5, 0.5 Please let me know if there is any further info I can provide to clarify my question. – Sergio Solorzano Jul 27 '22 at 14:48
  • 1
    in line 82, you need you call create image after you add regions for the image in line 85, see the Quickstarts example here: https://learn.microsoft.com/en-us/azure/cognitive-services/custom-vision-service/quickstarts/object-detection?tabs=visual-studio&pivots=programming-language-csharp#upload-and-tag-images:~:text=image%20with%20its-,region%20coordinates.,-You%20can%20upload – Tong Bai Jul 28 '22 at 17:10