Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write image to the record failed: AttributeError: 'NoneType' object has no attribute 'shape' #55

Closed
GabrielZZZ opened this issue Oct 11, 2022 · 8 comments

Comments

@GabrielZZZ
Copy link

Hi @daohu527 ,

I have successfully used your recover tool to repair the file (after updating the cyber_record). Then I split the file to delete the original imaes. My idea is by transforming the image extracted and then writing it back to the record file to test Apollo. However, when I try to write image data back to the record file, it gives me error: AttributeError: 'NoneType' object has no attribute 'shape'
image

Moreover, I tried to write other images to an empty file, and this error is still encountered, but I have not encountered it before I updated the tool (I am using the same data as before). Is there anything conflict among these updates?
image

@daohu527
Copy link
Owner

In fact, I don't know your operation process, you can write down the operation steps in detail then we can find what's wrong

@GabrielZZZ
Copy link
Author

Good idea, here are the steps I followed:

  1. I update the cyber_record tool

  2. Since the cyber_record recover command not work on my device (I am using Ubuntu 20.04, it shows "command not found"), I use the recover function inside my code and repaired the demo

  3. I extracted the images,and it worked fine:
    image
    00001

  4. First, I tried to write these images to an empty record first, and here is the error:
    image

  5. Then I tried to write these images back to the original record file that has been splitted images, and here is the error:
    image

HERE is the code of writing image back to record:
image

@daohu527
Copy link
Owner

daohu527 commented Oct 12, 2022

I checked the code and it works well. Maybe your img path is error and I add check in record_msg now.

def write_image():
  '''
  img_dir: image folder
  '''
  image_builder = ImageBuilder()
  write_file_name = "example_w.record.00002"
  img_dir = "../tests/"
  with Record(write_file_name, mode='w') as record:
    img_paths = sorted(os.listdir(img_dir))
    for img_path in img_paths:
      if img_path.endswith(".jpg"):
        file_path = img_dir + img_path
        print(file_path)

        pb_image = image_builder.build(file_path, encoding='rgb8')
        record.write('/apollo/sensor/camera/front_6mm/image',
                    pb_image,
                    int(time.time() * 1e9))
  print("Success write image!")

@GabrielZZZ
Copy link
Author

I double-checked the img path. I added a print command of the image_list I used before writing to record, and program can read the images
image

@daohu527
Copy link
Owner

Pls use Record(write_file_name, mode='w') mode='a' is not support for now!

@GabrielZZZ
Copy link
Author

So how do I write images back to an existing bag? If using mode='w', the old one will be overwritten.

@daohu527
Copy link
Owner

daohu527 commented Oct 14, 2022

so it depends on mode='a', and I will finish it in a few days #56

@GabrielZZZ
Copy link
Author

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants