-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Aligning external camera and depth in Python using numpy arrays results in black image expect the first pixel #12677
Comments
Hi @fcitil As only the first pixel is being aligned, that makes me wonder whether this is because the program is not looping through the frames, like in the align_depth2color.py alignment example. |
Hi @MartyG-RealSense, I am able to run align-depth2color.py script with the official sample realsense .bag file successfully. It would have been the case, if the program was not able to show unaligned depth and color frames in the loop but it is. I think, the problem is most likely to be related to use of |
The software-device interface has rarely worked with Python without errors and is best used with C++. There are therefore very few working examples of Python code for software-device, which makes it difficult to diagnose any possible problems in your script that are preventing alignment from working. Does alignment take place if the sample Python script at #12020 (comment) is run on your computer? |
As I stated in the description, it does not work with .bag files directly. I needed to change and add following lines
And I get black image as an aligned depth frame, except the first pixel. |
What happems if you comment out the |
I haven't tried yet with the camera have attached. Let me try it with D435i in the following days. However, I am trying to align depth stream of realsense camera and color stream of an external camera. Therefore, I need to work with numpy arrays as here, which will end up with the same problem even if I use the D435i, so I don't think having attached D435 would solve the problem with |
Is use of numpy compulsory for your project, please? The link below has an Intel guide for using ROS1 to combine the views of two separate cameras together. https://github.com/IntelRealSense/realsense-ros/wiki/Showcase-of-using-2-cameras |
I'm using numpy because the sample-python script saves .npy files and uses numpy to create framesets. But I don't have to stick with numpy - if there's another way to align external camera with different format, I'm open to that. The guide that you provided looks like it's more for aligning up two realsense cameras with serial numbers and explains merging their point clouds. My goal is different. I need to align RGB frame of external non-realsense camera whose relative pose w.r.t. realsense camera is known and realsense depth frame, like the official |
I have just tried with D435i camera have attached, still I got the same response. I get color and depth frames separately but I don't get aligned frame as a result of align.process. |
I conducted extensive further research into this issue but #12020 is the best available reference unfortunately and there does not appear to be any other approach available to using software-device with alignment in Python. I do apologize. |
Hi @fcitil Bearing in mind the information in the comment above, do you require further assistance with this case please? Thanks! |
I have searched through all related issues but have not found any solution for my problem. I have tried to run the script with the sdk version that is said to be working in the issue, but it is not. I am still investigating for a possible solution ... |
Please do share a solution here if you find it. Good luck! |
Hi @fcitil Do you require further assistance on this case please as your last comment was in February 2024. Thanks! |
I am still not able to use software-device in python, I implemented the code for pixel matching for an external camera and D435i depth camera, which performs de-projection from depth image to depth camera coordinates, transformation from depth camera coordinates to external camera coordinates, and then projection to external camera for each depth pixel. However, it is too slow for realtime applications since it performs pixel-wise sequential operation with my current implementation without utilizing realsense pipeline, unfortunately. |
I researched your case again from the beginning but did not find a better solution than the software-device script at #12677 that you have already looked at, unfortunately. The current latest librealsense version 2.55.1 has implemented a fix for software-device's matcher creation - as described at #12394 - so it may be worth testing software-device again in 2.55.1 if you have not done so already. |
Hi @fcitil Have you tried testing software-device in SDK version 2.55.1 please? |
Hi @fcitil Do you require further assistance with this case, please? Thanks! |
Hi, I didn't have a chance to test yet. I will test and reply as soon as possible. |
Thanks very much for the update. Good luck! |
Hi, I had the same problem as @fcitil and just tested the code with the latest version of the SDK (2.55.1.6486). While this version has resolved the initial issue, I still don't get the expected results. In my experiments, I recorded a .bag file using the D455 camera and then exported the images from the .bag, both with Depth aligned to RGB and without alignment. I used the images from the latter case to align them using
I don't know if I'm doing something wrong, but I get the impression that the extrinsic values that are being used are not the ones I'm setting them to, which are the values read from the .bag:
What do you think about it? Thanks in advance for your help! |
Hi @Irene-G The image aligned using software-device appears to be the same as the first image which did not have alignment. #12020 (comment) - which the original poster on this case @fcitil highlighed - remains the best available Python reference for using intrinsics and extrinsics with software-device for the purposes of depth-color alignment. I do not have further advice on the topic, unfortunately, as few have been able to use software-device successfully with Python (it works best with C++ language). |
Case closed due to no further comments received. |
Issue Description
Hi,
I am trying to align a external RGB camera pixels with Realsense D435i depth usign align.process. In order to achieve that, I am trying to use
software-device
with two seperate rostopic of RGB frame and depth topics with ros. In this regard, I am currently working with .npy files to confirm that I am able create a new frameset consisting of RGB frame and corresponding depth. I first tried to run sample python script provided by @gwen2018 in issue #12020, but I need to change the first part in order to work with realsense .bag ( I used official sample .bag files) file as follows:Although, the first part seems to properly saves .npy files and I can get frameset with color and depth image using this files, the align.process give black frame, except the [0,0] indexed pixel as in issue #6522. Therefore, I applied the solution stated in this issue, though it is given in C++, by adding the following lines to the python script:
but still I get black image, except the first pixel, for aligned depth image. Since the first part of the sample python script seems (we cannot explicitly state fps and data format for config) working and I created required .npy files thanks to it, I ended up using this script that includes only the second part of the sample python script and required read_only_options additions given above.
Is it possible that, the problem with align process might be due to the fact that the fps and encoding cannot be stated explicitly in the first part, which would cause the problem when using the corresponding numpy arrays? If not what could be the problem with align.process considering that given scripts are able to show unaligned depth and color images from frameset created by
software-device
? I couldn't find any working reference for this problem, any advice would be appreciated.Thank you in advance,
Furkan Çitil
The text was updated successfully, but these errors were encountered: