GithubHelp home page GithubHelp logo

Comments (7)

franferraz98 avatar franferraz98 commented on May 26, 2024 1

Well yeah, it was my fault. That i['id'] == a['id'] should be i['id'] == a['image_id'].

Sigh. Sorry, had my head somewhere else when I wrote this. Thanks for your support!

from zpy.

franferraz98 avatar franferraz98 commented on May 26, 2024

The rest of the code, for if it's needed:

import logging
import math
import random
from pathlib import Path
import random
import numpy as np
 
import bpy
import zpy

from mathutils.bvhtree import BVHTree


log = logging.getLogger("zpy")


def rotation_matrix(axis, theta):
    """
    Return the rotation matrix associated with counterclockwise rotation about
    the given axis by theta radians.
    """
    axis = np.asarray(axis)
    axis = axis / math.sqrt(np.dot(axis, axis))
    a = math.cos(theta / 2.0)
    b, c, d = -axis * math.sin(theta / 2.0)
    aa, bb, cc, dd = a * a, b * b, c * c, d * d
    bc, ad, ac, ab, bd, cd = b * c, a * d, a * c, a * b, b * d, c * d
    return np.array([[aa + bb - cc - dd, 2 * (bc + ad), 2 * (bd - ac)],
                     [2 * (bc - ad), aa + cc - bb - dd, 2 * (cd + ab)],
                     [2 * (bd + ac), 2 * (cd - ab), aa + dd - bb - cc]])


def rotate(point, angle_degrees, axis=(0,1,0)):
    theta_degrees = angle_degrees
    theta_radians = math.radians(theta_degrees)
    rotated_point = np.dot(rotation_matrix(axis, theta_radians), point)
    return rotated_point

from zpy.

hu-po avatar hu-po commented on May 26, 2024

That is a weird result for sure. Code seems to looks fine. What do the depth and segmentation images look like for those weird bounding boxes?

from zpy.

franferraz98 avatar franferraz98 commented on May 26, 2024

I deleted those ones, but here are some new ones:

image

image

image


image

image

image

In general they look fine, I wouldn't say that it has to do with the model.

from zpy.

hu-po avatar hu-po commented on May 26, 2024

Interesting. Are you using your own visualization tools to show the bounding box over the image? There are a couple different styles of bounding boxes, zpy uses (x, y, width, height) as seen here. Could be that your visualization tool uses something else like (x1, y1, x2, y2)

from zpy.

franferraz98 avatar franferraz98 commented on May 26, 2024

Yes, I use my own script, but I'd say I got the style you say. Here is my script:

import json
import argparse
import cv2
from matplotlib import pyplot as plt

# Initiate argument parser
parser = argparse.ArgumentParser(
    description="Sample TensorFlow COCO-to-TFRecord converter")
parser.add_argument("-a",
                    "--ann_file",
                    help="Path to the folder where the input .coco.json files are stored.",
                    type=str)
parser.add_argument("-i",
                    "--img_dir",
                    help="Path to the folder where the input image files are stored. "
                         "Defaults to the same directory as ANN_FILE.",
                    type=str, default=None)

args = parser.parse_args()

if args.img_dir is None:
    args.img_dir = args.ann_file

img_dir=args.img_dir
annotations_file=args.ann_file

# Remove annotations
# Read JSON for annotations
d = {}
with open(args.ann_file) as f:  
    d = json.load(f)

f.close()

# Get images and annotations
images = d['images']
annotations = d['annotations']

for i in images:
    print("PATH: ", args.img_dir + i['file_name'])
    img = cv2.imread(args.img_dir + i['file_name'])
    for a in annotations:
        if i['id'] == a['id']:  # Annotation for the image
            [x,y,w,h] = a['bbox']
            start = (int(x), int(y))
            end = (int(x+w), int(y+h))
            color = (255,0,0)
            thick = 2
            cv2.rectangle(img, start, end, color, thick)
            cv2.imshow(' ',img)
            cv2.waitKey(0)
            cv2.destroyAllWindows()

from zpy.

hu-po avatar hu-po commented on May 26, 2024

All good! Glad I could help.

from zpy.

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.