suyz526 / ZebraPose

The implementation of the paper 'ZebraPose: Coarse to Fine Surface Encoding for 6DoF Object Pose Estimation' (CVPR2022)
MIT License
122 stars 20 forks source link

Artifacts in saved images #28

Closed jonashein closed 1 year ago

jonashein commented 1 year ago

Hi all,

I'm currently trying to apply Zebrapose to my own dataset. I've sucessfully generated the c++ executable and the python wrapper, and I can run the generator to render the zebrapose annotated images

python3 generate_training_labels_for_BOP.py --bop_path /home/user/datasets/bop/ --dataset_name myDataset --force_rewrite True --is_training_data False --data_folder test --start_obj_id 0 --end_obj_id 1

The script runs fine and I can see that correct images are being generated, see the following screenshot:

Screenshot ![screenshot](https://github.com/suyz526/ZebraPose/assets/16691259/6058cb85-d49b-43b3-8ad3-35cd6bdeb36f)

However, when I open the saved images, all of them have some artifacts on the top border, and the rendered image content is shifted by the same height along the y axis. See this example:

Saved Image ![artifacts](https://github.com/suyz526/ZebraPose/assets/16691259/be846d67-9883-42c4-a269-89dd3c9c8fba)

My specs:

Has anyone experienced a similar issue or a good guess what could be the issue? Thanks in advance!

suyz526 commented 1 year ago

Hi Jonas,

Thanks for your interest, and sorry for the inconvenience. I think it is caused by some memory alignment problem. Can you try to remove L185 to L187 and compile the render again?

Best regards, Yongzhi

jonashein commented 1 year ago

Hi Yongzhi,

thanks for your fast reply. It indeed looks like some alignment issue. I tested your proposed change but unfortunately it did not change anything. The height of the artifact border is exactly 50px. I also checked the image sizes, and the image shown in the UI has a resolution of 1280x1030, whereas the saved image has the (correct) resolution of 1280x1080. I'm currently working my way through the code to understand what happens between rendering the image in the UI and storing said image as a file, as to find out where this 50px difference stems from. I'm not familiar with the OpenGL API though, so I'd be grateful for any hints.

suyz526 commented 1 year ago

Hmmm, that's a little bit weird. I have never seen such cases.

We defined cv::Mat img(IMG_HEIGHT, IMG_WIDTH, CV_8UC3);. So in the Opencv Mat, it contains up to 1280x1030x3 values. Maybe you can put a breakpoint here, to check the shape of the Opencv matbefore saving it.

yinguoxiangyi commented 1 year ago

@jonashein, have you solved the issue? I have the same problem and could you please give me some help?

yinguoxiangyi commented 1 year ago

The issue may be due to that the rendering window is not totally displayed in monitor screen. The bottom part is not rendered, after flipped, it turns to top part.

yinguoxiangyi commented 1 year ago

@suyz526 do you have any suggestion about how to render hidden part as well?

suyz526 commented 1 year ago

@suyz526 do you have any suggestion about how to render hidden part as well?

Hi!

Thanks for providing more information regarding this bug.

I don't know if this will be helpful: https://www.glfw.org/docs/latest/context.html#context_offscreen

It would be just adding glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); into the code.

yinguoxiangyi commented 1 year ago

Thank you very much. It now works.