wwj
2025-06-26 b20d38f0c9969c4bf11f7fd106e3abff31aa4fd3
日志4
2个文件已添加
2个文件已删除
179 ■■■■■ 已修改文件
Server/汪卫军/code/ImageProcessor.cpp 93 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Server/汪卫军/code/ImageProcessor.h 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Server/汪卫军/code/ImageStorage.cpp 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Server/汪卫军/code/ImageStorage.h 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Server/ÍôÎÀ¾ü/code/ImageProcessor.cpp
File was deleted
Server/ÍôÎÀ¾ü/code/ImageProcessor.h
File was deleted
Server/ÍôÎÀ¾ü/code/ImageStorage.cpp
New file
@@ -0,0 +1,54 @@
// 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);
}
Server/ÍôÎÀ¾ü/code/ImageStorage.h
New file
@@ -0,0 +1,17 @@
// 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);
};