Code Monkey home page Code Monkey logo

Comments (3)

AlexeyAB avatar AlexeyAB commented on May 10, 2024 1

Thank you for more detailed information.

  • Yolo_mark works correctly
  • x and y aren't top-left corner. x and y are center of bounded box in the Yolo:

    Yolo_mark/main.cpp

    Lines 306 to 309 in d0f23d8

    float const relative_center_x = (float)(i.abs_rect.x + i.abs_rect.width / 2) / full_image_roi.cols;
    float const relative_center_y = (float)(i.abs_rect.y + i.abs_rect.height / 2) / full_image_roi.rows;
    float const relative_width = (float)i.abs_rect.width / full_image_roi.cols;
    float const relative_height = (float)i.abs_rect.height / full_image_roi.rows;

  • If you use cv::Rect(x_yolo * width_frame, y_yolo * height_frame, w_yolo * width_frame, h_yolo * height_frame); then OpenCV draws rectangle with top-left corner at x_yolo * width_image, y_yolo * height_frame that isn't correct.

You should use cv::Rect((x_yolo - w_yolo/2) * width_frame, (y_yolo - h_yolo/2) * height_frame, w_yolo * width_frame, h_yolo * height_frame); - this is correct.

See how it is calculated: https://github.com/AlexeyAB/darknet#how-to-train-to-detect-your-custom-objects

Where:

  • <object-class> - integer number of object from 0 to (classes-1)
  • <x> <y> <width> <height> - float values relative to width and height of image, it can be equal from 0.0 to 1.0
  • for example: <x> = <absolute_x> / <image_width> or <height> = <absolute_height> / <image_height>
  • atention: <x> <y> - are center of rectangle (are not top-left corner)

from yolo_mark.

AlexeyAB avatar AlexeyAB commented on May 10, 2024

Can you provide some more information, what kind of error did you get?
Show example with image and label, that has biased relative coords.

from yolo_mark.

DarrVeter avatar DarrVeter commented on May 10, 2024

screenshot_3

this is what i get when draw the rect
x = x_yolo * width
y = y_yolo * height
width_obj = w_yolo * width_frame
height_obj = h_yolo * height_frame

screenshot_4

seems to me that yolo_mark add some value to original width and height and then calculates relative coordinates, but it is strange for sure that i am first who found this out.
also one can see this difference with naked eyes comparing txt file coordinates and truth without even drawing any rectangles.
0 0.475781 0.663194 0.064062 0.345833
If you will not answer I am going to view code tomorrow.
thanks a lot for your open code and all efforts, its hard to overappreciate how much Redmon's darknet and your repo helps me in my learning progress and work.

from yolo_mark.

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.