Skip to content

Commit 2cb30b9

Browse files
authored
Version 0.40.0 (#168)
1 parent 1c293c9 commit 2cb30b9

24 files changed

+456
-135
lines changed

include/RealSenseID/AuthenticateStatus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ enum class RSID_API AuthenticateStatus
3333
Failure,
3434
TooManySpoofs,
3535
InvalidFeatures,
36+
AmbiguiousFace,
3637
/// serial statuses
3738
Ok = 100,
3839
Error,

include/RealSenseID/DeviceController.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ class RSID_API DeviceController
8383
* seconds to complete.
8484
*/
8585
Status FetchLog(std::string& log);
86+
87+
/**
88+
* Get color gains packet from device and fill the red, blue values
89+
* @return SerialStatus::Success on success.
90+
*/
91+
Status GetColorGains(int &red, int &blue);
92+
93+
/**
94+
* Send color gains packet to device. Valid range: 0-511
95+
* @return SerialStatus::Success on success.
96+
*/
97+
Status SetColorGains(int red, int blue);
8698

8799
private:
88100
RealSenseID::DeviceControllerImpl* _impl = nullptr;

include/RealSenseID/EnrollStatus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ enum class RSID_API EnrollStatus
3333
EnrollWithMaskIsForbidden, // for mask-detector : we'll forbid enroll if used wears mask.
3434
Spoof,
3535
InvalidFeatures,
36+
AmbiguiousFace,
3637
/// serial statuses
3738
Ok = 100,
3839
Error,

include/RealSenseID/Version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
#include <string>
99

1010
#define RSID_VER_MAJOR 0
11-
#define RSID_VER_MINOR 38
12-
#define RSID_VER_PATCH 2
11+
#define RSID_VER_MINOR 40
12+
#define RSID_VER_PATCH 0
1313

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

16-
#define RSID_FW_VER_MAJOR 6
16+
#define RSID_FW_VER_MAJOR 7
1717
#define RSID_FW_VER_MINOR 0
1818

1919
namespace RealSenseID

release_info.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"sw_version": 3802,
3-
"sw_version_str": "0.38.2",
4-
"fw_version": 609000301,
5-
"fw_version_str": "6.9.0.301",
6-
"release_url": "https://github.com/IntelRealSense/RealSenseID/releases/tag/v0.38.2",
7-
"release_notes_url": "https://github.com/IntelRealSense/RealSenseID/blob/v0.38.2/release_notes.txt"
8-
}
2+
"sw_version": 4000,
3+
"sw_version_str": "0.40.0",
4+
"fw_version": 700000304,
5+
"fw_version_str": "7.0.0.304",
6+
"release_url": "https://github.com/IntelRealSense/RealSenseID/releases/tag/v0.40.0",
7+
"release_notes_url": "https://github.com/IntelRealSense/RealSenseID/blob/v0.40.0/release_notes.txt"
8+
}

release_notes.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
Realsense ID version 0.40.0
2+
-----------------------------------
3+
* New firmware release - version 7.0.0.304
4+
* Improved TNR and TPR for Anti-Spoofing
5+
* Face authentication TPR/TNR improvement (requires old database conversion)
6+
* Face detection improvement
7+
* Import database bug fix
8+
* New host SW:
9+
* CRC Optimization
10+
* FW upgrade enhancement
11+
* Added Set/Get color gains to API
12+
113
Realsense ID version 0.38.2
214
-----------------------------------
315
* New firmware release - version 6.9.0.301

src/DeviceController.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,14 @@ Status DeviceController::FetchLog(std::string& log)
6161
return _impl->FetchLog(log);
6262
}
6363

64+
Status DeviceController::GetColorGains(int &red, int &blue)
65+
{
66+
return _impl->GetColorGains(red, blue);
67+
}
68+
69+
Status DeviceController::SetColorGains(int red, int blue)
70+
{
71+
return _impl->SetColorGains(red, blue);
72+
}
6473

6574
} // namespace RealSenseID

src/DeviceControllerImpl.cc

Lines changed: 99 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <sstream>
1111
#include <regex>
1212
#include <cctype>
13-
13+
#include <stdio.h>
1414

1515
#ifdef _WIN32
1616
#include "PacketManager/WindowsSerial.h"
@@ -75,7 +75,6 @@ Status DeviceControllerImpl::QueryFirmwareVersion(std::string& version)
7575
{
7676
// clear output version string to avoid returning garbage
7777
version.clear();
78-
7978
try
8079
{
8180
std::string version_in_progress;
@@ -109,24 +108,30 @@ Status DeviceControllerImpl::QueryFirmwareVersion(std::string& version)
109108
}
110109
}
111110

111+
// parse lines of module versions .e.g.
112+
// ASDISP : 18.9.24.0
113+
// NNLED : 15.9.24.0
114+
static const std::regex module_regex {R"((\w+) : ([\d\.]+))"};
112115
std::stringstream ss(buffer);
113116
std::string line;
114117
while (std::getline(ss, line, '\n'))
115-
{
116-
static const std::regex module_regex {
117-
R"((OPFW|NNLED|DNET|RECOG|YOLO|AS2DLR|NNLAS|NNLEDR|SPOOFS|ASDISP) : ([\d\.]+))"};
118+
{
118119
std::smatch match;
119-
120120
auto match_ok = std::regex_search(line, match, module_regex);
121121

122122
if (match_ok)
123123
{
124+
auto version_number = match[2].str();
125+
if (version_number == "0.0.0.0") // ignore, unused module
126+
{
127+
continue;
128+
}
124129
if (!version_in_progress.empty())
125130
version_in_progress += '|';
126131

127132
version_in_progress += match[1].str();
128133
version_in_progress += ':';
129-
version_in_progress += match[2].str();
134+
version_in_progress += version_number;
130135
}
131136
}
132137

@@ -301,7 +306,9 @@ Status DeviceControllerImpl::Ping()
301306
}
302307

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

@@ -388,8 +395,8 @@ Status DeviceControllerImpl::FetchLog(std::string& result)
388395
{
389396
result.erase(pos);
390397
}
391-
392-
// expect the START_OF_LOG token
398+
399+
// expect the START_OF_LOG token
393400
pos = result.find(start_token);
394401
if (pos != std::string::npos)
395402
{
@@ -405,9 +412,9 @@ Status DeviceControllerImpl::FetchLog(std::string& result)
405412
// make sure it ends with '\n'
406413
if (!result.empty() && result.back() != '\n')
407414
{
408-
result.push_back('\n');
415+
result.push_back('\n');
409416
}
410-
417+
411418
LOG_DEBUG(LOG_TAG, "Got %zu log bytes", result.size());
412419
return Status::Ok;
413420
}
@@ -422,4 +429,84 @@ Status DeviceControllerImpl::FetchLog(std::string& result)
422429
return Status::Error;
423430
}
424431
}
432+
433+
Status DeviceControllerImpl::GetColorGains(int& red, int& blue)
434+
{
435+
const char* const cmd = PacketManager::Commands::get_color_gains;
436+
auto send_status = _serial->SendBytes(cmd, ::strlen(cmd));
437+
if (send_status != PacketManager::SerialStatus::Ok)
438+
{
439+
LOG_ERROR(LOG_TAG, "Failed sending cm command");
440+
return ToStatus(send_status);
441+
}
442+
443+
// receive data until no more is available
444+
constexpr size_t max_buffer_size = 128;
445+
char buffer[max_buffer_size] = {0};
446+
for (size_t i = 0; i < max_buffer_size - 1; ++i)
447+
{
448+
auto status = _serial->RecvBytes(&buffer[i], 1);
449+
// timeout is legal for the final byte, because we do not know the expected data size
450+
if (status == PacketManager::SerialStatus::RecvTimeout)
451+
break;
452+
453+
// other error are still not accepted
454+
if (status != PacketManager::SerialStatus::Ok)
455+
{
456+
LOG_ERROR(LOG_TAG, "Failed reading serial number data");
457+
return ToStatus(status);
458+
}
459+
}
460+
461+
// extract red blue numbers e.g [123 511]
462+
try
463+
{
464+
std::string input(buffer);
465+
std::smatch matches;
466+
static const std::regex pattern {R"(\[(\d+)\s(\d+)\])"};
467+
if (std::regex_search(input, matches, pattern))
468+
{
469+
red = std::stoi(matches[1].str());
470+
blue = std::stoi(matches[2].str());
471+
return Status::Ok;
472+
}
473+
else
474+
{
475+
return Status::Error;
476+
}
477+
}
478+
catch (const std::exception& ex)
479+
{
480+
LOG_EXCEPTION(LOG_TAG, ex);
481+
return Status::Error;
482+
}
483+
catch (...)
484+
{
485+
LOG_ERROR(LOG_TAG, "Unknown exception in GetColorGains");
486+
return Status::Error;
487+
}
488+
}
489+
490+
Status DeviceControllerImpl::SetColorGains(int red, int blue)
491+
{
492+
constexpr int max_value = 511;
493+
constexpr int min_value = 0;
494+
if (red < min_value || red > max_value || blue < min_value || blue > max_value)
495+
{
496+
LOG_ERROR(LOG_TAG, "Invalid color gain values");
497+
return Status::Error;
498+
}
499+
500+
char buf[64];
501+
const char* const cmd = PacketManager::Commands::set_color_gains;
502+
snprintf(buf, sizeof(buf), cmd, red, blue);
503+
auto send_status = _serial->SendBytes(buf, ::strlen(buf));
504+
if (send_status != PacketManager::SerialStatus::Ok)
505+
{
506+
LOG_ERROR(LOG_TAG, "Failed sending cm command");
507+
}
508+
return ToStatus(send_status);
509+
}
510+
511+
425512
} // namespace RealSenseID

src/DeviceControllerImpl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class DeviceControllerImpl
2929
Status QueryOtpVersion(uint8_t& otpVer);
3030
Status Ping();
3131
Status FetchLog(std::string& log);
32+
Status GetColorGains(int& red, int& blue);
33+
Status SetColorGains(int red, int blue);
3234

3335
private:
3436
std::unique_ptr<PacketManager::SerialConnection> _serial;

src/FaceAuthenticatorImpl.cc

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1703,7 +1703,39 @@ Status FaceAuthenticatorImpl::SetUsersFaceprints(UserFaceprints_t* user_features
17031703
continue;
17041704
}
17051705
}
1706-
return all_users_set ? Status::Ok : Status::Error;
1706+
if (!all_users_set)
1707+
{
1708+
return Status::Error;
1709+
}
1710+
1711+
// If succeeded setting all users, tell the device to save the detures DB to its storage
1712+
auto save_db_packet = std::make_unique<PacketManager::FaPacket>(PacketManager::MsgId::SaveDatabase);
1713+
status = _session.SendPacket(*save_db_packet);
1714+
if (status != PacketManager::SerialStatus::Ok)
1715+
{
1716+
LOG_ERROR(LOG_TAG, "Failed sending SaveDatabase packet (status %d)", (int)status);
1717+
all_users_set = false;
1718+
}
1719+
// Wait for savedb reply
1720+
status = _session.RecvFaPacket(*save_db_packet);
1721+
if (status != PacketManager::SerialStatus::Ok)
1722+
{
1723+
LOG_ERROR(LOG_TAG, "Failed receiving savedb reply packet (status %d)", static_cast<int>(status));
1724+
return ToStatus(status);
1725+
}
1726+
auto msg_id = save_db_packet->header.id;
1727+
if (PacketManager::MsgId::Reply != msg_id)
1728+
{
1729+
LOG_ERROR(LOG_TAG, "Got unexpected message id %d instead of MsgId::Reply", static_cast<int>(msg_id));
1730+
return Status::Error;
1731+
}
1732+
auto status_code = save_db_packet->GetStatusCode();
1733+
auto final_status = Status(status_code);
1734+
if (final_status != Status::Ok)
1735+
{
1736+
LOG_ERROR(LOG_TAG, "Failed saving DB to device. Status: %d", static_cast<int>(status_code));
1737+
}
1738+
return final_status;
17071739
}
17081740

17091741

0 commit comments

Comments
 (0)