Skip to content

Commit

Permalink
Compatibility fix for image chunk header v2
Browse files Browse the repository at this point in the history
  • Loading branch information
tpanzarella committed Nov 3, 2016
1 parent 3b107ef commit 0e46e2d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 37 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
is to allow for checking, visually, an off-board computed cloud vs. an
on-board computed cloud.
* Fixed memory access [bug](https://github.com/lovepark/libo3d3xx/issues/67)
* Updated to support (in a backward compatible fashion) image chunk header
version 2.

## Changes between libo3d3xx 0.4.6 and 0.4.8

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
namespace o3d3xx
{
extern const std::size_t IMG_TICKET_SZ; // bytes
extern const std::size_t IMG_CHUNK_HEADER_SZ; // bytes

enum class pixel_format : std::uint8_t
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <glog/logging.h>

const std::size_t o3d3xx::IMG_TICKET_SZ = 16;
const std::size_t o3d3xx::IMG_CHUNK_HEADER_SZ = 36;

bool
o3d3xx::verify_ticket_buffer(const std::vector<std::uint8_t>& buff)
Expand Down
26 changes: 0 additions & 26 deletions modules/framegrabber/src/libo3d3xx_framegrabber/frame_grabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,32 +375,6 @@ o3d3xx::FrameGrabber::Run()
{
boost::asio::io_service::work work(this->io_service_);

// //
//
// XXX: TP I don't think this is necessary. I think it will more likely lead
// to error situations more often than helping out the situation. The user
// should take care to set the camera into "RUN" mode prior to starting the
// framegrabber.
//
// // setup the camera for image acquistion
// //
// try
// {
// this->cam_->RequestSession();
// this->cam_->SetOperatingMode(o3d3xx::Camera::operating_mode::RUN);
// this->cam_->CancelSession();
// }
// catch (const o3d3xx::error_t& ex)
// {
// LOG(ERROR) << "Failed to setup camera for image acquisition: "
// << ex.what();
// return;
// }

//
// After setting the schema, this gets called and kicks off our
// data processing "loop"
//
auto result_schema_write_handler =
[&, this]
(const boost::system::error_code& ec, std::size_t bytes_transferred)
Expand Down
23 changes: 14 additions & 9 deletions modules/image/src/libo3d3xx_image/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,22 @@ o3d3xx::ImageBuffer::Organize()
this->amp_.create(height, width, CV_16UC1);
this->raw_amp_.create(height, width, CV_16UC1);

// move index pointers to where pixel data starts
cidx += o3d3xx::IMG_CHUNK_HEADER_SZ;
didx += RDIST_OK ? o3d3xx::IMG_CHUNK_HEADER_SZ : 0;
uidx += UVEC_OK ? o3d3xx::IMG_CHUNK_HEADER_SZ : 0;
aidx += AMP_OK ? o3d3xx::IMG_CHUNK_HEADER_SZ : 0;
raw_aidx += RAW_AMP_OK ? o3d3xx::IMG_CHUNK_HEADER_SZ : 0;
// move index pointers to where pixel data starts -- we assume
// (I think safely) that all header sizes will be uniform in the data stream,

This comment has been minimized.

Copy link
@graugans

graugans Nov 8, 2016

Member

Yes, all data headers can be considered to be uniform

// so, we use our invariant of the confidence image header
std::uint32_t pixel_data_offset =
o3d3xx::mkval<std::uint32_t>(this->bytes_.data()+cidx+8);

cidx += pixel_data_offset;
didx += RDIST_OK ? pixel_data_offset : 0;
uidx += UVEC_OK ? pixel_data_offset : 0;
aidx += AMP_OK ? pixel_data_offset : 0;
raw_aidx += RAW_AMP_OK ? pixel_data_offset : 0;
if (CARTESIAN_OK)
{
xidx += o3d3xx::IMG_CHUNK_HEADER_SZ;
yidx += o3d3xx::IMG_CHUNK_HEADER_SZ;
zidx += o3d3xx::IMG_CHUNK_HEADER_SZ;
xidx += pixel_data_offset;
yidx += pixel_data_offset;
zidx += pixel_data_offset;
}

float bad_point = std::numeric_limits<float>::quiet_NaN();
Expand Down

0 comments on commit 0e46e2d

Please sign in to comment.