Open XiaobinWu1998 opened 4 years ago
The results of one picture are as follow:178.86, 139.719, 458.98, 308.18.
Can you show screeshot? What command do you use?
I have to get 679 grops of bbox results, so I use darknet.py. Part of the code: ` if showImage: try: from skimage import io, draw import numpy as np image = io.imread(imagePath)
# print("*** " + str(len(detections)) + " Results, color coded by confidence ***")
imcaption = []
shape = image.shape
try:
if shape[2]:
pass
except Exception as e:
image = np.expand_dims(image, axis=2).repeat(3, axis=2)
for detection in detections:
label = detection[0]
confidence = detection[1]
pstring = label + ": " + str(np.rint(100 * confidence)) + "%"
imcaption.append(pstring)
# print(pstring)
bounds = detection[2]
shape = image.shape
# x = shape[1]
# xExtent = int(x * bounds[2] / 100)
# y = shape[0]
# yExtent = int(y * bounds[3] / 100)
yExtent = int(bounds[3])
xEntent = int(bounds[2])
# Coordinates are around the center
xCoord = int(bounds[0] - bounds[2] / 2)
yCoord = int(bounds[1] - bounds[3] / 2)
boundingBox = [
[xCoord, yCoord],
[xCoord, yCoord + yExtent],
[xCoord + xEntent, yCoord + yExtent],
[xCoord + xEntent, yCoord]
]
# Wiggle it around to make a 3px border
rr, cc = draw.polygon_perimeter([x[1] for x in boundingBox], [x[0] for x in boundingBox], shape=shape)
rr2, cc2 = draw.polygon_perimeter([x[1] + 1 for x in boundingBox], [x[0] for x in boundingBox],
shape=shape)
rr3, cc3 = draw.polygon_perimeter([x[1] - 1 for x in boundingBox], [x[0] for x in boundingBox],
shape=shape)
rr4, cc4 = draw.polygon_perimeter([x[1] for x in boundingBox], [x[0] + 1 for x in boundingBox],
shape=shape)
rr5, cc5 = draw.polygon_perimeter([x[1] for x in boundingBox], [x[0] - 1 for x in boundingBox],
shape=shape)
boxColor = (int(255 * (1 - (confidence ** 2))), int(255 * (confidence ** 2)), 0)
# image = np.array([image, image, image])
# np.expand_dims(image, 2).repeat(3, axis=2)
draw.set_color(image, (rr, cc), boxColor, alpha=0.8)
draw.set_color(image, (rr2, cc2), boxColor, alpha=0.8)
draw.set_color(image, (rr3, cc3), boxColor, alpha=0.8)
draw.set_color(image, (rr4, cc4), boxColor, alpha=0.8)
draw.set_color(image, (rr5, cc5), boxColor, alpha=0.8)
if not makeImageOnly:
# return Image.fromarray(cv2.cvtColor(image, cv2.COLOR_BGR2RGBA))
io.imshow(image)
io.show()
detections_all = {
"detections": detections,
"image": image,
"caption": "\n<br/>".join(imcaption)
}
# print(detections)
infile(detections, imagePath, shape)
except Exception as e:
print("Unable to show image: " + str(e))
return detections_all
def listdir(path, list_name): # 传入存储的list for file in os.listdir(path): file_path = os.path.join(path, file) if os.path.isdir(file_path): listdir(file_path, list_name) else: list_name.append(file_path)
def infile(detections, file, shape): file = file.split('\')[-1].split('.')[0] + '.txt'
with open('E:\\PythonCode\\Server\\result\\' + file, 'w+', encoding='utf-8') as f:
for det in detections:
x_center = det[2][0]
y_center = det[2][1]
width = det[2][2]
height = det[2][3]
print(x_center, y_center, width, height)
x_min = int(x_center - (width / 2))
y_min = int(y_center - (height / 2))
x_max = int(x_center + (width / 2))
y_max = int(y_center + (height / 2))
x_min = x_min if x_min >= 0 else 0
y_min = y_min if y_min >= 0 else 0
x_max = x_max if x_max <= shape[0] else shape[0]
y_max = y_max if y_max <= shape[1] else shape[1]
data = [x_min, y_min, x_max, y_max]
if data[0] < 0 or data[1] < 0 or data[2] < 0 or data[3] < 0:
print(file)
f.write('%s %.3f %.2f %.2f %.2f %.2f \n' % (det[0], det[1], data[0], data[1], data[2], data[3]))`
Do you use default darknet.py or darknet_video.py without any changes?
Only the modifications on these four pictures.
There seems to be a phenomenon that when the target occupies almost the entire image, the width or height of the predicted target is always greater than the original pixel value of the image. When the target is at the edge of the image, it is also easy to exceed the boundary. Can we think of the absolute value of this negative number as the possible size of the object beyond the boundary? Does this mean that yolov3 has new features?
Can we think of the absolute value of this negative number as the possible size of the object beyond the boundary?
Yes.
Does this mean that yolov3 has new features?
It isn't new a feature. It was always. Just C-code limits range of with/height for image size.
So it doesn't matter if there are negative Numbers? Should I make these changes? Setting the negative number to 0 and setting the value exceeding width/height to the pixel maximum.
Hi, @AlexeyAB Bbox results are x_center, y_center, width, height. The results of one picture are as follow:178.86, 139.719, 458.98, 308.18. I'm trying to convert them to x_min, y_min, x_max, y_max. And then something strange happened. Bbox results are about -50.00 -14.00 408.00 293.00 if formulas are correct. x_min = x_center - (width / 2) x_max = x_center + (width / 2) y_min = y_center - (height / 2) y_max = y_center + (height / 2) What do you think?