-
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
Saving Video but the color is wired, why? #9541
Comments
Hi @pangpangshui If you are getting reversed colors in your depth image in OpenCV, it is typically because you need to take account of the fact that OpenCV uses the BGR color-space by default instead of RGB. |
I change this config from
Is there any way to change RGB frame to BGR frame? Or How can I saving videio and previw cameras'stream at the same time? @MartyG-RealSense |
In RealSense OpenCV programs, imshow is typically used to render the camera images, like in the RealSense SDK's OpenCV 'Getting Started' C++ example in the link below. There was a case of reversed colors in Python (I know you are using C++ but the concept should be similar) where a RealSense user used OpenCV's cvtColor instruction to perform conversion of the depth image. |
A C++ script in the link below provides an example use of cvtColor: |
I use thread one-> push frame
thread second->save video
Once I use cv::cvtColor, thread one will lost many frames. I confused, do you know why? @MartyG-RealSense More over, is there any way to convert rs2::frame to AVFrame? |
It could simply be that the processing demands of color conversion are slowing the program down. It looks as though you are using multiple-camera code in thread one. Is that correct please, and if so, how many cameras are being used simultaneously? Using multiple cameras that are all attached to the same computer can in itself impose a processing burden. For example, in a seminar in 2018 about use of multiple RealSense 400 Series cameras, Intel recommended a computer with an Intel i7 processor for using 4 cameras simultaneously. The C++ multithreading programming discussion in the link below may be a useful reference to check against your own multi-thread approach. |
I use 4 cameras in my computer that has prosessor named Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz 3.70 GHz and has 16GB memory. Why color conversion will influence rs2::frame pushed from camera. If I remove |
Does this C++ example provide any useful insights aobout using the color stream without cvtColor: |
If I use imshow, I cannot suit for my custom UI. Do you know how to convert rs2::frame to AVFrame? I want to try to use ffmpeg. |
I researched the subject of AVFrame or ffmpeg conversion again but found very little that was usable in librealsense, except for advice in the link below that was for Python instead of C++. I could not find anything else, unfortunately. |
Hi @pangpangshui Bearing in mind the difficulty mentioned above of finding reference mterial about ffmpeg / AVFrame in relation to librealsense, do you require further assistance with this case, please? Thanks! |
Case closed due to no further comments received. |
I have found the way that can convert rs2::frame to AVFrame. But I found that if I record video with resolution<1280*720>, it will lost frames. the code like this:
There are four cameras. The log show that there only about 990 frames in one minutes, but the camera is set 40 frames/s. Why? |
Hi @pangpangshui If this is a multiple camera application (4 cameras controlled by the same program on the same computer) then ideally poll_for_frames() should be used instead of wait_for_frames(). The difference between the two is explained in #2422 (comment) |
I change the code like this:
It does not work, it still lost frames. The log show that there only about 990 frames in one minutes. @MartyG-RealSense |
How does it behave if only one camera is attached? |
Is there any way for recoding video of 4 cameras with 720P or 1080P and it cannot lost frames ? I use cv::VideoWriter for recoding video. @MartyG-RealSense Now I recoding video with 4 cameras with 720P, the usage of cpu is 100%, and I lost three frames in one minute. |
Using multi-threading may be the best way to achieve efficient multiple camera recording. There is a C++ case about doing so at #3802 |
I use four thread to record videos, still ost frames.@MartyG-RealSense |
Are you using poll_for_frames() in your code? If you are then you need to control when the CPU is put to sleep and for how long, otherwise the CPU can max out at 100% usage. |
Issue Description
I want to save rs::frame to video, format is .avi. Now it is ok for saving video, but the color of video is wired. It shows blue but the original color is yellow, and it shows yellow but the original color is blue, and . the code like this:
Why would I get the error color of Mat?
The text was updated successfully, but these errors were encountered: