So due to automation purpose we created a nuitrack licence activation tool, modified from this little project:
here are part of the source code we did (with extra debug informations):
int main(int argc, char* argv[]) {
int errorCode = EXIT_SUCCESS;
//nuitrack_device_activation -l license
try {
cxxopts::Options options("NuitrackActivation", "One line description of MyProgram");
options.allow_unrecognised_options().add_options()
("l, license", "license Key", cxxopts::value<std::string>(), "");
std::string license;
auto result = options.parse(argc, argv);
if(result.count("l"))
{
license = result["l"].as<std::string>();
}
std::cout<<"license = "<< license<<std::endl;
Nuitrack::init();
const auto device = selectDevice();
activateDevice(device, license);
}
catch (const LicenseNotAcquiredException& e)
{
std::cerr << "LicenseNotAcquired exception (ExceptionType: " << e.type() << ')' << std::endl;
errorCode = EXIT_FAILURE;
}
catch (const Exception& e)
{
std::cerr << "Exception: " << e.what() << std::endl;
errorCode = EXIT_FAILURE;
}
Nuitrack::release();
return errorCode;
}
NuitrackDevice::Ptr selectDevice() {
std::cout<<"selectDevice started "<< std::endl;
std::vector<NuitrackDevice::Ptr> devices = Nuitrack::getDeviceList();
std::cout<<"device grabbed "<< std::endl;
if (devices.empty())
throw Exception("No devices found.");
console::Table<4> table({"Index", "Name", "Serial Number", "License"});
std::cout<<"table header created "<< std::endl;
for (std::size_t i = 0; i < devices.size(); i++)
{
const auto& device = devices[i];
table.addRow({
std::to_string(i),
device->getInfo(DeviceInfoType::DEVICE_NAME),
device->getInfo(DeviceInfoType::SERIAL_NUMBER),
toString(device->getActivationStatus())
});
}
std::cout << "\nAvailable devices: (0 will be used by default)" << std::endl;
table.printTable();
int devIndex = 0;
return devices[devIndex];
}
void activateDevice(NuitrackDevice::Ptr device, std::string manualLicenseKey) {
bool isActivated = device->getActivationStatus() != ActivationStatus::NONE;
if (isActivated)
{
std::cout << "Device already activated" << std::endl;
}
if (!isActivated) {
device->activate(manualLicenseKey);
std::cout << "Activation status: " << toString(device->getActivationStatus()) << std::endl;
}
}
(Not all source code are pasted here)
We want to run it on Linux (Ubuntu) for device activation, however, on some of our devices it works, but some doesn’t, it quits at the code: Nuitrack::getDeviceList, and the log “device grabbed” doesn’t appear. Can someone tells us what’s going on here?
More information:
Device 1 (working): Ubuntu 18.04.6, with GNOME UI, nuitrack 0.35.12, Kinect for xbox one camera
Device 2 (not working): Ubuntu 20.04, without UI (just TTY), nuitrack 0.35.12, Kinect for xbox one camera.
Device 3 (working): Ubuntu 20.04, with GNOME UI, nuitrack 0.35.12, Kinect for xbox one camera.
Also on device 2, license can be activated through nuitrack ui, however, without GNOME, running nuitrack_device_api_sample gives the same fail result.
On Device 3, we tested in tty, it has the same error behaviour, the device list doesn’t print. We tried to enable xserver, but with same fail result.