DavidGillsjo / VideoIMUCapture-Android

Android application for capture of Video, IMU data and Camera data useful in SLAM and Structure from Motion research. Differs between Optical Image Stabilization (OIS) and Digital Video Stabilization (DVS) and can provide OIS data if the device supports it.
GNU General Public License v3.0
242 stars 44 forks source link

Error running camera calibration #5

Closed XiaoHuang996 closed 2 years ago

XiaoHuang996 commented 2 years ago

I should have followed all configuration requirements to configure the environment. But when I run "python data2kalibr.py / --tag-size 0.235 --subsample 21", I get the error: Traceback (most recent call last): File "data2kalibr.py" line 109,in convert_to_bag(proto,video_path,bag_path,args.subsamle) File "data2rosbag.py" line 39,in convert_to_bag if not i == frame_data.frame_nbr: AttributeError: frame_nbr

thanks!

DavidGillsjo commented 2 years ago

Hi, Thanks for reaching out. It seems that it cannot find the frame_nbr field in the data field. Are you running from inside the docker container?

Maybe the proto-file is corrupted somehow, if so you can try to check it with data2statistics.py.

Another option is that the parser is not correctly generated. I've by mistake included a parser in ./protobuf/test_proto but that is now removed. You should generate the parser on your own, this is done automatically for the docker image.

XiaoHuang996 commented 2 years ago

Thanks for your answer! I can run data2statistics.py successfully, but it can't generate the .bag file I need, so I need to run data2kalibr.py. I think it should be my oversight, I don't use docker, I will try your suggestion. thank you very much!

DavidGillsjo commented 2 years ago

I think you actually found a bug. I see in both data2statistics and the protobuf-file that the field should be named frame_number but is incorrectly referred to as frame_nbr. Does it work if you make the change?

DavidGillsjo commented 2 years ago

I've now made the fix, try pulling master again and see it if works.

XiaoHuang996 commented 2 years ago

Thank you so much for your work! Yesterday I learned how to use docker with little success.It's all my fault. I pulled master again. When I run data2kalibr.py, I have not encountered the error of the "frame_nbr" field! But I have new problem: Traceback (most recent call last): File "data2kalibr.py",line 115,in create_camera_yaml(proto,camera_yaml_path,args.matlab_calibration) File "datakalibr.py",line 17,in create_camera_yaml assert proto.camera_meta.intrinsic_params[4] == 0 IndexError: list index(4) out of range I think it might be a bug in initializing the matrix size when creating "intrinsic_params"? Hope to get your verification!

I have put "recording_pb2.py" from "proto_python" folder into "calibration" folder. I opened the virtual machine Ubuntu18.04 system under the Window system, maybe I don't need docker to run? Or does it have to be run from inside the docker container? This is also the answer I want to get. Thanks!

XiaoHuang996 commented 2 years ago

Although there is an error of "IndexError: list index(4) out of range", the "kalibr.bag" file has been generated in the kalibr folder. But it might be incomplete, aborting the program because of an error? My goal is to calibrate the camera and IMU fusion, which requires running "data2kalibr.py" to generate the "target.yaml" file, before going to the next step to generate the "camchain-kalibr.yaml" file.

DavidGillsjo commented 2 years ago

It seems your device does not store any intrinsic parameters, which I have not accounted for in the script. I have now updated the script to handle this case and pushed a new docker image. What Android device are you using?

So you first step will be to calibrate the camera to get intrinsic parameters, then you may perform IMU to camera calibration.

Regarding your docker question I'm not sure what you are asking. As you say you will need recording_pb2.py to interpret the protobuf file, if you are inside the docker container then the proto_python forlder will be on the PYTHONPATH environment variable and python will find it. You may reuse your docker image after updating the code, but then you will have to navigate to the source code from within the container, i.e. go to /host_home/<path to repo>. Alternatively you rebuild the image when you have updated the code. For this bug fix I have updated the image on dockerhub, so you can just pull that.

It is certainly possible to setup the required environment directly on your virtual machine. I included a path in my container which allows for single camera kalibration using Kalibr, but that may very well be integrated into their master branch by now. To see what is required to run Kalibr and my scripts you may look into the Dockerfile which is based on the Kalibr Dockerfile.

XiaoHuang996 commented 2 years ago

I am using Xiaomi MIX 2S Android device. I think my problem is solved, thanks a lot for your suggestion! Thanks!

DavidGillsjo commented 2 years ago

Great, good luck!

sajjad-hm commented 1 year ago

@XiaoHuang996 can you please share how you have solved the problem? Is it for the low configuration android device issue? I'm also kinda facing similar problems. My device is showing 15fps video recording. Is that can be a problem? Thanks in advance!

XiaoHuang996 commented 1 year ago

My impression is that I directly run the modified data2kalibr.py program, and the terminal will start processing and report an error at the end of the data, but the kalibr.bag I want (maybe, because I haven't continued for a long time) has already appeared in the kalibr folder. So I didn't continue to pay attention to the source of the error. My device at that time also displayed 15fps video recording. I didn't try whether this could be modified or whether it was related to the error.

sajjad-hm commented 1 year ago

My impression is that I directly run the modified data2kalibr.py program, and the terminal will start processing and report an error at the end of the data, but the kalibr.bag I want (maybe, because I haven't continued for a long time) has already appeared in the kalibr folder. So I didn't continue to pay attention to the source of the error. My device at that time also displayed 15fps video recording. I didn't try whether this could be modified or whether it was related to the error.

@XiaoHuang996 Thanks for your reply. I have solved my issue. It was a silly newbie mistake. I didn't add the appropriate path for target.yaml file which has some parameters of the tracking paper.