|
@@ -2,6 +2,8 @@
|
|
|
#include <io.h>
|
|
|
#include <time.h>
|
|
|
#include <stdio.h>
|
|
|
+#include <pcl\io\ply_io.h>
|
|
|
+#include <pcl\point_types.h>
|
|
|
#include "imstorage_manager.h"
|
|
|
|
|
|
//namespace graft_gcv
|
|
@@ -9,6 +11,7 @@
|
|
|
|
|
|
|
|
|
CRITICAL_SECTION g_cs;
|
|
|
+CRITICAL_SECTION g_cs_pcd;
|
|
|
|
|
|
void getFiles( string path, vector<string>& files, time_t clean_time )
|
|
|
{
|
|
@@ -40,6 +43,7 @@ void getFiles( string path, vector<string>& files, time_t clean_time )
|
|
|
}
|
|
|
bool g_thread_run=false;
|
|
|
bool g_thread_run_saver=true;
|
|
|
+bool g_thread_run_saver_pcd = true;
|
|
|
int WINAPI TheadFuncClearn(LPVOID lpParam)
|
|
|
{
|
|
|
ThreadParamClean* threadParam = (ThreadParamClean *) lpParam;
|
|
@@ -95,12 +99,39 @@ int WINAPI TheadFuncSave(LPVOID lpParam)
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
+int WINAPI TheadFuncSavePcd(LPVOID lpParam)
|
|
|
+{
|
|
|
+ ThreadParamSavePcd* threadParam = (ThreadParamSavePcd *)lpParam;
|
|
|
+ int nIndex = threadParam->nIndex;
|
|
|
+ queue<PcdParam>* pcdQ = threadParam->pcdQ;
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ if (!g_thread_run_saver_pcd) { break; }
|
|
|
+ if (pcdQ->size() == 0) {
|
|
|
+ Sleep(50);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ EnterCriticalSection(&g_cs_pcd);
|
|
|
+ PcdParam& pcd_info = pcdQ->front();
|
|
|
+ pcl::io::savePLYFile(pcd_info.pcd_name, pcd_info.pcd, true);
|
|
|
+ //cout<<im_info.img_name<<"\t"<<imgQ->size()<<endl;
|
|
|
+ pcdQ->pop();
|
|
|
+ }
|
|
|
+ catch (...) {
|
|
|
+ //int tes = 0;
|
|
|
+ }
|
|
|
+ LeaveCriticalSection(&g_cs_pcd);
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
|
|
|
CImStoreManager::CImStoreManager()
|
|
|
:m_storeDays(7)
|
|
|
,m_storeDir(""),
|
|
|
m_workHandle(0),
|
|
|
- m_workHandleSave(0)
|
|
|
+ m_workHandleSave(0),
|
|
|
+ m_workHandleSavePcd(0)
|
|
|
{
|
|
|
InitializeCriticalSection(&g_cs);
|
|
|
ThreadParamSave paramSave;
|
|
@@ -114,16 +145,32 @@ CImStoreManager::CImStoreManager()
|
|
|
(LPVOID)¶mSave,
|
|
|
NULL,
|
|
|
NULL);
|
|
|
+
|
|
|
+ InitializeCriticalSection(&g_cs_pcd);
|
|
|
+ ThreadParamSavePcd paramSavePcd;
|
|
|
+ paramSavePcd.nIndex = 0;
|
|
|
+ //paramSave.state = &g_thread_run;
|
|
|
+ paramSavePcd.pcdQ = &m_pcds;
|
|
|
+ m_workHandleSavePcd = CreateThread(
|
|
|
+ NULL,
|
|
|
+ 0,
|
|
|
+ (LPTHREAD_START_ROUTINE)TheadFuncSavePcd,
|
|
|
+ (LPVOID)¶mSavePcd,
|
|
|
+ NULL,
|
|
|
+ NULL);
|
|
|
Sleep(500);
|
|
|
}
|
|
|
CImStoreManager::~CImStoreManager(){
|
|
|
g_thread_run=false;
|
|
|
g_thread_run_saver=false;
|
|
|
- HANDLE handles[2];
|
|
|
+ g_thread_run_saver_pcd = false;
|
|
|
+ HANDLE handles[3];
|
|
|
handles[0]=m_workHandle;
|
|
|
handles[1]=m_workHandleSave;
|
|
|
- WaitForMultipleObjects(2,handles,TRUE,500);
|
|
|
+ handles[2] = m_workHandleSavePcd;
|
|
|
+ WaitForMultipleObjects(3,handles,TRUE,500);
|
|
|
DeleteCriticalSection(&g_cs);
|
|
|
+ DeleteCriticalSection(&g_cs_pcd);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -195,4 +242,22 @@ int CImStoreManager::saveImage(cv::Mat&img,string name_id)
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
+
|
|
|
+int CImStoreManager::saveBinPly(
|
|
|
+ pcl::PointCloud<pcl::PointXYZ>::Ptr pcd,
|
|
|
+ string name_id)
|
|
|
+{
|
|
|
+ if (!is_valid_folder()) { return 1; }
|
|
|
+ if (pcd->points.size()==0) { return 1; }
|
|
|
+ string tar_file = m_storeDir + "/" + name_id + ".ply";
|
|
|
+ PcdParam pcdp;
|
|
|
+ pcdp.pcd_name = tar_file;
|
|
|
+ pcl::copyPointCloud(*pcd, pcdp.pcd);
|
|
|
+ EnterCriticalSection(&g_cs_pcd);
|
|
|
+ m_pcds.push(pcdp);
|
|
|
+ //cout<<"=========="<<pcdp.pcd_name<<endl;
|
|
|
+ LeaveCriticalSection(&g_cs_pcd);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
//};
|