Skip to content

Add a dump depth processor. Reactivate the RGB dump processor. #551

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

Merged
merged 1 commit into from
Feb 3, 2016

Conversation

brendandburns
Copy link
Contributor

Add a dump pipeline.

#endif // LIBFREENECT2_WITH_OPENCL_SUPPORT

class DumpDepthPacketProcessor : public DepthPacketProcessor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why you want to dump depth packets? The raw depth packets will require P0, X, and Z tables to decode. The tables are pulled from the Kinect at run time. So far my impression is that the raw depth packets are too big to be practical (85MB/s).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd like to do offline processing of the depth files in order to facilitate faster/easier algorithm refining and testing.

When you mention the tables, can I pull them once and keep them around or are they re-calculated whenever the kinect restarts?

And yes, I'm seeing ~3Mb / frame, so yes, I think your size estimate is correct. However I'm not offput by those sizes, and I can successfully capture to disk at those rates w/o frame dropping.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see now storage is not a problem for Google. :)

P0 table contains the initial phase shift of the device and can only be obtained at run time. X and Z tables are algorithmic helper and are derived from the intrinsic parameters of the IR camera. The intrinsic parameters are factory built-in and obtained at run time but you can provide your own calibration parameters.

More details about the tables: https://github.com/OpenKinect/libfreenect2/blob/master/src/libfreenect2.cpp#L63

If you don't plan to do your own calibration, you can save the tables in DumpDepthPacketProcessor::load*Table***().

or are they re-calculated whenever the kinect restarts?

Yes, but saving the tables at the start would be sufficient for the following continuous session.

@brendandburns
Copy link
Contributor Author

Someone on my team suggested that an alternative to this approach would be to extend libfreenect2::Frame to include a Type of Raw and then pass the raw data along via Frame objects of type Raw to the corresponding Listener and have them handle it. This would probably mean adding a buffer_length field to the Frame object as well, since the bytes_per_pixel isn't applicable for the raw data.

Let me know if you prefer that approach to the one I've implemented here and I can change the implementation.

(and thanks for the fast review! I will try to get the portable timing function in tomorrow)

@xlz
Copy link
Member

xlz commented Feb 2, 2016

That was what I planned. I planned to add a JPEG format which is produced by a dummy JPEG processor doing nothing. Maybe you don't want to save it to disk, instead you want to stream it over network. We have some demand on a data recording tool #438, and specifying a recording format is not really a job of the library proper.

I don't want to add a new field if that breaks the ABI. Maybe you can abuse bytes_per_pixel for a Raw format by using proper documentation to redefine its meaning. There is quite some cruft in the library unfortunately, but no ABI breakage is accepted.

My preference:

The dump pipeline is acceptable for debug purposes, because the code is there and code matters.

If you don't break the ABI, the suggestion from your teammate is preferred, for further extension of a data recording tool. The actual code for writing the data to disk could be added to Protonect.cpp or you could directly create the data recording tool under tools/ to suit your needs (we can extend it later).

@brendandburns
Copy link
Contributor Author

ok, SGTM.

I don't think adding a Type Raw would break the ABI, since Type is listed as TBD in the docs.

So how about the following:

We will add Type RAW to the type enum, and if Type is RAW bytes_per_pixel will actually be buffer_length which is kind of hacky but will work.

If that works for you, I will re-arrange this PR to do that.

Thanks
--brendan

@xlz
Copy link
Member

xlz commented Feb 2, 2016

I meant adding buffer_length to Frame would break the ABI.

The current version of your plan is good for me.

@floe
Copy link
Contributor

floe commented Feb 2, 2016

Just curious: what's Google doing with the Kinect v2? Anything related to Project Tango? (Feel free to silently ignore me if I'm being too nosy ;-)

@brendandburns brendandburns force-pushed the master branch 2 times, most recently from 17ee696 to cf9ba02 Compare February 2, 2016 22:34
@brendandburns
Copy link
Contributor Author

@xlz I've updated this PR to reflect our discussions. please take another look.

@floe sorry...

--brendan

virtual void loadLookupTable(const short *lut);

// Get the P0 Tables
unsigned char* getP0Tables();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const unsigned char*? I think you would not need to modify the values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@brendandburns
Copy link
Contributor Author

comments addressed, please take another look.

Thanks!
--brendan


const unsigned char* getP0Tables();

float* getXTable();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these float* -> const float* too.

short* -> const short *

@xlz
Copy link
Member

xlz commented Feb 2, 2016

My review is complete.

@brendandburns
Copy link
Contributor Author

Thanks for the extensive review. Comments addressed, please re-check.

--brendan

@brendandburns brendandburns force-pushed the master branch 3 times, most recently from 68fa3e3 to e0fd47c Compare February 3, 2016 00:49
{
}

DumpRgbPacketProcessor::~DumpRgbPacketProcessor()
{
delete frame;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double free here. As in DumpDepthPacketProcessor::~DumpDepthPacketProcessor(), just remove this line.

I see you have frame = NULL;, but this delete is useless anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I figured that out ;) I deleted the member variable entirely, its not needed.

//std::ofstream file(name.str().c_str());
//file.write(reinterpret_cast<char *>(packet->jpeg_buffer), jpeg_buffer_length);
//file.close();
frame = new Frame(1, 1, 1920*1080*4);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still need this:

  frame->bytes_per_pixel = packet.jpeg_buffer_length;

1920*1080*4 is the size for the allocation, but not for the actual data.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@brendandburns
Copy link
Contributor Author

thanks, sorry for all the little errors...

--brendan

@xlz
Copy link
Member

xlz commented Feb 3, 2016

Build test OK.

ABI report looks OK.

Functions changes summary: 0 Removed, 0 Changed (5 filtered out), 3 Added functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
Function symbols changes summary: 0 Removed, 0 Added function symbol not referenced by debug info
Variable symbols changes summary: 0 Removed, 3 Added variable symbols not referenced by debug info

3 Added functions:

  'method libfreenect2::DumpPacketPipeline::DumpPacketPipeline()'    {_ZN12libfreenect218DumpPacketPipelineC1Ev, aliases _ZN12libfreenect218DumpPacketPipelineC2Ev}
  'method virtual libfreenect2::DumpPacketPipeline::~DumpPacketPipeline(int)'    {_ZN12libfreenect218DumpPacketPipelineD0Ev}
    note that this adds a new entry to the vtable of class libfreenect2::DumpPacketPipeline
  'method virtual libfreenect2::DumpPacketPipeline::~DumpPacketPipeline(int)'    {_ZN12libfreenect218DumpPacketPipelineD1Ev, aliases _ZN12libfreenect218DumpPacketPipelineD2Ev}
    note that this adds a new entry to the vtable of class libfreenect2::DumpPacketPipeline

3 Added variable symbols not referenced by debug info:

  _ZTIN12libfreenect218DumpPacketPipelineE
  _ZTSN12libfreenect218DumpPacketPipelineE
  _ZTVN12libfreenect218DumpPacketPipelineE

xlz added a commit that referenced this pull request Feb 3, 2016
Add a dump depth processor.  Reactivate the RGB dump processor.
@xlz xlz merged commit 163b575 into OpenKinect:master Feb 3, 2016
@xlz xlz mentioned this pull request Feb 3, 2016
@brendandburns
Copy link
Contributor Author

Awesome, thanks!

On Tue, Feb 2, 2016, 5:10 PM Lingzhu Xiang [email protected] wrote:

Merged #551 #551.


Reply to this email directly or view it on GitHub
#551 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants