Yolo NEXT: Output forecast BoundingBox Do further processing __ computer vision

Source: Internet
Author: User

For us to use YOLO for other applications in study, the ultimate goal is definitely not to look at the predictions BoundingBox OK.
Specifically for me, we need to get boundingbox and then find the local information of the target. Here's a brief description of how to do it.
1. Modify the source code
In the source code image.c find the Draw_detections () function, print out the position of the box, as follows:

2. Record terminal output to text file
The command I use here is | Tee Train_log.txt, refer to: Linux recording terminal (Terminal) output to text file
3.python further extract boundingbox and do simple processing
First look at the input data (that is, the data in the previous step output to the file):

You can see sometimes detection is sometimes not detected, here I do it for the convenience of the back (here I want to extract the category name tip of the box coordinates and processing), a simple process (known each frame has and only one tip, if not detected by the coordinates of adjacent frames), and save to the new file.
The code is as follows:

Read a row of ' tip ' data into dic

I=0
d={} with
open (' Output_coordinate.txt ') as F: For line in
    F.readlines ():
        if ' Objects: ' in line:
            i=i+1            
        If ' tip: ' in line:
            D[i]=line.strip ()

# Print (i)
# print (d)
If tip is not detected in a frame, the data detected by the previous frame defaults to
D[1]=d[2] for
K in range (1, i+1):
    if not d.get (k):
        d[k]=d[k-1]
# print (d)
Split tip data into List
Import re
for K, v. in D.items ():
    d[k]=re.split (R ' \s+ ', v)
# print (d)
Array reassembly to DICT format
Frames=[]
probs=[]
lx=[]
rx=[]
ly=[]
ry=[]

for K, v. in D.items ():
    frames.append (k)
    probs.append (v[1])
    lx.append (v[2])
    rx.append (v[3)) Ly.append (
    v[4])
    ry.append (v[5))

data = {' Frames ': frames,
        ' probs ':p robs,
        ' lx ': lx,
        ' rx ': Rx,
        ' ly ': ly,
        ' ry ': ry,}
Data stored to Dataframe
From pandas import Series, dataframe

frames_num=1590

frame = dataframe (data, columns = [' probs ', ' lx ', ' rx ', ' ly ', ' ry '], index = list (range (1, frames_num+1)))
Frame.index.name = ' frames '
frame.columns.name = ' Coordiante '
Frame.head ()
Coordiante probs LX Rx ly ry
Frames
1 36% 559 811 247 306
2 36% 559 811 247 306
3 37% 559 811 247 305
4 37% 558 810 246 305
5 37% 557 810 245 304

Coordinate data saved to text

With open (' Tip_coordinate.txt ', ' W ') as F: to
    J in Range (Frames_num):
        f.write (lx[j]+ ' +ly[j]+ ' +rx[j]+ ') +ry[ j]+ ' \ n ')  

Results of the final processing:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.