fix(device):fix the image info bug for s1030
This commit is contained in:
parent
a06786c16d
commit
5b8301c601
|
@ -127,7 +127,7 @@ Channels::Channels(std::shared_ptr<uvc::device> device)
|
||||||
imu_sn_(0),
|
imu_sn_(0),
|
||||||
imu_callback_(nullptr) {
|
imu_callback_(nullptr) {
|
||||||
VLOG(2) << __func__;
|
VLOG(2) << __func__;
|
||||||
UpdateControlInfos();
|
// UpdateControlInfos();
|
||||||
}
|
}
|
||||||
|
|
||||||
Channels::~Channels() {
|
Channels::~Channels() {
|
||||||
|
|
|
@ -51,17 +51,7 @@ const std::map<Model, std::map<Capabilities, StreamRequests>>
|
||||||
stream_requests_map = {
|
stream_requests_map = {
|
||||||
{Model::STANDARD,
|
{Model::STANDARD,
|
||||||
{{Capabilities::STEREO, {
|
{{Capabilities::STEREO, {
|
||||||
{752, 480, Format::YUYV, 10},
|
{752, 480, Format::YUYV, 25}}
|
||||||
{752, 480, Format::YUYV, 15},
|
|
||||||
{752, 480, Format::YUYV, 20},
|
|
||||||
{752, 480, Format::YUYV, 25},
|
|
||||||
{752, 480, Format::YUYV, 30},
|
|
||||||
{752, 480, Format::YUYV, 35},
|
|
||||||
{752, 480, Format::YUYV, 40},
|
|
||||||
{752, 480, Format::YUYV, 45},
|
|
||||||
{752, 480, Format::YUYV, 50},
|
|
||||||
{752, 480, Format::YUYV, 55},
|
|
||||||
{752, 480, Format::YUYV, 60}}
|
|
||||||
}}
|
}}
|
||||||
},
|
},
|
||||||
{Model::STANDARD2,
|
{Model::STANDARD2,
|
||||||
|
|
|
@ -13,7 +13,10 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
#include "mynteye/device/standard/streams_adapter_s.h"
|
#include "mynteye/device/standard/streams_adapter_s.h"
|
||||||
|
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
#include "mynteye/logger.h"
|
#include "mynteye/logger.h"
|
||||||
|
#include "mynteye/device/types.h"
|
||||||
|
|
||||||
MYNTEYE_BEGIN_NAMESPACE
|
MYNTEYE_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
@ -45,6 +48,55 @@ bool unpack_right_img_pixels(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool unpack_stereo_img_data(
|
||||||
|
const void *data, const StreamRequest &request, ImgData *img) {
|
||||||
|
CHECK_NOTNULL(img);
|
||||||
|
|
||||||
|
auto data_new = reinterpret_cast<const std::uint8_t *>(data);
|
||||||
|
std::size_t data_n =
|
||||||
|
request.width * request.height * bytes_per_pixel(request.format);
|
||||||
|
auto data_end = data_new + data_n;
|
||||||
|
|
||||||
|
std::size_t packet_n = sizeof(ImagePacketS1);
|
||||||
|
std::vector<std::uint8_t> packet(packet_n);
|
||||||
|
std::reverse_copy(data_end - packet_n, data_end, packet.begin());
|
||||||
|
|
||||||
|
ImagePacketS1 img_packet(packet.data());
|
||||||
|
// LOG(INFO) << "ImagePacket: header=0x" << std::hex <<
|
||||||
|
// static_cast<int>(img_packet.header)
|
||||||
|
// << ", size=0x" << std::hex << static_cast<int>(img_packet.size)
|
||||||
|
// << ", frame_id="<< std::dec << img_packet.frame_id
|
||||||
|
// << ", timestamp="<< std::dec << img_packet.timestamp
|
||||||
|
// << ", exposure_time="<< std::dec << img_packet.exposure_time
|
||||||
|
// << ", checksum=0x" << std::hex << static_cast<int>(img_packet.checksum);
|
||||||
|
|
||||||
|
if (img_packet.header != 0x3B) {
|
||||||
|
VLOG(2) << "Image packet header must be 0x3B, but 0x" << std::hex
|
||||||
|
<< std::uppercase << std::setw(2) << std::setfill('0')
|
||||||
|
<< static_cast<int>(img_packet.header) << " now";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::uint8_t checksum = 0;
|
||||||
|
for (std::size_t i = 2, n = packet_n - 2; i <= n; i++) { // content: [2,9]
|
||||||
|
checksum = (checksum ^ packet[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (img_packet.checksum != checksum) {
|
||||||
|
VLOG(2) << "Image packet checksum should be 0x" << std::hex
|
||||||
|
<< std::uppercase << std::setw(2) << std::setfill('0')
|
||||||
|
<< static_cast<int>(img_packet.checksum) << ", but 0x"
|
||||||
|
<< std::setw(2) << std::setfill('0') << static_cast<int>(checksum)
|
||||||
|
<< " now";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
img->frame_id = img_packet.frame_id;
|
||||||
|
img->timestamp = static_cast<uint64_t>(img_packet.timestamp * 10);
|
||||||
|
img->exposure_time = img_packet.exposure_time;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
StandardStreamsAdapter::StandardStreamsAdapter() {
|
StandardStreamsAdapter::StandardStreamsAdapter() {
|
||||||
|
|
|
@ -13,7 +13,10 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
#include "mynteye/device/standard2/streams_adapter_s2.h"
|
#include "mynteye/device/standard2/streams_adapter_s2.h"
|
||||||
|
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
#include "mynteye/logger.h"
|
#include "mynteye/logger.h"
|
||||||
|
#include "mynteye/device/types.h"
|
||||||
|
|
||||||
MYNTEYE_BEGIN_NAMESPACE
|
MYNTEYE_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
@ -63,6 +66,55 @@ bool unpack_right_img_pixels(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool unpack_stereo_img_data(
|
||||||
|
const void *data, const StreamRequest &request, ImgData *img) {
|
||||||
|
CHECK_NOTNULL(img);
|
||||||
|
|
||||||
|
auto data_new = reinterpret_cast<const std::uint8_t *>(data);
|
||||||
|
std::size_t data_n =
|
||||||
|
request.width * request.height * bytes_per_pixel(request.format);
|
||||||
|
auto data_end = data_new + data_n;
|
||||||
|
|
||||||
|
std::size_t packet_n = sizeof(ImagePacketS2);
|
||||||
|
std::vector<std::uint8_t> packet(packet_n);
|
||||||
|
std::reverse_copy(data_end - packet_n, data_end, packet.begin());
|
||||||
|
|
||||||
|
ImagePacketS2 img_packet(packet.data());
|
||||||
|
// LOG(INFO) << "ImagePacket: header=0x" << std::hex <<
|
||||||
|
// static_cast<int>(img_packet.header)
|
||||||
|
// << ", size=0x" << std::hex << static_cast<int>(img_packet.size)
|
||||||
|
// << ", frame_id="<< std::dec << img_packet.frame_id
|
||||||
|
// << ", timestamp="<< std::dec << img_packet.timestamp
|
||||||
|
// << ", exposure_time="<< std::dec << img_packet.exposure_time
|
||||||
|
// << ", checksum=0x" << std::hex << static_cast<int>(img_packet.checksum);
|
||||||
|
|
||||||
|
if (img_packet.header != 0x3B) {
|
||||||
|
VLOG(2) << "Image packet header must be 0x3B, but 0x" << std::hex
|
||||||
|
<< std::uppercase << std::setw(2) << std::setfill('0')
|
||||||
|
<< static_cast<int>(img_packet.header) << " now";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::uint8_t checksum = 0;
|
||||||
|
for (std::size_t i = 2, n = packet_n - 2; i <= n; i++) { // content: [2,9]
|
||||||
|
checksum = (checksum ^ packet[i]);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if (img_packet.checksum != checksum) {
|
||||||
|
VLOG(2) << "Image packet checksum should be 0x" << std::hex
|
||||||
|
<< std::uppercase << std::setw(2) << std::setfill('0')
|
||||||
|
<< static_cast<int>(img_packet.checksum) << ", but 0x"
|
||||||
|
<< std::setw(2) << std::setfill('0') << static_cast<int>(checksum)
|
||||||
|
<< " now";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
img->frame_id = img_packet.frame_id;
|
||||||
|
img->timestamp = img_packet.timestamp;
|
||||||
|
img->exposure_time = img_packet.exposure_time;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Standard2StreamsAdapter::Standard2StreamsAdapter() {
|
Standard2StreamsAdapter::Standard2StreamsAdapter() {
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <iomanip>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "mynteye/logger.h"
|
#include "mynteye/logger.h"
|
||||||
|
@ -23,55 +22,6 @@
|
||||||
|
|
||||||
MYNTEYE_BEGIN_NAMESPACE
|
MYNTEYE_BEGIN_NAMESPACE
|
||||||
|
|
||||||
bool unpack_stereo_img_data(
|
|
||||||
const void *data, const StreamRequest &request, ImgData *img) {
|
|
||||||
CHECK_NOTNULL(img);
|
|
||||||
|
|
||||||
auto data_new = reinterpret_cast<const std::uint8_t *>(data);
|
|
||||||
std::size_t data_n =
|
|
||||||
request.width * request.height * bytes_per_pixel(request.format);
|
|
||||||
auto data_end = data_new + data_n;
|
|
||||||
|
|
||||||
std::size_t packet_n = sizeof(ImagePacket);
|
|
||||||
std::vector<std::uint8_t> packet(packet_n);
|
|
||||||
std::reverse_copy(data_end - packet_n, data_end, packet.begin());
|
|
||||||
|
|
||||||
ImagePacket img_packet(packet.data());
|
|
||||||
// LOG(INFO) << "ImagePacket: header=0x" << std::hex <<
|
|
||||||
// static_cast<int>(img_packet.header)
|
|
||||||
// << ", size=0x" << std::hex << static_cast<int>(img_packet.size)
|
|
||||||
// << ", frame_id="<< std::dec << img_packet.frame_id
|
|
||||||
// << ", timestamp="<< std::dec << img_packet.timestamp
|
|
||||||
// << ", exposure_time="<< std::dec << img_packet.exposure_time
|
|
||||||
// << ", checksum=0x" << std::hex << static_cast<int>(img_packet.checksum);
|
|
||||||
|
|
||||||
if (img_packet.header != 0x3B) {
|
|
||||||
VLOG(2) << "Image packet header must be 0x3B, but 0x" << std::hex
|
|
||||||
<< std::uppercase << std::setw(2) << std::setfill('0')
|
|
||||||
<< static_cast<int>(img_packet.header) << " now";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::uint8_t checksum = 0;
|
|
||||||
for (std::size_t i = 2, n = packet_n - 2; i <= n; i++) { // content: [2,9]
|
|
||||||
checksum = (checksum ^ packet[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (img_packet.checksum != checksum) {
|
|
||||||
VLOG(2) << "Image packet checksum should be 0x" << std::hex
|
|
||||||
<< std::uppercase << std::setw(2) << std::setfill('0')
|
|
||||||
<< static_cast<int>(img_packet.checksum) << ", but 0x"
|
|
||||||
<< std::setw(2) << std::setfill('0') << static_cast<int>(checksum)
|
|
||||||
<< " now";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
img->frame_id = img_packet.frame_id;
|
|
||||||
img->timestamp = img_packet.timestamp;
|
|
||||||
img->exposure_time = img_packet.exposure_time;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Streams::Streams(const std::shared_ptr<StreamsAdapter> &adapter)
|
Streams::Streams(const std::shared_ptr<StreamsAdapter> &adapter)
|
||||||
: key_streams_(std::move(adapter->GetKeyStreams())),
|
: key_streams_(std::move(adapter->GetKeyStreams())),
|
||||||
stream_capabilities_(std::move(adapter->GetStreamCapabilities())),
|
stream_capabilities_(std::move(adapter->GetStreamCapabilities())),
|
||||||
|
|
|
@ -28,8 +28,10 @@
|
||||||
|
|
||||||
MYNTEYE_BEGIN_NAMESPACE
|
MYNTEYE_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
/*
|
||||||
extern bool unpack_stereo_img_data(
|
extern bool unpack_stereo_img_data(
|
||||||
const void *data, const StreamRequest &request, ImgData *img);
|
const void *data, const StreamRequest &request, ImgData *img);
|
||||||
|
*/
|
||||||
|
|
||||||
class StreamsAdapter;
|
class StreamsAdapter;
|
||||||
|
|
||||||
|
|
|
@ -140,10 +140,10 @@ struct MYNTEYE_API DeviceInfo {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup datatypes
|
* @ingroup datatypes
|
||||||
* Image packet.
|
* Image packet for standand 2.
|
||||||
*/
|
*/
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
struct ImagePacket {
|
struct ImagePacketS2 {
|
||||||
std::uint8_t header;
|
std::uint8_t header;
|
||||||
std::uint8_t size;
|
std::uint8_t size;
|
||||||
std::uint16_t frame_id;
|
std::uint16_t frame_id;
|
||||||
|
@ -151,8 +151,8 @@ struct ImagePacket {
|
||||||
std::uint16_t exposure_time;
|
std::uint16_t exposure_time;
|
||||||
std::uint8_t checksum;
|
std::uint8_t checksum;
|
||||||
|
|
||||||
ImagePacket() = default;
|
ImagePacketS2() = default;
|
||||||
explicit ImagePacket(std::uint8_t *data) {
|
explicit ImagePacketS2(std::uint8_t *data) {
|
||||||
from_data(data);
|
from_data(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,6 +174,36 @@ struct ImagePacket {
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup datatypes
|
||||||
|
* Image packet for standand 1.
|
||||||
|
*/
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
struct ImagePacketS1 {
|
||||||
|
std::uint8_t header;
|
||||||
|
std::uint8_t size;
|
||||||
|
std::uint16_t frame_id;
|
||||||
|
std::uint32_t timestamp;
|
||||||
|
std::uint16_t exposure_time;
|
||||||
|
std::uint8_t checksum;
|
||||||
|
|
||||||
|
ImagePacketS1() = default;
|
||||||
|
explicit ImagePacketS1(std::uint8_t *data) {
|
||||||
|
from_data(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_data(std::uint8_t *data) {
|
||||||
|
header = *data;
|
||||||
|
size = *(data + 1);
|
||||||
|
frame_id = (*(data + 2) << 8) | *(data + 3);
|
||||||
|
timestamp = (*(data + 4) << 24) | (*(data + 5) << 16) | (*(data + 6) << 8) |
|
||||||
|
*(data + 7);
|
||||||
|
exposure_time = (*(data + 8) << 8) | *(data + 9);
|
||||||
|
checksum = *(data + 10);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup datatypes
|
* @ingroup datatypes
|
||||||
* Imu request packet.
|
* Imu request packet.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user