78 lines
2.3 KiB
C++
78 lines
2.3 KiB
C++
#include "hw/hw_factory.h"
|
|
|
|
#include <cctype>
|
|
|
|
#include "hw/atlas_defaults.h"
|
|
#include "hw/jetson_defaults.h"
|
|
#include "hw/rk3588_defaults.h"
|
|
|
|
namespace rk3588 {
|
|
|
|
namespace {
|
|
|
|
std::string NormalizePlatform(const SimpleJson& config) {
|
|
std::string platform = config.ValueOr<std::string>("platform", "");
|
|
if (platform.empty()) {
|
|
platform = config.ValueOr<std::string>("hw_platform", "");
|
|
}
|
|
if (platform.empty()) {
|
|
return "rk3588";
|
|
}
|
|
std::string normalized;
|
|
normalized.reserve(platform.size());
|
|
for (char c : platform) {
|
|
if (!std::isspace(static_cast<unsigned char>(c))) {
|
|
normalized.push_back(static_cast<char>(std::tolower(static_cast<unsigned char>(c))));
|
|
}
|
|
}
|
|
return normalized.empty() ? "rk3588" : normalized;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
std::shared_ptr<IInferBackend> HwFactory::CreateInferBackend(const SimpleJson& config) {
|
|
const std::string platform = NormalizePlatform(config);
|
|
if (platform == "atlas") {
|
|
return std::make_shared<AtlasInferBackend>();
|
|
}
|
|
if (platform == "jetson") {
|
|
return std::make_shared<JetsonInferBackend>();
|
|
}
|
|
return std::make_shared<Rk3588InferBackend>();
|
|
}
|
|
|
|
std::shared_ptr<IImageProcessor> HwFactory::CreateImageProcessor(const SimpleJson& config) {
|
|
const std::string platform = NormalizePlatform(config);
|
|
if (platform == "atlas") {
|
|
return std::make_shared<AtlasImageProcessor>();
|
|
}
|
|
if (platform == "jetson") {
|
|
return std::make_shared<JetsonImageProcessor>();
|
|
}
|
|
return std::make_shared<Rk3588ImageProcessor>(config);
|
|
}
|
|
|
|
std::shared_ptr<IDecoder> HwFactory::CreateDecoder(const SimpleJson& config) {
|
|
const std::string platform = NormalizePlatform(config);
|
|
if (platform == "atlas") {
|
|
return std::make_shared<AtlasDecoder>();
|
|
}
|
|
if (platform == "jetson") {
|
|
return std::make_shared<JetsonDecoder>();
|
|
}
|
|
return std::make_shared<Rk3588Decoder>();
|
|
}
|
|
|
|
std::shared_ptr<IEncoder> HwFactory::CreateEncoder(const SimpleJson& config) {
|
|
const std::string platform = NormalizePlatform(config);
|
|
if (platform == "atlas") {
|
|
return std::make_shared<AtlasEncoder>();
|
|
}
|
|
if (platform == "jetson") {
|
|
return std::make_shared<JetsonEncoder>();
|
|
}
|
|
return std::make_shared<Rk3588Encoder>();
|
|
}
|
|
|
|
} // namespace rk3588
|