Comments (7)
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.
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.
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.
I deleted those ones, but here are some new ones:
In general they look fine, I wouldn't say that it has to do with the model.
from zpy.
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.
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.
All good! Glad I could help.
from zpy.
Related Issues (20)
- Improving Rendering & Processing Speed with AWS HOT 14
- Help message for `zpy dataset generate` is improperly formatted
- Package Sim Notebook
- Cannot create COCO annotations when RGB and Segmentation images are in Separate folder HOT 4
- Segmentation taking more and more time as my script is running HOT 2
- typo in zpy/render.py HOT 1
- Attribute Error on zpy.objects.segment HOT 2
- Convert COCO annotations .json file to TensorFlow .record file HOT 2
- Can't get denoised render from zpy generated dataset HOT 2
- Attributerror: "rendersettings" object has no attribute "tile_x" (blender 3.0) HOT 1
- Single bounding box for multiple instances HOT 2
- AttributeError: 'Object' object has no attribute 'seg' HOT 1
- ZPY Add-on can not be activated on Blender
- An error with 'tile_x' HOT 2
- Headless Execution Instructions HOT 2
- How to get the Normalised segmentation?
- Did not update the self.category_name_to_id in remap function.
- HDRI & texture randomisation HOT 1
- Material jitter
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zpy.