GithubHelp home page GithubHelp logo

Comments (3)

GuoxiaWang avatar GuoxiaWang commented on August 18, 2024

@MichaelRamamonjisoa
Yes, I have the code. If you need, I can push the code to the Repo. But the code in my disk, so I need to find out.

If you can not to wait, you can write the orientation conversion code by yourself according to the code atan formulas. For the edge image, you just need draw the polygons on a binary image.

Thank you for reading my paper, I hope my paper and label tool can help you!

from instancelabeltool.

MichaelRamamonjisoa avatar MichaelRamamonjisoa commented on August 18, 2024

Thank you for your reply. I have indeed drawn boundaries as you said. However I did not try to export orientations, since I do not need it yet. I'd be glad if you could push your code to the Repo since I will probably use it for next work.

I have another request, which I can put in another issue if you want since it will probably require a specific commit.

from instancelabeltool.

GuoxiaWang avatar GuoxiaWang commented on August 18, 2024

@MichaelRamamonjisoa

I have found the calculation code of orientations from my driven disk. Here is the code snippet, and I will don't push the code to the Repo:

def get_edge_and_ori_map(obj):

    imsize = (obj.imgHeight, obj.imgWidth)
    edge_map = np.zeros(imsize, dtype=np.uint8)
    ori_map = np.zeros(imsize, dtype=np.float32)

    for edge in obj.boundaries.polygon:
        npix = len(edge)
        for idx, pt in enumerate(edge):
            
            # First, we calculate orientation
            idx0 = max(idx-5, 0)
            pt0 = edge[idx0]
            idx1 = min(idx+5, npix-1)
            pt1 = edge[idx1]

            theta = math.atan2(pt1.y-pt0.y, pt1.x-pt0.x)
            ori_map[pt.y][pt.x] = theta
            edge_map[pt.y][pt.x] = 1

    return edge_map, ori_map

and you can invoke the function like this:

    from lib.annotation import *

    ann = Annotation()
    ann.fromJsonFile(json_file_name)
    edge_map, ori_map = get_edge_and_ori_map(ann)

    height, width = edge_map.shape
    label = np.zeros((1, 2, height, width), dtype=np.float32)
    label[0, 0, ...] = edge_map
    label[0, 1, ...] = ori_map

    with h5py.File(h5_filename, 'w') as f:
        f['label'] = label

from instancelabeltool.

Related Issues (2)

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.