Azure Custom Vision SDK ImageRegionCreateEntry doesn't seem to set region

242 Views Asked by At

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?

1

There are 1 best solutions below

2
Tong Bai On

[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