From 8774b22e788c606f61ab6e6f9b96da7eb184b5cd Mon Sep 17 00:00:00 2001 From: wwj <3427896184@qq.com> Date: 星期二, 01 七月 2025 18:17:17 +0800 Subject: [PATCH] dm --- Server/汪卫军/code/图像处理.rar | 0 /dev/null | 17 ----------------- Server/汪卫军/log/日志_汪卫军_0629.doc | 0 3 files changed, 0 insertions(+), 17 deletions(-) diff --git "a/Server/\346\261\252\345\215\253\345\206\233/code/ImageProcessor.cpp" "b/Server/\346\261\252\345\215\253\345\206\233/code/ImageProcessor.cpp" deleted file mode 100644 index 4148d4e..0000000 --- "a/Server/\346\261\252\345\215\253\345\206\233/code/ImageProcessor.cpp" +++ /dev/null @@ -1,93 +0,0 @@ -// ImageProcessor.cpp - 照片处理模块实现 -#include "stdafx.h" -#include "ImageProcessor.h" -#include <opencv2/opencv.hpp> - -ImageProcessor::ImageProcessor() {} - -ImageProcessor::~ImageProcessor() {} - -bool ImageProcessor::CropFace(const unsigned char* imageData, int width, int height, - unsigned char*& faceData, int& faceWidth, int& faceHeight) const { - try { - // 创建OpenCV图像 - cv::Mat image(height, width, CV_8UC3, const_cast<unsigned char*>(imageData)); - - // 加载人脸检测器 - cv::CascadeClassifier face_cascade; - if (!face_cascade.load(cv::samples::findFile("haarcascade_frontalface_alt.xml"))) { - std::cerr << "无法加载人脸检测器" << std::endl; - return false; - } - - // 转换为灰度图 - cv::Mat gray; - cv::cvtColor(image, gray, cv::COLOR_BGR2GRAY); - cv::equalizeHist(gray, gray); - - // 检测人脸 - std::vector<cv::Rect> faces; - face_cascade.detectMultiScale(gray, faces, 1.1, 2, 0 | cv::CASCADE_SCALE_IMAGE, cv::Size(30, 30)); - - if (faces.empty()) { - return false; - } - - // 获取第一个检测到的人脸 - cv::Rect face_rect = faces[0]; - cv::Mat face = image(face_rect); - - // 保存人脸数据 - faceWidth = face.cols; - faceHeight = face.rows; - size_t dataSize = faceWidth * faceHeight * 3; - - faceData = new unsigned char[dataSize]; - memcpy(faceData, face.data, dataSize); - - return true; - } - catch (const std::exception& e) { - std::cerr << "裁剪人脸失败: " << e.what() << std::endl; - return false; - } -} - -bool ImageProcessor::EnhanceQuality(unsigned char* imageData, int width, int height) const { - try { - // 创建OpenCV图像 - cv::Mat image(height, width, CV_8UC3, imageData); - - // 图像增强处理 - cv::Mat enhanced; - cv::GaussianBlur(image, enhanced, cv::Size(0, 0), 3); - cv::addWeighted(image, 1.5, enhanced, -0.5, 0, enhanced); - - // 复制回原始数据 - memcpy(imageData, enhanced.data, width * height * 3); - - return true; - } - catch (const std::exception& e) { - std::cerr << "增强图像质量失败: " << e.what() << std::endl; - return false; - } -} - -bool ImageProcessor::ValidateImage(const unsigned char* imageData, int width, int height) const { - try { - // 简单验证:检查图像尺寸是否合理 - if (width < 10 || height < 10) { - return false; - } - - // 这里可以添加更复杂的图像验证逻辑 - // 例如:检查图像是否模糊、是否包含人脸等 - - return true; - } - catch (const std::exception& e) { - std::cerr << "验证图像失败: " << e.what() << std::endl; - return false; - } -} \ No newline at end of file diff --git "a/Server/\346\261\252\345\215\253\345\206\233/code/ImageProcessor.h" "b/Server/\346\261\252\345\215\253\345\206\233/code/ImageProcessor.h" deleted file mode 100644 index 2a5727b..0000000 --- "a/Server/\346\261\252\345\215\253\345\206\233/code/ImageProcessor.h" +++ /dev/null @@ -1,15 +0,0 @@ -// ImageProcessor.h - 照片处理模块 -#pragma once -#include <string> -#include "FaceImageManager.h" - -class ImageProcessor { -public: - ImageProcessor(); - ~ImageProcessor(); - - bool CropFace(const unsigned char* imageData, int width, int height, - unsigned char*& faceData, int& faceWidth, int& faceHeight) const; - bool EnhanceQuality(unsigned char* imageData, int width, int height) const; - bool ValidateImage(const unsigned char* imageData, int width, int height) const; -}; \ No newline at end of file diff --git "a/Server/\346\261\252\345\215\253\345\206\233/code/ImageStorage.cpp" "b/Server/\346\261\252\345\215\253\345\206\233/code/ImageStorage.cpp" deleted file mode 100644 index b43bc2e..0000000 --- "a/Server/\346\261\252\345\215\253\345\206\233/code/ImageStorage.cpp" +++ /dev/null @@ -1,54 +0,0 @@ -// 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); -} \ No newline at end of file diff --git "a/Server/\346\261\252\345\215\253\345\206\233/code/ImageStorage.h" "b/Server/\346\261\252\345\215\253\345\206\233/code/ImageStorage.h" deleted file mode 100644 index 3b754d6..0000000 --- "a/Server/\346\261\252\345\215\253\345\206\233/code/ImageStorage.h" +++ /dev/null @@ -1,17 +0,0 @@ -// 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); -}; \ No newline at end of file diff --git "a/Server/\346\261\252\345\215\253\345\206\233/code/\345\233\276\345\203\217\345\244\204\347\220\206.rar" "b/Server/\346\261\252\345\215\253\345\206\233/code/\345\233\276\345\203\217\345\244\204\347\220\206.rar" new file mode 100644 index 0000000..84ae583 --- /dev/null +++ "b/Server/\346\261\252\345\215\253\345\206\233/code/\345\233\276\345\203\217\345\244\204\347\220\206.rar" Binary files differ diff --git "a/Server/\346\261\252\345\215\253\345\206\233/log/\346\227\245\345\277\227_\346\261\252\345\215\253\345\206\233_0629.doc" "b/Server/\346\261\252\345\215\253\345\206\233/log/\346\227\245\345\277\227_\346\261\252\345\215\253\345\206\233_0629.doc" new file mode 100644 index 0000000..4e3d6fa --- /dev/null +++ "b/Server/\346\261\252\345\215\253\345\206\233/log/\346\227\245\345\277\227_\346\261\252\345\215\253\345\206\233_0629.doc" Binary files differ -- Gitblit v1.8.0