-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add object detection capability and python API #3472
Conversation
@rajat2004 any idea why checks failed for Unity build? |
You'll need to add some unimplemented methods in Unity WorldSimApi.cpp, .h files for compilation, just follow the format in the other methods There's also a conflict which needs to be fixed, #3477 renamed the file and everywhere it was used. Will need to fix the spelling of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a brief review. I haven't yet looked at the detection part of the code, will do so later
One main point is that AirSim uses 4 spaces instead of tabs, it'll be best to convert to remain consistent. Another is that snake case is used for variables, which would also be another good thing to fix
I don't want to undermine your hard work, but I want to note that there is a simpler way of getting bounding boxes around objects such as cars by using the segmentation images. I explained it here. This way, you get pixel-perfect bounding boxes. By projecting a 3D box, you will always end up (except for objects that have the shape of a box of course) with bigger bounding boxes than optimal. |
@evroon The bounding box retrieval from segmentation images works only in cases when objects do not overlap in the camera view. If there is a forest with a lot of trees or car in front of an another car, then these tightly coupled different objects can not be differentiated in segmentation images. So this bounding box feature is very welcomed in cases such as these. |
@PPakalns Yes that's true, in case of occlusion "my" method does not work. But in my case I use it to train yolov4 for example and then you don't need such data AFAIK. I value correct bounding boxes more. Btw I think you can also make my method work by taking multiple segmentation images of the same frame and changing the visibility of objects, but that is more complicated and less performant of course. |
@evron I will be using it for prototyping object detection model where objects can be tightly located in the scene next to each other, like standard case of people passing in front of each other or, in my case, prototyping survey drone where it is important to correctly recognize each separate object, these objects can occlude each other little bit. Segmentation image approach makes it hard to annotate such objects with separate bounding boxes because their regions overlap. @alonfaraj At least now DetectionInfo data returns only object geolocation, for generating annotated data it would be useful if object position and orientation relative to the camera could be returned additionally. At least I will try to add such information myself :) UPDATE Looks like using name returned in DetectionInfo and AirSim api to get object, vehicle and camera poses such information can be calculated. Tomorrow will test this code and see how it works. Thanks @alonfaraj for such implementation 🥇 |
@alonfaraj This is great! Was building the exact same thing but stumbled upon this. I have a few suggestions..
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, object detection results for some objects are flickering (in some frames object is visible, in some it is not even when camera position is not changed). Will look into cause of it.
|
@MoBaT Thanks for the suggestions! About 4 - what is the purpose of 3D BB? Should it be in Geo as well? |
@PPakalns Thank you very much for testing and fix those bugs! @evroon Seems like you already discussed it but I like your approach too :) |
- Move FString ctor outside of loop
@zimmy87 Seems like all set now. |
…nly by API request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly comments on naming guidelines
@zimmy87 Thanks for the review! Hopefully I didn't miss anything |
adding setup_path.py for convenience in calling detection.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
latest revision looks good to me; will move ahead with merge once all checks pass
Hi, @alonfaraj! Congratulations on this merged Pull Request. You are in the top 5 AirSim contributors! However, this contribution would have a much greater impact if it had associated documentation. Can you create a new PR with documentation? |
@jonyMarino Thank you! |
Should have mentioned this earlier, the API has a |
@rajat2004 you right, this PR currently support only I added the I'm wondering if add it to all other types is necessary or remove the |
Yeah, makes sense to have different detections for each image type as well. Since the API already has the image_type arg, adding support for other types will be good |
Hi, @alonfaraj But Could you please explain these parameters in detail? ,such as I am confused about these two parameters Thanks a lot! |
Thank you @LIU-Xueming,
|
Hi, @alonfaraj I have a quick question. How will you accommodate for occluded objects?. Is there a way to determine whether the object is occluded or not ?. I potentially want to exclude the bounding box of an object if it is occluded. Thank you. |
About
This PR adds the capability to detect objects with Unreal.
It support setting radius from camera to search for objects and setting object name in wildcard format.
One can control these settings for each camera, image type and vehicle combination separately.
It output relevant information as described in
DetectionInfo
.Itcurrently support only
ImageType::Scene
, but can be extended by attaching theDetectionComponent
in BP_PIPCamera to the relevant camera and add corresponding lines inAPIPCamera::PostInitializeComponents
Detection APIs implementation:
Detection struct:
TODO:
settings.json
Most of the detection and object filter code was copied from https://github.com/unrealgt/UnrealGT and changed for my own needs.
Probably much more work to do but I'm using it for a while and though other users might find it useful.
How Has This Been Tested?
Tested on Blocks and ModularNeighborhood environments by running the detection python script in this PR (Windows).
Example API Call -
Example output -
Screenshots (if appropriate):
Blocks


Unreal
Python
ModularNeighborhood
Unreal
Python