Giter Club home page Giter Club logo

Comments (4)

ImTheMan153 avatar ImTheMan153 commented on May 28, 2024 1
if( flags & OVERLAY_BOX )
{   
    // Draw bounding box overlays once for all detections
    if( CUDA_FAILED(cudaDetectionOverlay(input, output, width, height, format, detections, numDetections, mClassColors)) )
        return false;
    
    // Then iterate over each detection to draw the centroid circles
    for( int n=0; n < numDetections; n++ )
    {   
        const Detection* d = detections + n;
        
        // Use the Center function to calculate the center coordinates
        float cx, cy;
        d->Center(&cx, &cy);
        
        // Adjust the radius as needed
        float radius = 12.5f; // Use this variable or decide if you want to use a fixed value

        // Draw the centroid circle for the current detection
        if( CUDA_FAILED(cudaDrawCircle((uchar3*)output, width, height, static_cast<int>(cx), static_cast<int>(cy), radius, make_float4(255,0,0,200)))) // Corrected line
            return false;
    }
}

Just simply casting the output to one of the supported formats worked! Thank you.

from jetson-inference.

ImTheMan153 avatar ImTheMan153 commented on May 28, 2024

Nvidia-2024-02-05_18 02 34-ezgif com-optimize

from jetson-inference.

dusty-nv avatar dusty-nv commented on May 28, 2024

Hi @ImTheMan153, the detectNet::Detection struct has a Center() function which will return the centroid, and there are these CUDA functions for drawing basic shapes:

There are Python analogs of these too.

from jetson-inference.

ImTheMan153 avatar ImTheMan153 commented on May 28, 2024

Hi dusty,
Thank you for the reply. I changed the code to whatever you told me to go with, however, I get the same output as the gif shown above. If I remove the cuda circle loop, I am properly getting the overlay of the detection. If I use drawcircle function from jetson utils as per the repo you shared and make my build, it shows an error saying that it expects my input image to be some specific formats. I am attaching the error below.
/home/ubuntu/jetson-inference/build/aarch64/include/jetson-utils/cudaDraw.h:67:68: required from ‘cudaError_t cudaDrawCircle(T*, size_t, size_t, int, int, float, const float4&) [with T = void; cudaError_t = cudaError; size_t = long unsigned int; float4 = float4]’ /home/ubuntu/jetson-inference/c/detectNet.cpp:1024:13: required from here /home/ubuntu/jetson-inference/build/aarch64/include/jetson-utils/imageFormat.inl:234:48: error: static assertion failed: invalid image format type - supported types are uchar3, uchar4, float3, float4 234 | static_assert(__image_format_assert_false<T>::value, "invalid image format type - supported types are uchar3, uchar4, float3, float4"); | ^~~~~ make[2]: *** [CMakeFiles/jetson-inference.dir/build.make:1473: CMakeFiles/jetson-inference.dir/c/detectNet.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:447: CMakeFiles/jetson-inference.dir/all] Error 2

Source code (just the overlay function) for now:

if( flags & OVERLAY_BOX )
{   
    // Draw bounding box overlays once for all detections
    if( CUDA_FAILED(cudaDetectionOverlay(input, output, width, height, format, detections, numDetections, mClassColors)) )
        return false;

    // Then iterate over each detection to draw the centroid circles
    for( int n=0; n < numDetections; n++ )
    {   
        const Detection* d = detections + n;
        
        // Use the Center function to calculate the center coordinates
        float cx, cy;
        d->Center(&cx, &cy);
        
        // Adjust the radius as needed
        float radius = 12.5f;

        // Draw the centroid circle for the current detection
        // Ensure that the format of the image and the call to cudaDrawCircle are compatible
        if( CUDA_FAILED(cudaDrawCircle(input, output, width, height, format, static_cast<int>(cx), static_cast<int>(cy), radius, make_float4(255,0,0,200))))
            return false;
    }
}

I tried a different cuda draw circle function according to the source code shown above, but it works the same way as the gif.

If you know the fix, please send me the modified function. I will try it out and let you know!

from jetson-inference.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.