@@ -150,27 +150,18 @@ void AInSceneRecord::HandleFrameData(TArray<FColor> Bitmap, int32 x, int32 y)
150150 m_WrapOpenCv->m_VideoWriter .open (cvFilePath, cv::VideoWriter::fourcc (' X' , ' V' , ' I' , ' D' ), m_Fps, cv::Size (m_ImageX, m_ImageY));
151151 }
152152
153- int count = 0 ;
154- for (int i = 0 ; i < Bitmap.Num (); i++)
155- {
156- m_ImageBuf[count] = Bitmap[i].B ;
157- m_ImageBuf[count + 1 ] = Bitmap[i].G ;
158- m_ImageBuf[count + 2 ] = Bitmap[i].R ;
159- count += 3 ;
160- }
161-
162153 if (false == m_WrapOpenCv->m_VideoWriter .isOpened ())
163154 {
164155 UE_LOG (LogTemp, Error, TEXT (" AInSceneRecord m_VideoWriter isOpened" ));
165156 return ;
166157 }
158+
167159 if (nullptr == m_Thread)
168160 {
169161 m_Thread = FRunnableThread::Create (this , TEXT (" SceneRecord Thread" ));
170162 }
171- cv::Mat img (m_ImageY,m_ImageX,CV_8UC3, (unsigned char *)m_ImageBuf);
172- auto newImg = img.clone ();
173- m_WrapOpenCv->m_ImageQueue .Enqueue (newImg);
163+
164+ m_WrapOpenCv->m_ImageQueue .Enqueue (Bitmap);
174165}
175166
176167bool AInSceneRecord::Init ()
@@ -185,8 +176,20 @@ uint32 AInSceneRecord::Run()
185176 {
186177 if (false == m_WrapOpenCv->m_ImageQueue .IsEmpty ())
187178 {
188- cv::Mat img;
189- m_WrapOpenCv->m_ImageQueue .Dequeue (img);
179+ TArray<FColor> Bitmap;
180+ m_WrapOpenCv->m_ImageQueue .Dequeue (Bitmap);
181+
182+ int count = 0 ;
183+ for (int i = 0 ; i < Bitmap.Num (); i++)
184+ {
185+ m_ImageBuf[count] = Bitmap[i].B ;
186+ m_ImageBuf[count + 1 ] = Bitmap[i].G ;
187+ m_ImageBuf[count + 2 ] = Bitmap[i].R ;
188+ count += 3 ;
189+ }
190+
191+ cv::Mat img (m_ImageY, m_ImageX, CV_8UC3, (unsigned char *)m_ImageBuf);
192+
190193 m_WrapOpenCv->m_VideoWriter .write (img);
191194 continue ;
192195 }
0 commit comments