Problems encountered when GCN-SLAM compiles pytorch and runs the TUM dataset

Compile pytorch problem

When I compile pytorch (C++) according to the process on github, I have been encountering problems. At first I thought it was an incomplete clone code problem. Later, I carefully searched for the error message and found that it was a function in the pytorch source code and the function name of cuda. The conflict resulted (my environment cuda10.1 is completely compiled according to the setup.py of pytorch1.0.1 downloaded from github).

Data set problem

After downloading one or two TUM data sets, I ran run.sh under GCN and found that it could not be started.
Finally, it is found that after decompression, it contains a depth.txt and a rgb.txt file to save the filename. The code is the image read from the folder through the filename. The contents of the depth.txt and rgb.txt files are as follows (only put A small part):

# color images
# file: 'rgbd_dataset_freiburg3_long_office_household.bag'
# timestamp filename
1341847980.722988 rgb/1341847980.722988.png
1341847980.754743 rgb/1341847980.754743.png
1341847980.786856 rgb/1341847980.786856.png
1341847980.822978 rgb/1341847980.822978.png
1341847980.854676 rgb/1341847980.854676.png
1341847980.890728 rgb/1341847980.890728.png
1341847980.922978 rgb/1341847980.922978.png
# depth maps
# file: 'rgbd_dataset_freiburg3_long_office_household.bag'
# timestamp filename
1341847980.723020 depth/1341847980.723020.png
1341847980.754755 depth/1341847980.754755.png
1341847980.786879 depth/1341847980.786879.png
1341847980.822989 depth/1341847980.822989.png
1341847980.854690 depth/1341847980.854690.png
1341847980.890737 depth/1341847980.890737.png
1341847980.922989 depth/1341847980.922989.png

But in the GCN run.sh startup file, the startup parameter is passed in association.txt. After looking through some of the incoming parameters of the ORB, I found that the association.txt passed in here should be the above rgb.txt and depth. The result of txt merge is as follows:

1341847980.722988 rgb/1341847980.722988.png 1341847980.723020 depth/1341847980.723020.png
1341847980.754743 rgb/1341847980.754743.png 1341847980.754755 depth/1341847980.754755.png
1341847980.786856 rgb/1341847980.786856.png 1341847980.786879 depth/1341847980.786879.png
1341847980.822978 rgb/1341847980.822978.png 1341847980.822989 depth/1341847980.822989.png
1341847980.854676 rgb/1341847980.854676.png 1341847980.854690 depth/1341847980.854690.png
1341847980.890728 rgb/1341847980.890728.png 1341847980.890737 depth/1341847980.890737.png
1341847980.922978 rgb/1341847980.922978.png 1341847980.922989 depth/1341847980.922989.png
1341847980.954645 rgb/1341847980.954645.png 1341847980.954676 depth/1341847980.954676.png
1341847980.990699 rgb/1341847980.990699.png 1341847980.990724 depth/1341847980.990724.png
1341847981.022715 rgb/1341847981.022715.png 1341847981.022728 depth/1341847981.022728.png

Data formatting

Option 1: Change the code

Since the rgb.txt and depth.txt we need are passed in at the same time, we need to add an incoming parameter at the end of run.sh, so that the code corresponding to the read image part of the code also needs to be modified. And it is also necessary to associate the filenames in the two txt files according to the timestamp in advance (the original number of filenames in the two txt files is not the same, that is, the number of pictures in the two folders is not the same). Considering that this method is more troublesome, the following method is adopted:

Solution two: splicing rgb.txt and depth.txt according to the timestamp

A reminder, when reading the file according to the filename in the code, the comment on the first three lines of the txt is not taken into account, so there will be problems. Therefore, the comments on the first three lines of the incoming txt file must be deleted, that is, the .txt file after rgb.txt and depth.txt are spliced ​​according to the timestamp, do not add the previous comments. Splicing the code by timestamp is as follows:
Copy the association.txt generated by the code to the corresponding data set folder, and execute run.sh directly.


def split_line(f_rgbd):
    rgbd_split = f_rgbd.read().split()
    index_to_delete = []
    for i in range(len(rgbd_split)):
        if i%2:
            index_to_delete.append(i)
    count = 0
    for index in index_to_delete:
        index = index - count
        rgbd_split.pop(index)
        count += 1
    return rgbd_split

def near_time_stamp(rgb_time_stamp, depth_time_stamp):
    """
    假设len(rgb_time_stamp)  >  len(depth_time_stamp)
    只需在rgb_time_stamp中取出len(depth_time_stamp)个元素即可
    """
    near_rgb_stamp = []
    for index in depth_time_stamp:
        min_value = 1000000000
        min_jndex = ''
        depth_float = float(index)
        for jndex in rgb_time_stamp:
            rgb_float = float(jndex)
            if abs(depth_float - rgb_float) < min_value:
                min_value = abs(depth_float - rgb_float)
                min_jndex = jndex
        near_rgb_stamp.append(min_jndex)
    return near_rgb_stamp


if __name__ == '__main__':

    f_rgb = open("rgb.txt","r")
    f_depth = open("depth.txt","r")
    f_association = open('association.txt','w',encoding='utf-8')
    data_depth = f_depth.readlines()
    f_depth.seek(0,0)

    # 切分出时间戳
    rgb_time_stamp = split_line(f_rgb)
    depth_time_stamp = split_line(f_depth)

    # 寻找最近时间戳
    rgb_time_stamp = near_time_stamp(rgb_time_stamp, depth_time_stamp)
    
    # 将rgb_time_stamp与depth_time_stamp对应行拼接起来
    for i in range(len(rgb_time_stamp)):
        str_association = rgb_time_stamp[i] + " " \
                            + "rgb/" + rgb_time_stamp[i] + ".png" + " " \
                            + data_depth[i]
        f_association.write(str_association)

    f_rgb.close()
    f_depth.close()
    f_association.close()

Guess you like

Origin blog.csdn.net/qq_38337524/article/details/112648057