-
Notifications
You must be signed in to change notification settings - Fork 769
A go at making the depth_packet_stream_parser better. #75
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
Conversation
492ba42
to
0c1f09c
Compare
0c1f09c
to
8ba584a
Compare
8ba584a
to
54db33b
Compare
54db33b
to
e460b71
Compare
|
||
size_t max_length = std::min<size_t>(wb.capacity - wb.length, in_length - 8); | ||
for (size_t i = 0; i < in_length; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
upper bound should be in_length - sizeof(DepthSubPacketFooter)
otherwise we might cause a segfault!?
e460b71
to
58d88e9
Compare
For your reference one of the |
Here is my take. This is a complete rewrite, please ignore the diff and just look at the new function. It has been tested extensively . Several considerations for the rewrite:
Some additional observations:
|
58d88e9
to
67f14c4
Compare
Hi @xlz I have tried out your implementation, but I get really bad performance :( I can't even manage to stop and find the average framerate printout... But I like a lot of the ideas you bring up - so I'll try to figure out why its not working at my part. I have added the implementation on a branch in my fork here |
My version should be strictly faster than the current one because it does not use an extra buffer and does not memcpy unnecessarily. I have tested it for 70 fps without data loss. It may be that something is different on Windows that needs change. So this depends on your investigation. You can check if you have correctly disabled USB autosuspend settings, and you can try running it without visualization (comment out |
Hi @xlz The above test was on my dell precision m6600 - and I just tried it on my stationary I7 GTX480 and here it runs a lot more smooth. (I see same behavior with the current(master/my go at it) implementation - simply more processing power :) ) But I'll try to investigate why its running slower than the current implementation on the laptop. I think have seen various data transfers sometimes on the USB - this might be the problem (ie. looking at the end/memory scanning). I have never done anything about USB autosuspend, but I'll try find out where to change this :) It has nothing to do with the visualization. |
@larshg It might also be the slow scrolling of |
Iterates through all bytes to find footer. Copy data in chunks. Doesn't use additional working buffer. Adds timestamp
@larshg Slow (0.5x performance)
Fast
I don't know what is exactly the problem, but I reverted my patch to follow the original order of memcpys. |
After closer look at libusb ISO transfer, it seems it is not even necessary to detect the footer at all. ISO packets length will provide clue about the end of a subpacket. And zero packet length indicates splitting between packets. An example with one transfer a line:
Also as can be seen, the 10th auxiliary subpacket lags in time and is not actually used for the depth image. |
@larshg I have removed enforcing of sequence number, and mostly minimized changes made to the original code to preserve the original execution order. The only changes now are 1) removing magic footer scanning, and assuming fixed sizes. I have tested the patch under Linux and Windows. Please see if it works for you. |
Iterates through all bytes to find footer but copy data in chunks.
Doesn't use additional working buffer.
I tried to find out why I was getting a lot of errors as shown here #72 (comment) .
And I found out that its probably not about the code, but rather a hardware/software issue of my dell Precision m6600, with a Renesas USB 3.0 controller not being able to process and acquire all the data that the Kinectv2 sends out.
Also when data is transferred using ISO-mode, the packages are not guaranteed to be received either in order or at all.
I don't have any measures if this is faster/better than the previous, but it avoids using the extra working buffer.
Update: I added a FPS counter(locally) which showed my laptop running about 20(min 16, max 24). Tried the code on my stationary pc and there are a lot fewer errors and showed about 29-30 fps, hence sometimes a frame is lost. I tried a official depth app also and it runs about 29-30 fps - maybe just a bit more stable at the 30 :)