I am writing an application in PyQt5 that depicts images with objects inside. For instance houses. I need to check (somehow) the objects on the image and get the pixels’ values on that specific objects. For instance if I have an image with 20 houses (house_1, house_2, house_3, … e.t.c.) and I choose house_1, then to get the all pixels’ values of for object “house_1”.

Any ideas on how can I achieve that?

Is it something that can OpenCV code help me?

Is it something that has to do entirely with custom dataset object detection?

Can I apply object detection algorithms withn opencv?

I am using Ubuntu.

I have tried this: https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html where I use custom dataset, but when I train it it never finish....

I have also tried this: https://blog.paperspace.com/mask-r-cnn-in-tensorflow-2-0/ and never finish...

I have, also, been studied papers, without finding something that could help me more.

I managed to build the model and make the object detection after many days trying. The problem is that the boxes with which the houses are marked, are overlapping. For instance box of “house_1” overlaps box of “house_2”.

How can I achieve this?

No boxes exist on the image and when I place a mouse over a house, then I need a box to appear for that specific house. An alternative is to keep all the boxes around the houses and when I place the mouse cursor over a house, then the box to disappear.

Any ideas?

  • 1
    To clarify: you need to do the actual object detection and then you also have to get all pixels that are detected as a specific object? Have you tried anything so far? Have you read any scientific papers? paperswithcode.com/task/object-detection-in-aerial-images/… seems to be a starting point.
    – til_b
    Feb 7, 2022 at 13:07
  • 1
    Yes! Please look at my update... Feb 7, 2022 at 13:11
  • 1
    Are you using an existing application (please say which if possible) or are you trying to write a new application for the object detection and its visualisation?
    – til_b
    Feb 7, 2022 at 13:37
  • I am trying to write a new application on PyQt5... Feb 7, 2022 at 13:44

1 Answer 1


what you need is a building footprint detection/segmentation model that can do instance segmetation of each building. There are many models submitted as part of Spacenet Building Detection Challenge https://github.com/SpaceNetChallenge/BuildingDetectors_Round2 which you can use as a referece.

Depending on your input imagery, you may have to retrain the model on your set of images since the source of imagery could be different than the spacenet dataset. It might still work but the precision and recall of the detection might not be as high as you would expect.

You will also need to write a post processing logic to smoothen the polygons of buildings,this is usually done by smoothening polygons using a smoothening algorithm like Ramer–Douglas–Peucker algorithm (there are many existing implementations for that ) once you do that you can incorporate that in your PyQt App.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.