From d07e3a223fdafeae97e052f9778aea48d841241d Mon Sep 17 00:00:00 2001 From: cmhu <2657262686@qq.com> Date: Mon, 9 Oct 2023 18:45:04 +0800 Subject: [PATCH] 修复width错误导致的拷贝错误 --- vehicle_structure_platform.git0708-3080-trt-face/src/VPT/ImageSaveCache.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/ImageSaveCache.cpp b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/ImageSaveCache.cpp index 4167c17..b1f9ad1 100644 --- a/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/ImageSaveCache.cpp +++ b/vehicle_structure_platform.git0708-3080-trt-face/src/VPT/ImageSaveCache.cpp @@ -46,7 +46,6 @@ void ImageSaveCache::insert(const OBJ_KEY &snaphot_id, const FRAME_KEY & frame_i auto iterK = mp_key.find(snaphot_id); if (iterK == mp_key.end()) { - //os1 << mp_frame.size() << std::endl; auto unaryF = [&frame_id](std::pair & item_key) { if (item_key.first == frame_id) @@ -84,7 +83,7 @@ void ImageSaveCache::insert(const OBJ_KEY &snaphot_id, const FRAME_KEY & frame_i if (iterKey == mp_key.end() && iterFrame->second.width == frame.width && iterFrame->second.height == frame.height && iterFrame->second.size == frame.size) //����ô�ͼû���棬���ȱ�����ͼvector,���ijһ����ͼ���ݣ���������map����������ô�ô�ͼ���ݽ����������� { - cudaError_t cudaStatus = cudaMemcpy(iterFrame->second.frame, frame.frame, IMG_CHANNELS * frame.size * frame.height * sizeof(unsigned char), cudaMemcpyDeviceToHost); + cudaError_t cudaStatus = cudaMemcpy(iterFrame->second.frame, frame.frame, IMG_CHANNELS * frame.width * frame.height * sizeof(unsigned char), cudaMemcpyDeviceToHost); if (cudaStatus != cudaSuccess) { fprintf(stderr, "here cudaMemcpy failed! error: %s\n", cudaGetErrorString(cudaStatus)); } @@ -99,12 +98,8 @@ void ImageSaveCache::insert(const OBJ_KEY &snaphot_id, const FRAME_KEY & frame_i } } DxGPUFrame dx_frame; - /* cudaError_t cudaStatus = cudaMalloc((void**)&dx_frame.frame, frame.size * frame.height * IMG_CHANNELS * sizeof(float)); - if (cudaStatus != cudaSuccess) { - fprintf(stderr, "here cudaMalloc failed! error: %s\n", cudaGetErrorString(cudaStatus)); - }*/ - dx_frame.frame = malloc(frame.size * frame.height * IMG_CHANNELS * sizeof(unsigned char)); - cudaError_t cudaStatus = cudaMemcpy(dx_frame.frame, frame.frame, IMG_CHANNELS * frame.size * frame.height * sizeof(unsigned char), cudaMemcpyDeviceToHost); + dx_frame.frame = malloc(frame.width * frame.height * IMG_CHANNELS * sizeof(unsigned char)); + cudaError_t cudaStatus = cudaMemcpy(dx_frame.frame, frame.frame, IMG_CHANNELS * frame.width * frame.height * sizeof(unsigned char), cudaMemcpyDeviceToHost); if (cudaStatus != cudaSuccess) { fprintf(stderr, "here cudaMemcpy failed! error: %s\n", cudaGetErrorString(cudaStatus)); } @@ -121,7 +116,6 @@ void ImageSaveCache::insert(const OBJ_KEY &snaphot_id, const FRAME_KEY & frame_i } else { - //os1 << mp_frame.size() << std::endl; auto unaryF = [&frame_id](std::pair & item_key) { if (item_key.first == frame_id) @@ -152,7 +146,7 @@ void ImageSaveCache::insert(const OBJ_KEY &snaphot_id, const FRAME_KEY & frame_i if (iterKey == mp_key.end()&& iterFrame->second.width == frame.width && iterFrame->second.height == frame.height && iterFrame->second.size == frame.size) //����ô�ͼû���棬���ȱ�����ͼvector,���ijһ����ͼ���ݣ���������map����������ô�ô�ͼ���ݽ����������� { - cudaError_t cudaStatus = cudaMemcpy(iterFrame->second.frame, frame.frame, IMG_CHANNELS * frame.size * frame.height * sizeof(unsigned char), cudaMemcpyDeviceToHost); + cudaError_t cudaStatus = cudaMemcpy(iterFrame->second.frame, frame.frame, IMG_CHANNELS * frame.width * frame.height * sizeof(unsigned char), cudaMemcpyDeviceToHost); if (cudaStatus != cudaSuccess) { fprintf(stderr, "here cudaMemcpy failed! error: %s\n", cudaGetErrorString(cudaStatus)); } @@ -165,8 +159,8 @@ void ImageSaveCache::insert(const OBJ_KEY &snaphot_id, const FRAME_KEY & frame_i } } DxGPUFrame dx_frame; - dx_frame.frame = malloc(IMG_CHANNELS * frame.size * frame.height * sizeof(unsigned char)); - cudaError_t cudaStatus = cudaMemcpy(dx_frame.frame, frame.frame, IMG_CHANNELS * frame.size * frame.height * sizeof(unsigned char), cudaMemcpyDeviceToHost); + dx_frame.frame = malloc(IMG_CHANNELS * frame.width * frame.height * sizeof(unsigned char)); + cudaError_t cudaStatus = cudaMemcpy(dx_frame.frame, frame.frame, IMG_CHANNELS * frame.width * frame.height * sizeof(unsigned char), cudaMemcpyDeviceToHost); if (cudaStatus != cudaSuccess) { fprintf(stderr, "here cudaMemcpy failed! error: %s\n", cudaGetErrorString(cudaStatus)); } -- libgit2 0.21.4