Commit af140c51 authored by alexandre burton's avatar alexandre burton
Browse files

CloudPlayerThread: déplacement du décodeur PCL en init et application de l'offset de cloud

parent 0ca9fe29
......@@ -11,7 +11,14 @@ namespace ofxCloudLib
class CloudPlayerThread : public ofThread
{
public:
CloudPlayerThread() {}
CloudPlayerThread()
{
octree_coder_ = new pcl::io::OctreePointCloudCompression<pcl::PointXYZ>(
pcl::io::HIGH_RES_OFFLINE_COMPRESSION_WITH_COLOR,
false, .01, .01, false, 1, 1,
static_cast<unsigned char>(4));
}
~CloudPlayerThread()
{
......@@ -23,13 +30,13 @@ class CloudPlayerThread : public ofThread
{
playback_path_ = playback_path;
if (ofDirectory::doesDirectoryExist(playback_path_)) {
ofDirectory dir = ofDirectory(playback_path_);
ofDirectory dir = ofDirectory(playback_path_);
std::cout << "CLOUDPLAYER: playing from " << playback_path_ << std::endl;
filename_ = playback_path_;
is_setup_ = true;
total_frames_ = dir.listDir();
decoded_frames_ = 0;
std::cout << "CLOUDPLAYER: playing " << total_frames_ << " frames from " << playback_path_ << std::endl;
} else {
std::cout << "ERROR:: CLOUDPLAYER:: no such directory" << playback_path_ << std::endl;
......@@ -78,6 +85,7 @@ class CloudPlayerThread : public ofThread
bool is_mesh_new() { return new_mesh_; }
ofMesh &get_mesh() { return mesh_; }
float offset_x_, offset_z_;
void stop()
{
......@@ -98,6 +106,8 @@ class CloudPlayerThread : public ofThread
while (1) {
if (stop_thread_) {
stop_thread_ = false;
std::cout << "CLOUD PLAYER: thread stopped" << std::endl;
return;
}
auto sysnow = std::chrono::system_clock::now();
......@@ -121,20 +131,12 @@ class CloudPlayerThread : public ofThread
decoded_frames_ = 0;
} else {
octree_coder_ = new pcl::io::OctreePointCloudCompression<pcl::PointXYZ>(
pcl::io::HIGH_RES_OFFLINE_COMPRESSION_WITH_COLOR,
false, .01, .01, false, 1, 1,
static_cast<unsigned char>(4));
cloudfile.seekg(0);
cloudfile.unsetf(ios_base::skipws);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud;
cloud.reset(new pcl::PointCloud<pcl::PointXYZ>);
octree_coder_->decodePointCloud(cloudfile, cloud);
cloudfile.close();
struct stat st;
// int ierr = stat(filename_to_decode, &st);
stat(filename_to_decode, &st);
......@@ -149,7 +151,6 @@ class CloudPlayerThread : public ofThread
delay = 50;
previousCloudTimestamp = status_ms;
decodingFenceTimestamp = now + delay;
// std::cout << "read cloud #" << decoded_frames_ << " with " << cloud->size() << " points from " << filename_to_decode << " with interval: " << delay << std::endl;
......@@ -157,17 +158,20 @@ class CloudPlayerThread : public ofThread
ofMesh mesh;
for (unsigned int qq = 0; qq < cloud->size(); qq++) {
mesh.addVertex(ofPoint(cloud->points[qq].x,
mesh.addVertex(ofPoint(cloud->points[qq].x + offset_x_,
cloud->points[qq].y,
cloud->points[qq].z));
cloud->points[qq].z + offset_z_));
}
recorded_.send(std::move(cloud));
recorded_mesh_.send(std::move(mesh));
}
cloudfile.close();
} else {
// std::cout << "DECODEUR: sleep" << std::endl;
// std::cout << "DECODEUR: sleep" << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(2));
}
std::this_thread::sleep_for(std::chrono::milliseconds(2));
}
}
......@@ -178,11 +182,12 @@ class CloudPlayerThread : public ofThread
std::string filename_;
std::string playback_path_;
bool new_mesh_ = false;
bool new_cloud_ = false;
bool is_setup_ = false;
bool stop_thread_ = false;
bool data_available_ = false;
bool new_mesh_ = false;
bool new_cloud_ = false;
bool is_setup_ = false;
bool stop_thread_ = false;
bool data_available_ = false;
size_t decoded_frames_ = 0;
size_t total_frames_ = 0;
......@@ -192,6 +197,6 @@ class CloudPlayerThread : public ofThread
ofThreadChannel<pcl::PointCloud<pcl::PointXYZ>::Ptr> recorded_;
ofThreadChannel<ofMesh> recorded_mesh_;
};
}
} // namespace ofxCloudLib
#endif // CLOUDPLAYERTHREAD_HPP
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment