Files
face_sdk/vulkan/main.cpp
T
2025-10-29 21:38:03 +08:00

86 lines
2.3 KiB
C++

#include "FaceApp.h"
std::wstring ReadUTF8File(const std::string& filePath)
{
std::ifstream file(filePath, std::ios::binary);
if (!file.is_open()) {
throw std::runtime_error("无法打开UTF-8文件: " + filePath);
}
// 读取文件所有内容
std::string content((std::istreambuf_iterator<char>(file)),
std::istreambuf_iterator<char>());
file.close();
// 将UTF-8字符串转换为宽字符串
return AppBase::UTF8ToWideString(content);
}
std::wstring ReadFileWithChinesePath(const std::wstring& filePath) {
// 使用二进制模式打开文件
std::ifstream file(filePath, std::ios::binary);
if (!file.is_open()) {
std::wcout << L"无法打开文件: " << filePath << std::endl;
return L"";
}
// 读取文件内容到std::string
std::string context;
file.seekg(0, std::ios::end);
context.resize(file.tellg());
file.seekg(0, std::ios::beg);
file.read(&context[0], context.size());
file.close();
return AppBase::UTF8ToWideString(context);
}
int main() {
//std::string path = "chinese.txt";
//std::wstring chinese = ReadUTF8File(path);
//std::wstring chinese_path = AppBase::UTF8ToWideString("d:/测试目录/中文文件.txt");
//std::wstring content = ReadFileWithChinesePath(chinese_path);
InitArg init_arg;
Motion motion;
motion.type = "底妆";
motion.technique = "基础上妆";
motion.step = "2按压";
motion.show_type = "方向示意图";
motion.png_name = "4.png";
motion.png_num = 1;
#
init_arg.motion = motion;
//motion.type = "底妆";
//motion.technique = "基础上妆";
//motion.step = "2按压";
//motion.show_type = "区域";
//motion.png_name = "pic";
//motion.png_num = 1;
init_arg.action_fps = 3;
init_arg.zoom = 1.5f;
string json_str = json(init_arg).dump();
FaceApp app;
app.SetInitArg(json_str.c_str());
app.initVulkan();
app.mainLoop();
//try {
// app.mainLoop();
//} catch (const std::exception& e) {
// std::cerr << e.what() << std::endl;
// return EXIT_FAILURE;
//}
app.cleanup();
return EXIT_SUCCESS;
}