Commit d07e3a223fdafeae97e052f9778aea48d841241d

Authored by Hu Chunming
1 parent 80302362

修复width错误导致的拷贝错误

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 @@ -46,7 +46,6 @@ void ImageSaveCache::insert(const OBJ_KEY &snaphot_id, const FRAME_KEY & frame_i
46 auto iterK = mp_key.find(snaphot_id); 46 auto iterK = mp_key.find(snaphot_id);
47 if (iterK == mp_key.end()) 47 if (iterK == mp_key.end())
48 { 48 {
49 - //os1 << mp_frame.size() << std::endl;  
50 auto unaryF = [&frame_id](std::pair<FRAME_KEY, DxGPUFrame> & item_key) 49 auto unaryF = [&frame_id](std::pair<FRAME_KEY, DxGPUFrame> & item_key)
51 { 50 {
52 if (item_key.first == frame_id) 51 if (item_key.first == frame_id)
@@ -84,7 +83,7 @@ void ImageSaveCache::insert(const OBJ_KEY &amp;snaphot_id, const FRAME_KEY &amp; frame_i @@ -84,7 +83,7 @@ void ImageSaveCache::insert(const OBJ_KEY &amp;snaphot_id, const FRAME_KEY &amp; frame_i
84 if (iterKey == mp_key.end() && iterFrame->second.width == frame.width && iterFrame->second.height == frame.height && iterFrame->second.size == frame.size) //����ô�ͼû���棬���ȱ�����ͼvector,���ijһ����ͼ���ݣ���������map����������ô�ô�ͼ���ݽ����������� 83 if (iterKey == mp_key.end() && iterFrame->second.width == frame.width && iterFrame->second.height == frame.height && iterFrame->second.size == frame.size) //����ô�ͼû���棬���ȱ�����ͼvector,���ijһ����ͼ���ݣ���������map����������ô�ô�ͼ���ݽ�����������
85 { 84 {
86 85
87 - cudaError_t cudaStatus = cudaMemcpy(iterFrame->second.frame, frame.frame, IMG_CHANNELS * frame.size * frame.height * sizeof(unsigned char), cudaMemcpyDeviceToHost); 86 + cudaError_t cudaStatus = cudaMemcpy(iterFrame->second.frame, frame.frame, IMG_CHANNELS * frame.width * frame.height * sizeof(unsigned char), cudaMemcpyDeviceToHost);
88 if (cudaStatus != cudaSuccess) { 87 if (cudaStatus != cudaSuccess) {
89 fprintf(stderr, "here cudaMemcpy failed! error: %s\n", cudaGetErrorString(cudaStatus)); 88 fprintf(stderr, "here cudaMemcpy failed! error: %s\n", cudaGetErrorString(cudaStatus));
90 } 89 }
@@ -99,12 +98,8 @@ void ImageSaveCache::insert(const OBJ_KEY &amp;snaphot_id, const FRAME_KEY &amp; frame_i @@ -99,12 +98,8 @@ void ImageSaveCache::insert(const OBJ_KEY &amp;snaphot_id, const FRAME_KEY &amp; frame_i
99 } 98 }
100 } 99 }
101 DxGPUFrame dx_frame; 100 DxGPUFrame dx_frame;
102 - /* cudaError_t cudaStatus = cudaMalloc((void**)&dx_frame.frame, frame.size * frame.height * IMG_CHANNELS * sizeof(float));  
103 - if (cudaStatus != cudaSuccess) {  
104 - fprintf(stderr, "here cudaMalloc failed! error: %s\n", cudaGetErrorString(cudaStatus));  
105 - }*/  
106 - dx_frame.frame = malloc(frame.size * frame.height * IMG_CHANNELS * sizeof(unsigned char));  
107 - cudaError_t cudaStatus = cudaMemcpy(dx_frame.frame, frame.frame, IMG_CHANNELS * frame.size * frame.height * sizeof(unsigned char), cudaMemcpyDeviceToHost); 101 + dx_frame.frame = malloc(frame.width * frame.height * IMG_CHANNELS * sizeof(unsigned char));
  102 + cudaError_t cudaStatus = cudaMemcpy(dx_frame.frame, frame.frame, IMG_CHANNELS * frame.width * frame.height * sizeof(unsigned char), cudaMemcpyDeviceToHost);
108 if (cudaStatus != cudaSuccess) { 103 if (cudaStatus != cudaSuccess) {
109 fprintf(stderr, "here cudaMemcpy failed! error: %s\n", cudaGetErrorString(cudaStatus)); 104 fprintf(stderr, "here cudaMemcpy failed! error: %s\n", cudaGetErrorString(cudaStatus));
110 } 105 }
@@ -121,7 +116,6 @@ void ImageSaveCache::insert(const OBJ_KEY &amp;snaphot_id, const FRAME_KEY &amp; frame_i @@ -121,7 +116,6 @@ void ImageSaveCache::insert(const OBJ_KEY &amp;snaphot_id, const FRAME_KEY &amp; frame_i
121 } 116 }
122 else 117 else
123 { 118 {
124 - //os1 << mp_frame.size() << std::endl;  
125 auto unaryF = [&frame_id](std::pair<FRAME_KEY, DxGPUFrame> & item_key) 119 auto unaryF = [&frame_id](std::pair<FRAME_KEY, DxGPUFrame> & item_key)
126 { 120 {
127 if (item_key.first == frame_id) 121 if (item_key.first == frame_id)
@@ -152,7 +146,7 @@ void ImageSaveCache::insert(const OBJ_KEY &amp;snaphot_id, const FRAME_KEY &amp; frame_i @@ -152,7 +146,7 @@ void ImageSaveCache::insert(const OBJ_KEY &amp;snaphot_id, const FRAME_KEY &amp; frame_i
152 146
153 if (iterKey == mp_key.end()&& iterFrame->second.width == frame.width && iterFrame->second.height == frame.height && iterFrame->second.size == frame.size) //����ô�ͼû���棬���ȱ�����ͼvector,���ijһ����ͼ���ݣ���������map����������ô�ô�ͼ���ݽ����������� 147 if (iterKey == mp_key.end()&& iterFrame->second.width == frame.width && iterFrame->second.height == frame.height && iterFrame->second.size == frame.size) //����ô�ͼû���棬���ȱ�����ͼvector,���ijһ����ͼ���ݣ���������map����������ô�ô�ͼ���ݽ�����������
154 { 148 {
155 - cudaError_t cudaStatus = cudaMemcpy(iterFrame->second.frame, frame.frame, IMG_CHANNELS * frame.size * frame.height * sizeof(unsigned char), cudaMemcpyDeviceToHost); 149 + cudaError_t cudaStatus = cudaMemcpy(iterFrame->second.frame, frame.frame, IMG_CHANNELS * frame.width * frame.height * sizeof(unsigned char), cudaMemcpyDeviceToHost);
156 if (cudaStatus != cudaSuccess) { 150 if (cudaStatus != cudaSuccess) {
157 fprintf(stderr, "here cudaMemcpy failed! error: %s\n", cudaGetErrorString(cudaStatus)); 151 fprintf(stderr, "here cudaMemcpy failed! error: %s\n", cudaGetErrorString(cudaStatus));
158 } 152 }
@@ -165,8 +159,8 @@ void ImageSaveCache::insert(const OBJ_KEY &amp;snaphot_id, const FRAME_KEY &amp; frame_i @@ -165,8 +159,8 @@ void ImageSaveCache::insert(const OBJ_KEY &amp;snaphot_id, const FRAME_KEY &amp; frame_i
165 } 159 }
166 } 160 }
167 DxGPUFrame dx_frame; 161 DxGPUFrame dx_frame;
168 - dx_frame.frame = malloc(IMG_CHANNELS * frame.size * frame.height * sizeof(unsigned char));  
169 - cudaError_t cudaStatus = cudaMemcpy(dx_frame.frame, frame.frame, IMG_CHANNELS * frame.size * frame.height * sizeof(unsigned char), cudaMemcpyDeviceToHost); 162 + dx_frame.frame = malloc(IMG_CHANNELS * frame.width * frame.height * sizeof(unsigned char));
  163 + cudaError_t cudaStatus = cudaMemcpy(dx_frame.frame, frame.frame, IMG_CHANNELS * frame.width * frame.height * sizeof(unsigned char), cudaMemcpyDeviceToHost);
170 if (cudaStatus != cudaSuccess) { 164 if (cudaStatus != cudaSuccess) {
171 fprintf(stderr, "here cudaMemcpy failed! error: %s\n", cudaGetErrorString(cudaStatus)); 165 fprintf(stderr, "here cudaMemcpy failed! error: %s\n", cudaGetErrorString(cudaStatus));
172 } 166 }