Skip to content

Commit

Permalink
Version 0.40.0 (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabime authored Nov 6, 2024
1 parent 1c293c9 commit 2cb30b9
Show file tree
Hide file tree
Showing 24 changed files with 456 additions and 135 deletions.
1 change: 1 addition & 0 deletions include/RealSenseID/AuthenticateStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ enum class RSID_API AuthenticateStatus
Failure,
TooManySpoofs,
InvalidFeatures,
AmbiguiousFace,
/// serial statuses
Ok = 100,
Error,
Expand Down
12 changes: 12 additions & 0 deletions include/RealSenseID/DeviceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ class RSID_API DeviceController
* seconds to complete.
*/
Status FetchLog(std::string& log);

/**
* Get color gains packet from device and fill the red, blue values
* @return SerialStatus::Success on success.
*/
Status GetColorGains(int &red, int &blue);

/**
* Send color gains packet to device. Valid range: 0-511
* @return SerialStatus::Success on success.
*/
Status SetColorGains(int red, int blue);

private:
RealSenseID::DeviceControllerImpl* _impl = nullptr;
Expand Down
1 change: 1 addition & 0 deletions include/RealSenseID/EnrollStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ enum class RSID_API EnrollStatus
EnrollWithMaskIsForbidden, // for mask-detector : we'll forbid enroll if used wears mask.
Spoof,
InvalidFeatures,
AmbiguiousFace,
/// serial statuses
Ok = 100,
Error,
Expand Down
6 changes: 3 additions & 3 deletions include/RealSenseID/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#include <string>

#define RSID_VER_MAJOR 0
#define RSID_VER_MINOR 38
#define RSID_VER_PATCH 2
#define RSID_VER_MINOR 40
#define RSID_VER_PATCH 0

#define RSID_VERSION (RSID_VER_MAJOR * 10000 + RSID_VER_MINOR * 100 + RSID_VER_PATCH)

#define RSID_FW_VER_MAJOR 6
#define RSID_FW_VER_MAJOR 7
#define RSID_FW_VER_MINOR 0

namespace RealSenseID
Expand Down
14 changes: 7 additions & 7 deletions release_info.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"sw_version": 3802,
"sw_version_str": "0.38.2",
"fw_version": 609000301,
"fw_version_str": "6.9.0.301",
"release_url": "https://github.com/IntelRealSense/RealSenseID/releases/tag/v0.38.2",
"release_notes_url": "https://github.com/IntelRealSense/RealSenseID/blob/v0.38.2/release_notes.txt"
}
"sw_version": 4000,
"sw_version_str": "0.40.0",
"fw_version": 700000304,
"fw_version_str": "7.0.0.304",
"release_url": "https://github.com/IntelRealSense/RealSenseID/releases/tag/v0.40.0",
"release_notes_url": "https://github.com/IntelRealSense/RealSenseID/blob/v0.40.0/release_notes.txt"
}
12 changes: 12 additions & 0 deletions release_notes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Realsense ID version 0.40.0
-----------------------------------
* New firmware release - version 7.0.0.304
* Improved TNR and TPR for Anti-Spoofing
* Face authentication TPR/TNR improvement (requires old database conversion)
* Face detection improvement
* Import database bug fix
* New host SW:
* CRC Optimization
* FW upgrade enhancement
* Added Set/Get color gains to API

Realsense ID version 0.38.2
-----------------------------------
* New firmware release - version 6.9.0.301
Expand Down
9 changes: 9 additions & 0 deletions src/DeviceController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,14 @@ Status DeviceController::FetchLog(std::string& log)
return _impl->FetchLog(log);
}

Status DeviceController::GetColorGains(int &red, int &blue)
{
return _impl->GetColorGains(red, blue);
}

Status DeviceController::SetColorGains(int red, int blue)
{
return _impl->SetColorGains(red, blue);
}

} // namespace RealSenseID
111 changes: 99 additions & 12 deletions src/DeviceControllerImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <sstream>
#include <regex>
#include <cctype>

#include <stdio.h>

#ifdef _WIN32
#include "PacketManager/WindowsSerial.h"
Expand Down Expand Up @@ -75,7 +75,6 @@ Status DeviceControllerImpl::QueryFirmwareVersion(std::string& version)
{
// clear output version string to avoid returning garbage
version.clear();

try
{
std::string version_in_progress;
Expand Down Expand Up @@ -109,24 +108,30 @@ Status DeviceControllerImpl::QueryFirmwareVersion(std::string& version)
}
}

// parse lines of module versions .e.g.
// ASDISP : 18.9.24.0
// NNLED : 15.9.24.0
static const std::regex module_regex {R"((\w+) : ([\d\.]+))"};
std::stringstream ss(buffer);
std::string line;
while (std::getline(ss, line, '\n'))
{
static const std::regex module_regex {
R"((OPFW|NNLED|DNET|RECOG|YOLO|AS2DLR|NNLAS|NNLEDR|SPOOFS|ASDISP) : ([\d\.]+))"};
{
std::smatch match;

auto match_ok = std::regex_search(line, match, module_regex);

if (match_ok)
{
auto version_number = match[2].str();
if (version_number == "0.0.0.0") // ignore, unused module
{
continue;
}
if (!version_in_progress.empty())
version_in_progress += '|';

version_in_progress += match[1].str();
version_in_progress += ':';
version_in_progress += match[2].str();
version_in_progress += version_number;
}
}

Expand Down Expand Up @@ -301,7 +306,9 @@ Status DeviceControllerImpl::Ping()
}

// create a ping data packet with random data
char random_data[sizeof(DataMessage::data)];
// create a ping data packet with random data
char random_data[512];
static_assert(sizeof(random_data) <= sizeof(DataMessage::data), "Random data size exceeds max allowed");
Randomizer::Instance().GenerateRandom((unsigned char*)random_data, sizeof(random_data));
DataPacket ping_packet {MsgId::Ping, random_data, sizeof(random_data)};

Expand Down Expand Up @@ -388,8 +395,8 @@ Status DeviceControllerImpl::FetchLog(std::string& result)
{
result.erase(pos);
}
// expect the START_OF_LOG token

// expect the START_OF_LOG token
pos = result.find(start_token);
if (pos != std::string::npos)
{
Expand All @@ -405,9 +412,9 @@ Status DeviceControllerImpl::FetchLog(std::string& result)
// make sure it ends with '\n'
if (!result.empty() && result.back() != '\n')
{
result.push_back('\n');
result.push_back('\n');
}

LOG_DEBUG(LOG_TAG, "Got %zu log bytes", result.size());
return Status::Ok;
}
Expand All @@ -422,4 +429,84 @@ Status DeviceControllerImpl::FetchLog(std::string& result)
return Status::Error;
}
}

Status DeviceControllerImpl::GetColorGains(int& red, int& blue)
{
const char* const cmd = PacketManager::Commands::get_color_gains;
auto send_status = _serial->SendBytes(cmd, ::strlen(cmd));
if (send_status != PacketManager::SerialStatus::Ok)
{
LOG_ERROR(LOG_TAG, "Failed sending cm command");
return ToStatus(send_status);
}

// receive data until no more is available
constexpr size_t max_buffer_size = 128;
char buffer[max_buffer_size] = {0};
for (size_t i = 0; i < max_buffer_size - 1; ++i)
{
auto status = _serial->RecvBytes(&buffer[i], 1);
// timeout is legal for the final byte, because we do not know the expected data size
if (status == PacketManager::SerialStatus::RecvTimeout)
break;

// other error are still not accepted
if (status != PacketManager::SerialStatus::Ok)
{
LOG_ERROR(LOG_TAG, "Failed reading serial number data");
return ToStatus(status);
}
}

// extract red blue numbers e.g [123 511]
try
{
std::string input(buffer);
std::smatch matches;
static const std::regex pattern {R"(\[(\d+)\s(\d+)\])"};
if (std::regex_search(input, matches, pattern))
{
red = std::stoi(matches[1].str());
blue = std::stoi(matches[2].str());
return Status::Ok;
}
else
{
return Status::Error;
}
}
catch (const std::exception& ex)
{
LOG_EXCEPTION(LOG_TAG, ex);
return Status::Error;
}
catch (...)
{
LOG_ERROR(LOG_TAG, "Unknown exception in GetColorGains");
return Status::Error;
}
}

Status DeviceControllerImpl::SetColorGains(int red, int blue)
{
constexpr int max_value = 511;
constexpr int min_value = 0;
if (red < min_value || red > max_value || blue < min_value || blue > max_value)
{
LOG_ERROR(LOG_TAG, "Invalid color gain values");
return Status::Error;
}

char buf[64];
const char* const cmd = PacketManager::Commands::set_color_gains;
snprintf(buf, sizeof(buf), cmd, red, blue);
auto send_status = _serial->SendBytes(buf, ::strlen(buf));
if (send_status != PacketManager::SerialStatus::Ok)
{
LOG_ERROR(LOG_TAG, "Failed sending cm command");
}
return ToStatus(send_status);
}


} // namespace RealSenseID
2 changes: 2 additions & 0 deletions src/DeviceControllerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class DeviceControllerImpl
Status QueryOtpVersion(uint8_t& otpVer);
Status Ping();
Status FetchLog(std::string& log);
Status GetColorGains(int& red, int& blue);
Status SetColorGains(int red, int blue);

private:
std::unique_ptr<PacketManager::SerialConnection> _serial;
Expand Down
34 changes: 33 additions & 1 deletion src/FaceAuthenticatorImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1703,7 +1703,39 @@ Status FaceAuthenticatorImpl::SetUsersFaceprints(UserFaceprints_t* user_features
continue;
}
}
return all_users_set ? Status::Ok : Status::Error;
if (!all_users_set)
{
return Status::Error;
}

// If succeeded setting all users, tell the device to save the detures DB to its storage
auto save_db_packet = std::make_unique<PacketManager::FaPacket>(PacketManager::MsgId::SaveDatabase);
status = _session.SendPacket(*save_db_packet);
if (status != PacketManager::SerialStatus::Ok)
{
LOG_ERROR(LOG_TAG, "Failed sending SaveDatabase packet (status %d)", (int)status);
all_users_set = false;
}
// Wait for savedb reply
status = _session.RecvFaPacket(*save_db_packet);
if (status != PacketManager::SerialStatus::Ok)
{
LOG_ERROR(LOG_TAG, "Failed receiving savedb reply packet (status %d)", static_cast<int>(status));
return ToStatus(status);
}
auto msg_id = save_db_packet->header.id;
if (PacketManager::MsgId::Reply != msg_id)
{
LOG_ERROR(LOG_TAG, "Got unexpected message id %d instead of MsgId::Reply", static_cast<int>(msg_id));
return Status::Error;
}
auto status_code = save_db_packet->GetStatusCode();
auto final_status = Status(status_code);
if (final_status != Status::Ok)
{
LOG_ERROR(LOG_TAG, "Failed saving DB to device. Status: %d", static_cast<int>(status_code));
}
return final_status;
}


Expand Down
Loading

0 comments on commit 2cb30b9

Please sign in to comment.