Merge branch 'master' of ssh://115.28.86.8:29418/~admin/智能网联_25-0305_617_v1
New file |
| | |
| | | #ifndef TCPDATATYPE_H |
| | | #define TCPDATATYPE_H |
| | | /* */ |
| | | enum class ActionType |
| | | { |
| | | HeartCheck = 100, |
| | | Login = 110, |
| | | Register = 120, |
| | | Msg = 200, |
| | | Download = 300 |
| | | }; |
| | | /* ο HTTP Ӧ */ |
| | | enum class ResponseCode |
| | | { |
| | | ResponseOK = 200, // ɹ |
| | | BadRequest = 400, // ͻ 󣬷 ޷ |
| | | Unauthorized = 401, // Ҫ û ֤ |
| | | Forbidden = 403, // ͻ ˵ 󣬵 Ǿܾ ִ д |
| | | NotFound = 404, // Þ· Òµ Ô´ |
| | | MethodNotAllowed = 405 // ͻ еķ ֹ |
| | | |
| | | }; |
| | | /* Ϣ */ |
| | | struct Head |
| | | { |
| | | ActionType type; |
| | | int len; |
| | | int version; |
| | | Head(ActionType ptype, int plen, int pversion) |
| | | { |
| | | len = plen; |
| | | type = ptype; |
| | | version = pversion; |
| | | } |
| | | }; |
| | | struct HeartCheckReq // |
| | | { |
| | | ActionType type; |
| | | int len; |
| | | HeartCheckReq() |
| | | { |
| | | type = ActionType::HeartCheck; |
| | | len = sizeof(HeartCheckReq); |
| | | } |
| | | }; |
| | | |
| | | struct HeartCheckRes // Ó¦ |
| | | { |
| | | ActionType type; |
| | | int len; |
| | | HeartCheckRes() |
| | | { |
| | | type = ActionType::HeartCheck; |
| | | len = sizeof(HeartCheckRes); |
| | | } |
| | | }; |
| | | struct RegisterRequest |
| | | { |
| | | Head head; |
| | | char name[64]; |
| | | char password[64]; |
| | | char email[32]; |
| | | char phone[32]; |
| | | }; |
| | | struct LoginRequest |
| | | { |
| | | |
| | | Head head; |
| | | char name[64]; |
| | | char password[64]; |
| | | }; |
| | | #endif |
New file |
| | |
| | | // ImageStorage.cpp - ç
§çå卿¨¡åå®ç° |
| | | #include "stdafx.h" |
| | | #include "ImageStorage.h" |
| | | #include <fstream> |
| | | #include <opencv2/opencv.hpp> |
| | | |
| | | ImageStorage::ImageStorage() {} |
| | | |
| | | ImageStorage::~ImageStorage() {} |
| | | |
| | | bool ImageStorage::SaveImage(const std::string& filePath, const unsigned char* imageData, |
| | | int width, int height) { |
| | | try { |
| | | // å建OpenCVå¾å |
| | | cv::Mat image(height, width, CV_8UC3, const_cast<unsigned char*>(imageData)); |
| | | |
| | | // ä¿åå¾å |
| | | return cv::imwrite(filePath, image); |
| | | } |
| | | catch (const std::exception& e) { |
| | | std::cerr << "ä¿åå¾å失败: " << e.what() << std::endl; |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | bool ImageStorage::LoadImage(const std::string& filePath, unsigned char*& imageData, |
| | | int& width, int& height) const { |
| | | try { |
| | | // å è½½å¾å |
| | | cv::Mat image = cv::imread(filePath, cv::IMREAD_COLOR); |
| | | |
| | | if (image.empty()) { |
| | | return false; |
| | | } |
| | | |
| | | // åé
å
åå¹¶å¤å¶æ°æ® |
| | | width = image.cols; |
| | | height = image.rows; |
| | | size_t dataSize = width * height * 3; |
| | | |
| | | imageData = new unsigned char[dataSize]; |
| | | memcpy(imageData, image.data, dataSize); |
| | | |
| | | return true; |
| | | } |
| | | catch (const std::exception& e) { |
| | | std::cerr << "å è½½å¾å失败: " << e.what() << std::endl; |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | bool ImageStorage::DeleteImage(const std::string& filePath) { |
| | | return (remove(filePath.c_str()) == 0); |
| | | } |
New file |
| | |
| | | // ImageStorage.h - ç
§çå卿¨¡å |
| | | #pragma once |
| | | #include <string> |
| | | #include <vector> |
| | | #include "FaceImageManager.h" |
| | | |
| | | class ImageStorage { |
| | | public: |
| | | ImageStorage(); |
| | | ~ImageStorage(); |
| | | |
| | | bool SaveImage(const std::string& filePath, const unsigned char* imageData, |
| | | int width, int height); |
| | | bool LoadImage(const std::string& filePath, unsigned char*& imageData, |
| | | int& width, int& height) const; |
| | | bool DeleteImage(const std::string& filePath); |
| | | }; |
New file |
| | |
| | | Subproject commit 0000000000000000000000000000000000000000 |
| | | Subproject commit 89d19ad386e768e8e54b6aa4b1d42f4617ceed03 |