Fwd: CGAL classification

classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: CGAL classification

Zhang Jinwei
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: CGAL classification

Simon Giraudot-2

Hello,

Sorry you encountered trouble with CGAL Classification.

What version of CGAL are you using? Also, can you share a source code + the full error messages?

Best regards,

-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 18/02/2020 à 19:12, Zhang Jinwei a écrit :
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: CGAL classification

Zhang Jinwei
Dear Mr. Giraudot,

I used the version of 5.01. Now the situation is that when I use the example file cluster_config.gz or mesh_config.gz, everything is ok. 

For output configuration file I use:
std::ofstream fconfig(“classifier_config.gz”);
classifier.save_configuration(fconfig);
fconfig.close();

For loading configuration I write:
std::ifstream input;
input.open(filename_config, std::ios::in | std::ios::binary);
classifier.load_configuration(input);

However, when I tried to produce and load my own configuration file by using save_ and load_configuration function, then I encountered  an exception errors which jumps to the boost serialization library file. I compared the file I produced with the file in your example, and I found your configuration file is ascii format while mine is binary format. So how did you generate the configuration file of the trained classifier?

Sorry that I cannot attach a snapshot picture of errors because I use different devices.

Another question: as shown in the examples, the cluster and mesh can also be classified by the package. But there is no example to show how to export them? In which format? And how to export the results of cluster and mesh with the colors and labels?

If you could give me help and suggestions, I would really appreciate it!

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei



On Wed 19. Feb 2020 at 16:27, Simon Giraudot <[hidden email]> wrote:

Hello,

Sorry you encountered trouble with CGAL Classification.

What version of CGAL are you using? Also, can you share a source code + the full error messages?

Best regards,


-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 18/02/2020 à 19:12, Zhang Jinwei a écrit :
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: CGAL classification

Simon Giraudot-2

Dear Mr. Jinwei,

Le 21/02/2020 à 05:56, Zhang Jinwei a écrit :

For output configuration file I use:
std::ofstream fconfig(“classifier_config.gz”);
classifier.save_configuration(fconfig);
fconfig.close();
Note that on some OS (Windows for example), you need to specify the tag std::ios_base::binary so that the binary output is correctly written. That might be the source of your error here?

However, when I tried to produce and load my own configuration file by using save_ and load_configuration function, then I encountered  an exception errors which jumps to the boost serialization library file. I compared the file I produced with the file in your example, and I found your configuration file is ascii format while mine is binary format. So how did you generate the configuration file of the trained classifier?
You must be mistaken, the configuration files provided with CGAL are also binary (to be precise: they are compressed archives containing an ASCII file).

Another question: as shown in the examples, the cluster and mesh can also be classified by the package. But there is no example to show how to export them? In which format?
If you are talking about the configuration file, then it's no different from the point set case, the save_configuration + load_configuration should work all the same.
And how to export the results of cluster and mesh with the colors and labels?

If your clusters are defined on a CGAL::Point_set_3 (as is done in the example of the user manual), then you can just propagate the labels back to the inliers of each cluster and color them similarly to what is done in the point sets example.

For the mesh, if your are using a CGAL::Surface_mesh (as is done in the example of the user manual), then you can also generate a color for each face. The API is slightly different from Point_set: in Point_set, you need to define 3 properties of type unsigned char "r", "g" and "b", whereas for Surface_mesh, you need to define 1 face property of type CGAL::Color "v:color". Then, use CGAL::write_ply to save your mesh to the PLY format: https://doc.cgal.org/latest/Surface_mesh/group__PkgSurface__mesh.html#ga77bbb79d449c981895eedb6c3c23bd14

I hope this helps.

Best regards,

-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/

If you could give me help and suggestions, I would really appreciate it!

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei



On Wed 19. Feb 2020 at 16:27, Simon Giraudot <[hidden email]> wrote:

Hello,

Sorry you encountered trouble with CGAL Classification.

What version of CGAL are you using? Also, can you share a source code + the full error messages?

Best regards,


-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 18/02/2020 à 19:12, Zhang Jinwei a écrit :
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: CGAL classification

Zhang Jinwei
Dear Simon,

Following your solutions, the error is still not fixed. The error locates in the boost serialization head file throw_exception.hpp, showing an exception error at throw_exception() when processing the load_configuration function.

I guess it has something to do with the format of the config file of trained classifier.

1. Could you please specify the format and content of your generated config file after classifier training? 

2. Could you explain in detail how you generate such files, e.g. b9_cluster_config and b9_mesh_config?

3. As described in your example codes named example_generation_training, the output of the trained classifier is written in a .xml format, isn’t it?

4. If so, how could I utilize the .xml as input for classification? Because the load_configuration function requires stream files.

At this moment, I am stopped at this training and classifying step because of these confusions, even though I have my own training datasets. I really need your help and would appreciate for your explanation.

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei

On Mon 24. Feb 2020 at 16:58, Simon Giraudot <[hidden email]> wrote:

Dear Mr. Jinwei,

Le 21/02/2020 à 05:56, Zhang Jinwei a écrit :

For output configuration file I use:
std::ofstream fconfig(“classifier_config.gz”);
classifier.save_configuration(fconfig);
fconfig.close();
Note that on some OS (Windows for example), you need to specify the tag std::ios_base::binary so that the binary output is correctly written. That might be the source of your error here?

However, when I tried to produce and load my own configuration file by using save_ and load_configuration function, then I encountered  an exception errors which jumps to the boost serialization library file. I compared the file I produced with the file in your example, and I found your configuration file is ascii format while mine is binary format. So how did you generate the configuration file of the trained classifier?
You must be mistaken, the configuration files provided with CGAL are also binary (to be precise: they are compressed archives containing an ASCII file).

Another question: as shown in the examples, the cluster and mesh can also be classified by the package. But there is no example to show how to export them? In which format?
If you are talking about the configuration file, then it's no different from the point set case, the save_configuration + load_configuration should work all the same.
And how to export the results of cluster and mesh with the colors and labels?

If your clusters are defined on a CGAL::Point_set_3 (as is done in the example of the user manual), then you can just propagate the labels back to the inliers of each cluster and color them similarly to what is done in the point sets example.

For the mesh, if your are using a CGAL::Surface_mesh (as is done in the example of the user manual), then you can also generate a color for each face. The API is slightly different from Point_set: in Point_set, you need to define 3 properties of type unsigned char "r", "g" and "b", whereas for Surface_mesh, you need to define 1 face property of type CGAL::Color "v:color". Then, use CGAL::write_ply to save your mesh to the PLY format: https://doc.cgal.org/latest/Surface_mesh/group__PkgSurface__mesh.html#ga77bbb79d449c981895eedb6c3c23bd14

I hope this helps.

Best regards,

-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/

If you could give me help and suggestions, I would really appreciate it!

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei



On Wed 19. Feb 2020 at 16:27, Simon Giraudot <[hidden email]> wrote:

Hello,

Sorry you encountered trouble with CGAL Classification.

What version of CGAL are you using? Also, can you share a source code + the full error messages?

Best regards,


-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 18/02/2020 à 19:12, Zhang Jinwei a écrit :
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: CGAL classification

Zhang Jinwei
One more questions, a break point comes out when processing the data, which locate in the xmemory file. So does that mean it overflows the memory allocation? How could I expand the size of the threshold in order to train a large number of data?

I attached a screenshot of this error.

Thank you very much!
Jinwei

On Fri 28. Feb 2020 at 15:00, Zhang Jinwei <[hidden email]> wrote:
Dear Simon,

Following your solutions, the error is still not fixed. The error locates in the boost serialization head file throw_exception.hpp, showing an exception error at throw_exception() when processing the load_configuration function.

I guess it has something to do with the format of the config file of trained classifier.

1. Could you please specify the format and content of your generated config file after classifier training? 

2. Could you explain in detail how you generate such files, e.g. b9_cluster_config and b9_mesh_config?

3. As described in your example codes named example_generation_training, the output of the trained classifier is written in a .xml format, isn’t it?

4. If so, how could I utilize the .xml as input for classification? Because the load_configuration function requires stream files.

At this moment, I am stopped at this training and classifying step because of these confusions, even though I have my own training datasets. I really need your help and would appreciate for your explanation.

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei

On Mon 24. Feb 2020 at 16:58, Simon Giraudot <[hidden email]> wrote:

Dear Mr. Jinwei,

Le 21/02/2020 à 05:56, Zhang Jinwei a écrit :

For output configuration file I use:
std::ofstream fconfig(“classifier_config.gz”);
classifier.save_configuration(fconfig);
fconfig.close();
Note that on some OS (Windows for example), you need to specify the tag std::ios_base::binary so that the binary output is correctly written. That might be the source of your error here?

However, when I tried to produce and load my own configuration file by using save_ and load_configuration function, then I encountered  an exception errors which jumps to the boost serialization library file. I compared the file I produced with the file in your example, and I found your configuration file is ascii format while mine is binary format. So how did you generate the configuration file of the trained classifier?
You must be mistaken, the configuration files provided with CGAL are also binary (to be precise: they are compressed archives containing an ASCII file).

Another question: as shown in the examples, the cluster and mesh can also be classified by the package. But there is no example to show how to export them? In which format?
If you are talking about the configuration file, then it's no different from the point set case, the save_configuration + load_configuration should work all the same.
And how to export the results of cluster and mesh with the colors and labels?

If your clusters are defined on a CGAL::Point_set_3 (as is done in the example of the user manual), then you can just propagate the labels back to the inliers of each cluster and color them similarly to what is done in the point sets example.

For the mesh, if your are using a CGAL::Surface_mesh (as is done in the example of the user manual), then you can also generate a color for each face. The API is slightly different from Point_set: in Point_set, you need to define 3 properties of type unsigned char "r", "g" and "b", whereas for Surface_mesh, you need to define 1 face property of type CGAL::Color "v:color". Then, use CGAL::write_ply to save your mesh to the PLY format: https://doc.cgal.org/latest/Surface_mesh/group__PkgSurface__mesh.html#ga77bbb79d449c981895eedb6c3c23bd14

I hope this helps.

Best regards,

-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/

If you could give me help and suggestions, I would really appreciate it!

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei



On Wed 19. Feb 2020 at 16:27, Simon Giraudot <[hidden email]> wrote:

Hello,

Sorry you encountered trouble with CGAL Classification.

What version of CGAL are you using? Also, can you share a source code + the full error messages?

Best regards,


-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 18/02/2020 à 19:12, Zhang Jinwei a écrit :
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: CGAL classification

Zhang Jinwei
In reply to this post by Zhang Jinwei
Hi Simon,

How did you produce the config file in such format? (See attached figure) 


When I use the save_ and load_configuration() function, it produces config file in binary format which is not readable, and therefore comes out exception error when running.

I found that if the config file in this format, then there would be no errors. Otherwise, the binary config file would cause exception error.

So now I conclude that the issue is mainly about the load and save problem, relating to the file format. So how could I output the config file in non-binary format after training?

Looking forward to your reply!

Jinwei

On Fri 28. Feb 2020 at 15:00, Zhang Jinwei <[hidden email]> wrote:
Dear Simon,

Following your solutions, the error is still not fixed. The error locates in the boost serialization head file throw_exception.hpp, showing an exception error at throw_exception() when processing the load_configuration function.

I guess it has something to do with the format of the config file of trained classifier.

1. Could you please specify the format and content of your generated config file after classifier training? 

2. Could you explain in detail how you generate such files, e.g. b9_cluster_config and b9_mesh_config?

3. As described in your example codes named example_generation_training, the output of the trained classifier is written in a .xml format, isn’t it?

4. If so, how could I utilize the .xml as input for classification? Because the load_configuration function requires stream files.

At this moment, I am stopped at this training and classifying step because of these confusions, even though I have my own training datasets. I really need your help and would appreciate for your explanation.

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei

On Mon 24. Feb 2020 at 16:58, Simon Giraudot <[hidden email]> wrote:

Dear Mr. Jinwei,

Le 21/02/2020 à 05:56, Zhang Jinwei a écrit :

For output configuration file I use:
std::ofstream fconfig(“classifier_config.gz”);
classifier.save_configuration(fconfig);
fconfig.close();
Note that on some OS (Windows for example), you need to specify the tag std::ios_base::binary so that the binary output is correctly written. That might be the source of your error here?

However, when I tried to produce and load my own configuration file by using save_ and load_configuration function, then I encountered  an exception errors which jumps to the boost serialization library file. I compared the file I produced with the file in your example, and I found your configuration file is ascii format while mine is binary format. So how did you generate the configuration file of the trained classifier?
You must be mistaken, the configuration files provided with CGAL are also binary (to be precise: they are compressed archives containing an ASCII file).

Another question: as shown in the examples, the cluster and mesh can also be classified by the package. But there is no example to show how to export them? In which format?
If you are talking about the configuration file, then it's no different from the point set case, the save_configuration + load_configuration should work all the same.
And how to export the results of cluster and mesh with the colors and labels?

If your clusters are defined on a CGAL::Point_set_3 (as is done in the example of the user manual), then you can just propagate the labels back to the inliers of each cluster and color them similarly to what is done in the point sets example.

For the mesh, if your are using a CGAL::Surface_mesh (as is done in the example of the user manual), then you can also generate a color for each face. The API is slightly different from Point_set: in Point_set, you need to define 3 properties of type unsigned char "r", "g" and "b", whereas for Surface_mesh, you need to define 1 face property of type CGAL::Color "v:color". Then, use CGAL::write_ply to save your mesh to the PLY format: https://doc.cgal.org/latest/Surface_mesh/group__PkgSurface__mesh.html#ga77bbb79d449c981895eedb6c3c23bd14

I hope this helps.

Best regards,

-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/

If you could give me help and suggestions, I would really appreciate it!

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei



On Wed 19. Feb 2020 at 16:27, Simon Giraudot <[hidden email]> wrote:

Hello,

Sorry you encountered trouble with CGAL Classification.

What version of CGAL are you using? Also, can you share a source code + the full error messages?

Best regards,


-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 18/02/2020 à 19:12, Zhang Jinwei a écrit :
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: CGAL classification

Simon Giraudot-2
In reply to this post by Zhang Jinwei

Dear Zhang,

Le 28/02/2020 à 08:00, Zhang Jinwei a écrit :

1. Could you please specify the format and content of your generated config file after classifier training?
As I said, the format is an ASCII file compressed in a GZ archive. Same as the GZ files provided by CGAL. They *are* binary files, the fact that you can open them with a text reader is probably a feature of your text reader which may be able to decompress GZ archives on the fly an display the content of the

2. Could you explain in detail how you generate such files, e.g. b9_cluster_config and b9_mesh_config?
They were generated using the `save_configuration()` method, there are no tricks or hidden formulas here. (The line in the demo I used to generate them: https://github.com/CGAL/cgal/blob/master/Polyhedron/demo/Polyhedron/Plugins/Classification/Item_classification_base.h#L182 )

3. As described in your example codes named example_generation_training, the output of the trained classifier is written in a .xml format, isn’t it?
You're talking about a different classifier (Sum of weighted features) which uses a different format. This is not related to the ETHZ Random Forest which uses the GZ format.

4. If so, how could I utilize the .xml as input for classification? Because the load_configuration function requires stream files.
XML files for Sum Of Weighted Features and GZ from ETHZ Random Forest are not compatible at all.

At this moment, I am stopped at this training and classifying step because of these confusions, even though I have my own training datasets. I really need your help and would appreciate for your explanation.

I'm doing my best to figure what's going on, but it's very complicated to help without seeing the actual code (not just 2 lines copied in a mail), the cmake output or the actual error. The screenshot of the breakpoint comes from a deep code in Boost and is not related to CGAL, the problem probably comes before that.

If you can provide more information I can investigate more.

Best,

Simon


Thank you very much! Looking forward to your reply!

Best regards,
Jinwei

On Mon 24. Feb 2020 at 16:58, Simon Giraudot <[hidden email]> wrote:

Dear Mr. Jinwei,

Le 21/02/2020 à 05:56, Zhang Jinwei a écrit :

For output configuration file I use:
std::ofstream fconfig(“classifier_config.gz”);
classifier.save_configuration(fconfig);
fconfig.close();
Note that on some OS (Windows for example), you need to specify the tag std::ios_base::binary so that the binary output is correctly written. That might be the source of your error here?

However, when I tried to produce and load my own configuration file by using save_ and load_configuration function, then I encountered  an exception errors which jumps to the boost serialization library file. I compared the file I produced with the file in your example, and I found your configuration file is ascii format while mine is binary format. So how did you generate the configuration file of the trained classifier?
You must be mistaken, the configuration files provided with CGAL are also binary (to be precise: they are compressed archives containing an ASCII file).

Another question: as shown in the examples, the cluster and mesh can also be classified by the package. But there is no example to show how to export them? In which format?
If you are talking about the configuration file, then it's no different from the point set case, the save_configuration + load_configuration should work all the same.
And how to export the results of cluster and mesh with the colors and labels?

If your clusters are defined on a CGAL::Point_set_3 (as is done in the example of the user manual), then you can just propagate the labels back to the inliers of each cluster and color them similarly to what is done in the point sets example.

For the mesh, if your are using a CGAL::Surface_mesh (as is done in the example of the user manual), then you can also generate a color for each face. The API is slightly different from Point_set: in Point_set, you need to define 3 properties of type unsigned char "r", "g" and "b", whereas for Surface_mesh, you need to define 1 face property of type CGAL::Color "v:color". Then, use CGAL::write_ply to save your mesh to the PLY format: https://doc.cgal.org/latest/Surface_mesh/group__PkgSurface__mesh.html#ga77bbb79d449c981895eedb6c3c23bd14

I hope this helps.

Best regards,

-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/

If you could give me help and suggestions, I would really appreciate it!

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei



On Wed 19. Feb 2020 at 16:27, Simon Giraudot <[hidden email]> wrote:

Hello,

Sorry you encountered trouble with CGAL Classification.

What version of CGAL are you using? Also, can you share a source code + the full error messages?

Best regards,


-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 18/02/2020 à 19:12, Zhang Jinwei a écrit :
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: CGAL classification

Zhang Jinwei
Dear Simon, 

Thanks for your kindly reply. After reading your demo codes, I have already fixed several errors due to the file format. Now the problem occurs at the training step, where the break point locates in node.hpp from the ETHZ random forest package. If I use the example training dataset, everything is ok. However, when use my own labeled point clouds, it encounter such errors. 

So may I ask whether there is a specific definition of the format of the training dataset? In my dataset, everything point has a label in terms of integer number, denoting different classes. In your example dataset, just part of points are labeled and others with default value -1. Then I am just wondering, isn’t it allowed to give a fully labeled dataset to random forest? Or perhaps any other reasons?

Thank you again for your help.

Regards,
Jinwei



On Fri 28. Feb 2020 at 17:45, Simon Giraudot <[hidden email]> wrote:

Dear Zhang,

Le 28/02/2020 à 08:00, Zhang Jinwei a écrit :

1. Could you please specify the format and content of your generated config file after classifier training?
As I said, the format is an ASCII file compressed in a GZ archive. Same as the GZ files provided by CGAL. They *are* binary files, the fact that you can open them with a text reader is probably a feature of your text reader which may be able to decompress GZ archives on the fly an display the content of the

2. Could you explain in detail how you generate such files, e.g. b9_cluster_config and b9_mesh_config?
They were generated using the `save_configuration()` method, there are no tricks or hidden formulas here. (The line in the demo I used to generate them: https://github.com/CGAL/cgal/blob/master/Polyhedron/demo/Polyhedron/Plugins/Classification/Item_classification_base.h#L182 )

3. As described in your example codes named example_generation_training, the output of the trained classifier is written in a .xml format, isn’t it?
You're talking about a different classifier (Sum of weighted features) which uses a different format. This is not related to the ETHZ Random Forest which uses the GZ format.

4. If so, how could I utilize the .xml as input for classification? Because the load_configuration function requires stream files.
XML files for Sum Of Weighted Features and GZ from ETHZ Random Forest are not compatible at all.

At this moment, I am stopped at this training and classifying step because of these confusions, even though I have my own training datasets. I really need your help and would appreciate for your explanation.

I'm doing my best to figure what's going on, but it's very complicated to help without seeing the actual code (not just 2 lines copied in a mail), the cmake output or the actual error. The screenshot of the breakpoint comes from a deep code in Boost and is not related to CGAL, the problem probably comes before that.

If you can provide more information I can investigate more.

Best,

Simon


Thank you very much! Looking forward to your reply!

Best regards,
Jinwei

On Mon 24. Feb 2020 at 16:58, Simon Giraudot <[hidden email]> wrote:

Dear Mr. Jinwei,

Le 21/02/2020 à 05:56, Zhang Jinwei a écrit :

For output configuration file I use:
std::ofstream fconfig(“classifier_config.gz”);
classifier.save_configuration(fconfig);
fconfig.close();
Note that on some OS (Windows for example), you need to specify the tag std::ios_base::binary so that the binary output is correctly written. That might be the source of your error here?

However, when I tried to produce and load my own configuration file by using save_ and load_configuration function, then I encountered  an exception errors which jumps to the boost serialization library file. I compared the file I produced with the file in your example, and I found your configuration file is ascii format while mine is binary format. So how did you generate the configuration file of the trained classifier?
You must be mistaken, the configuration files provided with CGAL are also binary (to be precise: they are compressed archives containing an ASCII file).

Another question: as shown in the examples, the cluster and mesh can also be classified by the package. But there is no example to show how to export them? In which format?
If you are talking about the configuration file, then it's no different from the point set case, the save_configuration + load_configuration should work all the same.
And how to export the results of cluster and mesh with the colors and labels?

If your clusters are defined on a CGAL::Point_set_3 (as is done in the example of the user manual), then you can just propagate the labels back to the inliers of each cluster and color them similarly to what is done in the point sets example.

For the mesh, if your are using a CGAL::Surface_mesh (as is done in the example of the user manual), then you can also generate a color for each face. The API is slightly different from Point_set: in Point_set, you need to define 3 properties of type unsigned char "r", "g" and "b", whereas for Surface_mesh, you need to define 1 face property of type CGAL::Color "v:color". Then, use CGAL::write_ply to save your mesh to the PLY format: https://doc.cgal.org/latest/Surface_mesh/group__PkgSurface__mesh.html#ga77bbb79d449c981895eedb6c3c23bd14

I hope this helps.

Best regards,

-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/

If you could give me help and suggestions, I would really appreciate it!

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei



On Wed 19. Feb 2020 at 16:27, Simon Giraudot <[hidden email]> wrote:

Hello,

Sorry you encountered trouble with CGAL Classification.

What version of CGAL are you using? Also, can you share a source code + the full error messages?

Best regards,


-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 18/02/2020 à 19:12, Zhang Jinwei a écrit :
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: CGAL classification

Zhang Jinwei
Here are the screenshots of the errors.




On Sat 29. Feb 2020 at 16:03, Zhang Jinwei <[hidden email]> wrote:
Dear Simon, 

Thanks for your kindly reply. After reading your demo codes, I have already fixed several errors due to the file format. Now the problem occurs at the training step, where the break point locates in node.hpp from the ETHZ random forest package. If I use the example training dataset, everything is ok. However, when use my own labeled point clouds, it encounter such errors. 

So may I ask whether there is a specific definition of the format of the training dataset? In my dataset, everything point has a label in terms of integer number, denoting different classes. In your example dataset, just part of points are labeled and others with default value -1. Then I am just wondering, isn’t it allowed to give a fully labeled dataset to random forest? Or perhaps any other reasons?

Thank you again for your help.

Regards,
Jinwei



On Fri 28. Feb 2020 at 17:45, Simon Giraudot <[hidden email]> wrote:

Dear Zhang,

Le 28/02/2020 à 08:00, Zhang Jinwei a écrit :

1. Could you please specify the format and content of your generated config file after classifier training?
As I said, the format is an ASCII file compressed in a GZ archive. Same as the GZ files provided by CGAL. They *are* binary files, the fact that you can open them with a text reader is probably a feature of your text reader which may be able to decompress GZ archives on the fly an display the content of the

2. Could you explain in detail how you generate such files, e.g. b9_cluster_config and b9_mesh_config?
They were generated using the `save_configuration()` method, there are no tricks or hidden formulas here. (The line in the demo I used to generate them: https://github.com/CGAL/cgal/blob/master/Polyhedron/demo/Polyhedron/Plugins/Classification/Item_classification_base.h#L182 )

3. As described in your example codes named example_generation_training, the output of the trained classifier is written in a .xml format, isn’t it?
You're talking about a different classifier (Sum of weighted features) which uses a different format. This is not related to the ETHZ Random Forest which uses the GZ format.

4. If so, how could I utilize the .xml as input for classification? Because the load_configuration function requires stream files.
XML files for Sum Of Weighted Features and GZ from ETHZ Random Forest are not compatible at all.

At this moment, I am stopped at this training and classifying step because of these confusions, even though I have my own training datasets. I really need your help and would appreciate for your explanation.

I'm doing my best to figure what's going on, but it's very complicated to help without seeing the actual code (not just 2 lines copied in a mail), the cmake output or the actual error. The screenshot of the breakpoint comes from a deep code in Boost and is not related to CGAL, the problem probably comes before that.

If you can provide more information I can investigate more.

Best,

Simon


Thank you very much! Looking forward to your reply!

Best regards,
Jinwei

On Mon 24. Feb 2020 at 16:58, Simon Giraudot <[hidden email]> wrote:

Dear Mr. Jinwei,

Le 21/02/2020 à 05:56, Zhang Jinwei a écrit :

For output configuration file I use:
std::ofstream fconfig(“classifier_config.gz”);
classifier.save_configuration(fconfig);
fconfig.close();
Note that on some OS (Windows for example), you need to specify the tag std::ios_base::binary so that the binary output is correctly written. That might be the source of your error here?

However, when I tried to produce and load my own configuration file by using save_ and load_configuration function, then I encountered  an exception errors which jumps to the boost serialization library file. I compared the file I produced with the file in your example, and I found your configuration file is ascii format while mine is binary format. So how did you generate the configuration file of the trained classifier?
You must be mistaken, the configuration files provided with CGAL are also binary (to be precise: they are compressed archives containing an ASCII file).

Another question: as shown in the examples, the cluster and mesh can also be classified by the package. But there is no example to show how to export them? In which format?
If you are talking about the configuration file, then it's no different from the point set case, the save_configuration + load_configuration should work all the same.
And how to export the results of cluster and mesh with the colors and labels?

If your clusters are defined on a CGAL::Point_set_3 (as is done in the example of the user manual), then you can just propagate the labels back to the inliers of each cluster and color them similarly to what is done in the point sets example.

For the mesh, if your are using a CGAL::Surface_mesh (as is done in the example of the user manual), then you can also generate a color for each face. The API is slightly different from Point_set: in Point_set, you need to define 3 properties of type unsigned char "r", "g" and "b", whereas for Surface_mesh, you need to define 1 face property of type CGAL::Color "v:color". Then, use CGAL::write_ply to save your mesh to the PLY format: https://doc.cgal.org/latest/Surface_mesh/group__PkgSurface__mesh.html#ga77bbb79d449c981895eedb6c3c23bd14

I hope this helps.

Best regards,

-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/

If you could give me help and suggestions, I would really appreciate it!

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei



On Wed 19. Feb 2020 at 16:27, Simon Giraudot <[hidden email]> wrote:

Hello,

Sorry you encountered trouble with CGAL Classification.

What version of CGAL are you using? Also, can you share a source code + the full error messages?

Best regards,


-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 18/02/2020 à 19:12, Zhang Jinwei a écrit :
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: CGAL classification

Simon Giraudot-2
In reply to this post by Zhang Jinwei

Hello Zhang,

As explained in the manual https://doc.cgal.org/latest/Classification/classCGAL_1_1Classification_1_1ETHZ_1_1Random__forest__classifier.html#a7c0b299cb5829f598f395bcc16df72fa the expected format for the ground truth range that you give to the train() function is, for each input point, the index of its expected label in the Label_set that you used.

Judging by the breakpoint you provided, the ground truth that you pass probably contains indices which exceed the Label_set number of labels (I'm mostly guessing as you don't provide any code/data for context).

Points with label value -1 are ignored, but there's no problem in giving a fully labeled dataset to the random forest.

Best regards,

-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 29/02/2020 à 09:03, Zhang Jinwei a écrit :
Dear Simon, 

Thanks for your kindly reply. After reading your demo codes, I have already fixed several errors due to the file format. Now the problem occurs at the training step, where the break point locates in node.hpp from the ETHZ random forest package. If I use the example training dataset, everything is ok. However, when use my own labeled point clouds, it encounter such errors. 

So may I ask whether there is a specific definition of the format of the training dataset? In my dataset, everything point has a label in terms of integer number, denoting different classes. In your example dataset, just part of points are labeled and others with default value -1. Then I am just wondering, isn’t it allowed to give a fully labeled dataset to random forest? Or perhaps any other reasons?

Thank you again for your help.

Regards,
Jinwei



On Fri 28. Feb 2020 at 17:45, Simon Giraudot <[hidden email]> wrote:

Dear Zhang,

Le 28/02/2020 à 08:00, Zhang Jinwei a écrit :

1. Could you please specify the format and content of your generated config file after classifier training?
As I said, the format is an ASCII file compressed in a GZ archive. Same as the GZ files provided by CGAL. They *are* binary files, the fact that you can open them with a text reader is probably a feature of your text reader which may be able to decompress GZ archives on the fly an display the content of the

2. Could you explain in detail how you generate such files, e.g. b9_cluster_config and b9_mesh_config?
They were generated using the `save_configuration()` method, there are no tricks or hidden formulas here. (The line in the demo I used to generate them: https://github.com/CGAL/cgal/blob/master/Polyhedron/demo/Polyhedron/Plugins/Classification/Item_classification_base.h#L182 )

3. As described in your example codes named example_generation_training, the output of the trained classifier is written in a .xml format, isn’t it?
You're talking about a different classifier (Sum of weighted features) which uses a different format. This is not related to the ETHZ Random Forest which uses the GZ format.

4. If so, how could I utilize the .xml as input for classification? Because the load_configuration function requires stream files.
XML files for Sum Of Weighted Features and GZ from ETHZ Random Forest are not compatible at all.

At this moment, I am stopped at this training and classifying step because of these confusions, even though I have my own training datasets. I really need your help and would appreciate for your explanation.

I'm doing my best to figure what's going on, but it's very complicated to help without seeing the actual code (not just 2 lines copied in a mail), the cmake output or the actual error. The screenshot of the breakpoint comes from a deep code in Boost and is not related to CGAL, the problem probably comes before that.

If you can provide more information I can investigate more.

Best,

Simon


Thank you very much! Looking forward to your reply!

Best regards,
Jinwei

On Mon 24. Feb 2020 at 16:58, Simon Giraudot <[hidden email]> wrote:

Dear Mr. Jinwei,

Le 21/02/2020 à 05:56, Zhang Jinwei a écrit :

For output configuration file I use:
std::ofstream fconfig(“classifier_config.gz”);
classifier.save_configuration(fconfig);
fconfig.close();
Note that on some OS (Windows for example), you need to specify the tag std::ios_base::binary so that the binary output is correctly written. That might be the source of your error here?

However, when I tried to produce and load my own configuration file by using save_ and load_configuration function, then I encountered  an exception errors which jumps to the boost serialization library file. I compared the file I produced with the file in your example, and I found your configuration file is ascii format while mine is binary format. So how did you generate the configuration file of the trained classifier?
You must be mistaken, the configuration files provided with CGAL are also binary (to be precise: they are compressed archives containing an ASCII file).

Another question: as shown in the examples, the cluster and mesh can also be classified by the package. But there is no example to show how to export them? In which format?
If you are talking about the configuration file, then it's no different from the point set case, the save_configuration + load_configuration should work all the same.
And how to export the results of cluster and mesh with the colors and labels?

If your clusters are defined on a CGAL::Point_set_3 (as is done in the example of the user manual), then you can just propagate the labels back to the inliers of each cluster and color them similarly to what is done in the point sets example.

For the mesh, if your are using a CGAL::Surface_mesh (as is done in the example of the user manual), then you can also generate a color for each face. The API is slightly different from Point_set: in Point_set, you need to define 3 properties of type unsigned char "r", "g" and "b", whereas for Surface_mesh, you need to define 1 face property of type CGAL::Color "v:color". Then, use CGAL::write_ply to save your mesh to the PLY format: https://doc.cgal.org/latest/Surface_mesh/group__PkgSurface__mesh.html#ga77bbb79d449c981895eedb6c3c23bd14

I hope this helps.

Best regards,

-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/

If you could give me help and suggestions, I would really appreciate it!

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei



On Wed 19. Feb 2020 at 16:27, Simon Giraudot <[hidden email]> wrote:

Hello,

Sorry you encountered trouble with CGAL Classification.

What version of CGAL are you using? Also, can you share a source code + the full error messages?

Best regards,


-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 18/02/2020 à 19:12, Zhang Jinwei a écrit :
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: CGAL classification

Zhang Jinwei
Hello Simon,

Thanks for your reply last time. It was the problem of the data format.

Now I encountered another problem, when I trying to run the example code of region_growing_on_polygon_mesh.cpp in the shape detection package for mesh segmentation. 

Still, using the example dataset is fine, but I tried to input another test dataset myself, it turns to collapse. This time I just compared the .off format of the files, they have definitely the same. I have tried several different datasets, and had the same errors. So it seems to be bugs in the codes, isn’t it?

Please see the error information in the attachment. Thank you very much!

Look forward to your reply!

Best regards,
Jinwei Zhang



On Mon 2. Mar 2020 at 17:12, Simon Giraudot <[hidden email]> wrote:

Hello Zhang,

As explained in the manual https://doc.cgal.org/latest/Classification/classCGAL_1_1Classification_1_1ETHZ_1_1Random__forest__classifier.html#a7c0b299cb5829f598f395bcc16df72fa the expected format for the ground truth range that you give to the train() function is, for each input point, the index of its expected label in the Label_set that you used.

Judging by the breakpoint you provided, the ground truth that you pass probably contains indices which exceed the Label_set number of labels (I'm mostly guessing as you don't provide any code/data for context).

Points with label value -1 are ignored, but there's no problem in giving a fully labeled dataset to the random forest.

Best regards,

-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 29/02/2020 à 09:03, Zhang Jinwei a écrit :
Dear Simon, 

Thanks for your kindly reply. After reading your demo codes, I have already fixed several errors due to the file format. Now the problem occurs at the training step, where the break point locates in node.hpp from the ETHZ random forest package. If I use the example training dataset, everything is ok. However, when use my own labeled point clouds, it encounter such errors. 

So may I ask whether there is a specific definition of the format of the training dataset? In my dataset, everything point has a label in terms of integer number, denoting different classes. In your example dataset, just part of points are labeled and others with default value -1. Then I am just wondering, isn’t it allowed to give a fully labeled dataset to random forest? Or perhaps any other reasons?

Thank you again for your help.

Regards,
Jinwei



On Fri 28. Feb 2020 at 17:45, Simon Giraudot <[hidden email]> wrote:

Dear Zhang,

Le 28/02/2020 à 08:00, Zhang Jinwei a écrit :

1. Could you please specify the format and content of your generated config file after classifier training?
As I said, the format is an ASCII file compressed in a GZ archive. Same as the GZ files provided by CGAL. They *are* binary files, the fact that you can open them with a text reader is probably a feature of your text reader which may be able to decompress GZ archives on the fly an display the content of the

2. Could you explain in detail how you generate such files, e.g. b9_cluster_config and b9_mesh_config?
They were generated using the `save_configuration()` method, there are no tricks or hidden formulas here. (The line in the demo I used to generate them: https://github.com/CGAL/cgal/blob/master/Polyhedron/demo/Polyhedron/Plugins/Classification/Item_classification_base.h#L182 )

3. As described in your example codes named example_generation_training, the output of the trained classifier is written in a .xml format, isn’t it?
You're talking about a different classifier (Sum of weighted features) which uses a different format. This is not related to the ETHZ Random Forest which uses the GZ format.

4. If so, how could I utilize the .xml as input for classification? Because the load_configuration function requires stream files.
XML files for Sum Of Weighted Features and GZ from ETHZ Random Forest are not compatible at all.

At this moment, I am stopped at this training and classifying step because of these confusions, even though I have my own training datasets. I really need your help and would appreciate for your explanation.

I'm doing my best to figure what's going on, but it's very complicated to help without seeing the actual code (not just 2 lines copied in a mail), the cmake output or the actual error. The screenshot of the breakpoint comes from a deep code in Boost and is not related to CGAL, the problem probably comes before that.

If you can provide more information I can investigate more.

Best,

Simon


Thank you very much! Looking forward to your reply!

Best regards,
Jinwei

On Mon 24. Feb 2020 at 16:58, Simon Giraudot <[hidden email]> wrote:

Dear Mr. Jinwei,

Le 21/02/2020 à 05:56, Zhang Jinwei a écrit :

For output configuration file I use:
std::ofstream fconfig(“classifier_config.gz”);
classifier.save_configuration(fconfig);
fconfig.close();
Note that on some OS (Windows for example), you need to specify the tag std::ios_base::binary so that the binary output is correctly written. That might be the source of your error here?

However, when I tried to produce and load my own configuration file by using save_ and load_configuration function, then I encountered  an exception errors which jumps to the boost serialization library file. I compared the file I produced with the file in your example, and I found your configuration file is ascii format while mine is binary format. So how did you generate the configuration file of the trained classifier?
You must be mistaken, the configuration files provided with CGAL are also binary (to be precise: they are compressed archives containing an ASCII file).

Another question: as shown in the examples, the cluster and mesh can also be classified by the package. But there is no example to show how to export them? In which format?
If you are talking about the configuration file, then it's no different from the point set case, the save_configuration + load_configuration should work all the same.
And how to export the results of cluster and mesh with the colors and labels?

If your clusters are defined on a CGAL::Point_set_3 (as is done in the example of the user manual), then you can just propagate the labels back to the inliers of each cluster and color them similarly to what is done in the point sets example.

For the mesh, if your are using a CGAL::Surface_mesh (as is done in the example of the user manual), then you can also generate a color for each face. The API is slightly different from Point_set: in Point_set, you need to define 3 properties of type unsigned char "r", "g" and "b", whereas for Surface_mesh, you need to define 1 face property of type CGAL::Color "v:color". Then, use CGAL::write_ply to save your mesh to the PLY format: https://doc.cgal.org/latest/Surface_mesh/group__PkgSurface__mesh.html#ga77bbb79d449c981895eedb6c3c23bd14

I hope this helps.

Best regards,

-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/

If you could give me help and suggestions, I would really appreciate it!

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei



On Wed 19. Feb 2020 at 16:27, Simon Giraudot <[hidden email]> wrote:

Hello,

Sorry you encountered trouble with CGAL Classification.

What version of CGAL are you using? Also, can you share a source code + the full error messages?

Best regards,


-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 18/02/2020 à 19:12, Zhang Jinwei a écrit :
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: CGAL classification

Dmitry Anisimov
Hi Jinwei,

Try to change your Kernel to the inexact one:

If you simply copy pasted the example, then you are currently running it with the Exact_predicates_exact_constructions_kernel. 
Try to use the Exact_predicates_inexact_constructions_kernel or Simple_cartesian<double>. Do not forget to include it as
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

Cheers,
Dmitry

-- 
Dmitry Anisimov, PhD
R&D Engineer
GeometryFactory - https://geometryfactory.com/

On 9 Mar 2020 at 10:26 +0100, Zhang Jinwei <[hidden email]>, wrote:
Hello Simon,

Thanks for your reply last time. It was the problem of the data format.

Now I encountered another problem, when I trying to run the example code of region_growing_on_polygon_mesh.cpp in the shape detection package for mesh segmentation. 

Still, using the example dataset is fine, but I tried to input another test dataset myself, it turns to collapse. This time I just compared the .off format of the files, they have definitely the same. I have tried several different datasets, and had the same errors. So it seems to be bugs in the codes, isn’t it?

Please see the error information in the attachment. Thank you very much!

Look forward to your reply!

Best regards,
Jinwei Zhang

<IMG_7046.jpg>


On Mon 2. Mar 2020 at 17:12, Simon Giraudot <[hidden email]> wrote:

Hello Zhang,

As explained in the manual https://doc.cgal.org/latest/Classification/classCGAL_1_1Classification_1_1ETHZ_1_1Random__forest__classifier.html#a7c0b299cb5829f598f395bcc16df72fa the expected format for the ground truth range that you give to the train() function is, for each input point, the index of its expected label in the Label_set that you used.

Judging by the breakpoint you provided, the ground truth that you pass probably contains indices which exceed the Label_set number of labels (I'm mostly guessing as you don't provide any code/data for context).

Points with label value -1 are ignored, but there's no problem in giving a fully labeled dataset to the random forest.

Best regards,

--  
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 29/02/2020 à 09:03, Zhang Jinwei a écrit :
Dear Simon, 

Thanks for your kindly reply. After reading your demo codes, I have already fixed several errors due to the file format. Now the problem occurs at the training step, where the break point locates in node.hpp from the ETHZ random forest package. If I use the example training dataset, everything is ok. However, when use my own labeled point clouds, it encounter such errors. 

So may I ask whether there is a specific definition of the format of the training dataset? In my dataset, everything point has a label in terms of integer number, denoting different classes. In your example dataset, just part of points are labeled and others with default value -1. Then I am just wondering, isn’t it allowed to give a fully labeled dataset to random forest? Or perhaps any other reasons?

Thank you again for your help.

Regards,
Jinwei



On Fri 28. Feb 2020 at 17:45, Simon Giraudot <[hidden email]> wrote:

Dear Zhang,

Le 28/02/2020 à 08:00, Zhang Jinwei a écrit :

1. Could you please specify the format and content of your generated config file after classifier training?
As I said, the format is an ASCII file compressed in a GZ archive. Same as the GZ files provided by CGAL. They *are* binary files, the fact that you can open them with a text reader is probably a feature of your text reader which may be able to decompress GZ archives on the fly an display the content of the

2. Could you explain in detail how you generate such files, e.g. b9_cluster_config and b9_mesh_config?
They were generated using the `save_configuration()` method, there are no tricks or hidden formulas here. (The line in the demo I used to generate them: https://github.com/CGAL/cgal/blob/master/Polyhedron/demo/Polyhedron/Plugins/Classification/Item_classification_base.h#L182 )

3. As described in your example codes named example_generation_training, the output of the trained classifier is written in a .xml format, isn’t it?
You're talking about a different classifier (Sum of weighted features) which uses a different format. This is not related to the ETHZ Random Forest which uses the GZ format.

4. If so, how could I utilize the .xml as input for classification? Because the load_configuration function requires stream files.
XML files for Sum Of Weighted Features and GZ from ETHZ Random Forest are not compatible at all.

At this moment, I am stopped at this training and classifying step because of these confusions, even though I have my own training datasets. I really need your help and would appreciate for your explanation.

I'm doing my best to figure what's going on, but it's very complicated to help without seeing the actual code (not just 2 lines copied in a mail), the cmake output or the actual error. The screenshot of the breakpoint comes from a deep code in Boost and is not related to CGAL, the problem probably comes before that.

If you can provide more information I can investigate more.

Best,

Simon


Thank you very much! Looking forward to your reply!

Best regards,
Jinwei

On Mon 24. Feb 2020 at 16:58, Simon Giraudot <[hidden email]> wrote:

Dear Mr. Jinwei,

Le 21/02/2020 à 05:56, Zhang Jinwei a écrit :

For output configuration file I use:
std::ofstream fconfig(“classifier_config.gz”);
classifier.save_configuration(fconfig);
fconfig.close();
Note that on some OS (Windows for example), you need to specify the tag std::ios_base::binary so that the binary output is correctly written. That might be the source of your error here?

However, when I tried to produce and load my own configuration file by using save_ and load_configuration function, then I encountered  an exception errors which jumps to the boost serialization library file. I compared the file I produced with the file in your example, and I found your configuration file is ascii format while mine is binary format. So how did you generate the configuration file of the trained classifier?
You must be mistaken, the configuration files provided with CGAL are also binary (to be precise: they are compressed archives containing an ASCII file).

Another question: as shown in the examples, the cluster and mesh can also be classified by the package. But there is no example to show how to export them? In which format?
If you are talking about the configuration file, then it's no different from the point set case, the save_configuration + load_configuration should work all the same.
And how to export the results of cluster and mesh with the colors and labels?

If your clusters are defined on a CGAL::Point_set_3 (as is done in the example of the user manual), then you can just propagate the labels back to the inliers of each cluster and color them similarly to what is done in the point sets example.

For the mesh, if your are using a CGAL::Surface_mesh (as is done in the example of the user manual), then you can also generate a color for each face. The API is slightly different from Point_set: in Point_set, you need to define 3 properties of type unsigned char "r", "g" and "b", whereas for Surface_mesh, you need to define 1 face property of type CGAL::Color "v:color". Then, use CGAL::write_ply to save your mesh to the PLY format: https://doc.cgal.org/latest/Surface_mesh/group__PkgSurface__mesh.html#ga77bbb79d449c981895eedb6c3c23bd14

I hope this helps.

Best regards,

--  
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/

If you could give me help and suggestions, I would really appreciate it!

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei



On Wed 19. Feb 2020 at 16:27, Simon Giraudot <[hidden email]> wrote:

Hello,

Sorry you encountered trouble with CGAL Classification.

What version of CGAL are you using? Also, can you share a source code + the full error messages?

Best regards,


--  
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 18/02/2020 à 19:12, Zhang Jinwei a écrit :
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: CGAL classification

Zhang Jinwei
Hi Dmitry,

Thanks for your quick reply. I tried again following your tips, and unfortunately it still produced the same error. Perhaps due to other reasons?

Jinwei

On Mon 9. Mar 2020 at 17:34, Dmitry Anisimov <[hidden email]> wrote:
Hi Jinwei,

Try to change your Kernel to the inexact one:

If you simply copy pasted the example, then you are currently running it with the Exact_predicates_exact_constructions_kernel. 
Try to use the Exact_predicates_inexact_constructions_kernel or Simple_cartesian<double>. Do not forget to include it as
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

Cheers,
Dmitry

-- 
Dmitry Anisimov, PhD
R&D Engineer
GeometryFactory - https://geometryfactory.com/

On 9 Mar 2020 at 10:26 +0100, Zhang Jinwei <[hidden email]>, wrote:
Hello Simon,

Thanks for your reply last time. It was the problem of the data format.

Now I encountered another problem, when I trying to run the example code of region_growing_on_polygon_mesh.cpp in the shape detection package for mesh segmentation. 

Still, using the example dataset is fine, but I tried to input another test dataset myself, it turns to collapse. This time I just compared the .off format of the files, they have definitely the same. I have tried several different datasets, and had the same errors. So it seems to be bugs in the codes, isn’t it?

Please see the error information in the attachment. Thank you very much!

Look forward to your reply!

Best regards,
Jinwei Zhang

<IMG_7046.jpg>


On Mon 2. Mar 2020 at 17:12, Simon Giraudot <[hidden email]> wrote:

Hello Zhang,

As explained in the manual https://doc.cgal.org/latest/Classification/classCGAL_1_1Classification_1_1ETHZ_1_1Random__forest__classifier.html#a7c0b299cb5829f598f395bcc16df72fa the expected format for the ground truth range that you give to the train() function is, for each input point, the index of its expected label in the Label_set that you used.

Judging by the breakpoint you provided, the ground truth that you pass probably contains indices which exceed the Label_set number of labels (I'm mostly guessing as you don't provide any code/data for context).

Points with label value -1 are ignored, but there's no problem in giving a fully labeled dataset to the random forest.

Best regards,

--  
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 29/02/2020 à 09:03, Zhang Jinwei a écrit :
Dear Simon, 

Thanks for your kindly reply. After reading your demo codes, I have already fixed several errors due to the file format. Now the problem occurs at the training step, where the break point locates in node.hpp from the ETHZ random forest package. If I use the example training dataset, everything is ok. However, when use my own labeled point clouds, it encounter such errors. 

So may I ask whether there is a specific definition of the format of the training dataset? In my dataset, everything point has a label in terms of integer number, denoting different classes. In your example dataset, just part of points are labeled and others with default value -1. Then I am just wondering, isn’t it allowed to give a fully labeled dataset to random forest? Or perhaps any other reasons?

Thank you again for your help.

Regards,
Jinwei



On Fri 28. Feb 2020 at 17:45, Simon Giraudot <[hidden email]> wrote:

Dear Zhang,

Le 28/02/2020 à 08:00, Zhang Jinwei a écrit :

1. Could you please specify the format and content of your generated config file after classifier training?
As I said, the format is an ASCII file compressed in a GZ archive. Same as the GZ files provided by CGAL. They *are* binary files, the fact that you can open them with a text reader is probably a feature of your text reader which may be able to decompress GZ archives on the fly an display the content of the

2. Could you explain in detail how you generate such files, e.g. b9_cluster_config and b9_mesh_config?
They were generated using the `save_configuration()` method, there are no tricks or hidden formulas here. (The line in the demo I used to generate them: https://github.com/CGAL/cgal/blob/master/Polyhedron/demo/Polyhedron/Plugins/Classification/Item_classification_base.h#L182 )

3. As described in your example codes named example_generation_training, the output of the trained classifier is written in a .xml format, isn’t it?
You're talking about a different classifier (Sum of weighted features) which uses a different format. This is not related to the ETHZ Random Forest which uses the GZ format.

4. If so, how could I utilize the .xml as input for classification? Because the load_configuration function requires stream files.
XML files for Sum Of Weighted Features and GZ from ETHZ Random Forest are not compatible at all.

At this moment, I am stopped at this training and classifying step because of these confusions, even though I have my own training datasets. I really need your help and would appreciate for your explanation.

I'm doing my best to figure what's going on, but it's very complicated to help without seeing the actual code (not just 2 lines copied in a mail), the cmake output or the actual error. The screenshot of the breakpoint comes from a deep code in Boost and is not related to CGAL, the problem probably comes before that.

If you can provide more information I can investigate more.

Best,

Simon


Thank you very much! Looking forward to your reply!

Best regards,
Jinwei

On Mon 24. Feb 2020 at 16:58, Simon Giraudot <[hidden email]> wrote:

Dear Mr. Jinwei,

Le 21/02/2020 à 05:56, Zhang Jinwei a écrit :

For output configuration file I use:
std::ofstream fconfig(“classifier_config.gz”);
classifier.save_configuration(fconfig);
fconfig.close();
Note that on some OS (Windows for example), you need to specify the tag std::ios_base::binary so that the binary output is correctly written. That might be the source of your error here?

However, when I tried to produce and load my own configuration file by using save_ and load_configuration function, then I encountered  an exception errors which jumps to the boost serialization library file. I compared the file I produced with the file in your example, and I found your configuration file is ascii format while mine is binary format. So how did you generate the configuration file of the trained classifier?
You must be mistaken, the configuration files provided with CGAL are also binary (to be precise: they are compressed archives containing an ASCII file).

Another question: as shown in the examples, the cluster and mesh can also be classified by the package. But there is no example to show how to export them? In which format?
If you are talking about the configuration file, then it's no different from the point set case, the save_configuration + load_configuration should work all the same.
And how to export the results of cluster and mesh with the colors and labels?

If your clusters are defined on a CGAL::Point_set_3 (as is done in the example of the user manual), then you can just propagate the labels back to the inliers of each cluster and color them similarly to what is done in the point sets example.

For the mesh, if your are using a CGAL::Surface_mesh (as is done in the example of the user manual), then you can also generate a color for each face. The API is slightly different from Point_set: in Point_set, you need to define 3 properties of type unsigned char "r", "g" and "b", whereas for Surface_mesh, you need to define 1 face property of type CGAL::Color "v:color". Then, use CGAL::write_ply to save your mesh to the PLY format: https://doc.cgal.org/latest/Surface_mesh/group__PkgSurface__mesh.html#ga77bbb79d449c981895eedb6c3c23bd14

I hope this helps.

Best regards,

--  
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/

If you could give me help and suggestions, I would really appreciate it!

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei



On Wed 19. Feb 2020 at 16:27, Simon Giraudot <[hidden email]> wrote:

Hello,

Sorry you encountered trouble with CGAL Classification.

What version of CGAL are you using? Also, can you share a source code + the full error messages?

Best regards,


--  
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 18/02/2020 à 19:12, Zhang Jinwei a écrit :
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: CGAL classification

Dmitry Anisimov
Ok, good, then it is not a Kernel. Could you please tell me then on where it comes from in the Region Growing (RG) part? 
What I mean is which part of the RG causes the call of the Kernel function and hence the assertion.

Thanks,
Dmitry

-- 
Dmitry Anisimov, PhD
R&D Engineer
GeometryFactory - https://geometryfactory.com/

On 9 Mar 2020 at 10:57 +0100, Zhang Jinwei <[hidden email]>, wrote:
Hi Dmitry,

Thanks for your quick reply. I tried again following your tips, and unfortunately it still produced the same error. Perhaps due to other reasons?

Jinwei

On Mon 9. Mar 2020 at 17:34, Dmitry Anisimov <[hidden email]> wrote:
Hi Jinwei,

Try to change your Kernel to the inexact one:

If you simply copy pasted the example, then you are currently running it with the Exact_predicates_exact_constructions_kernel. 
Try to use the Exact_predicates_inexact_constructions_kernel or Simple_cartesian<double>. Do not forget to include it as
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

Cheers,
Dmitry

-- 
Dmitry Anisimov, PhD
R&D Engineer
GeometryFactory - https://geometryfactory.com/

On 9 Mar 2020 at 10:26 +0100, Zhang Jinwei <[hidden email]>, wrote:
Hello Simon,

Thanks for your reply last time. It was the problem of the data format.

Now I encountered another problem, when I trying to run the example code of region_growing_on_polygon_mesh.cpp in the shape detection package for mesh segmentation. 

Still, using the example dataset is fine, but I tried to input another test dataset myself, it turns to collapse. This time I just compared the .off format of the files, they have definitely the same. I have tried several different datasets, and had the same errors. So it seems to be bugs in the codes, isn’t it?

Please see the error information in the attachment. Thank you very much!

Look forward to your reply!

Best regards,
Jinwei Zhang

<IMG_7046.jpg>


On Mon 2. Mar 2020 at 17:12, Simon Giraudot <[hidden email]> wrote:

Hello Zhang,

As explained in the manual https://doc.cgal.org/latest/Classification/classCGAL_1_1Classification_1_1ETHZ_1_1Random__forest__classifier.html#a7c0b299cb5829f598f395bcc16df72fa the expected format for the ground truth range that you give to the train() function is, for each input point, the index of its expected label in the Label_set that you used.

Judging by the breakpoint you provided, the ground truth that you pass probably contains indices which exceed the Label_set number of labels (I'm mostly guessing as you don't provide any code/data for context).

Points with label value -1 are ignored, but there's no problem in giving a fully labeled dataset to the random forest.

Best regards,

--   
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 29/02/2020 à 09:03, Zhang Jinwei a écrit :
Dear Simon, 

Thanks for your kindly reply. After reading your demo codes, I have already fixed several errors due to the file format. Now the problem occurs at the training step, where the break point locates in node.hpp from the ETHZ random forest package. If I use the example training dataset, everything is ok. However, when use my own labeled point clouds, it encounter such errors. 

So may I ask whether there is a specific definition of the format of the training dataset? In my dataset, everything point has a label in terms of integer number, denoting different classes. In your example dataset, just part of points are labeled and others with default value -1. Then I am just wondering, isn’t it allowed to give a fully labeled dataset to random forest? Or perhaps any other reasons?

Thank you again for your help.

Regards,
Jinwei



On Fri 28. Feb 2020 at 17:45, Simon Giraudot <[hidden email]> wrote:

Dear Zhang,

Le 28/02/2020 à 08:00, Zhang Jinwei a écrit :

1. Could you please specify the format and content of your generated config file after classifier training?
As I said, the format is an ASCII file compressed in a GZ archive. Same as the GZ files provided by CGAL. They *are* binary files, the fact that you can open them with a text reader is probably a feature of your text reader which may be able to decompress GZ archives on the fly an display the content of the

2. Could you explain in detail how you generate such files, e.g. b9_cluster_config and b9_mesh_config?
They were generated using the `save_configuration()` method, there are no tricks or hidden formulas here. (The line in the demo I used to generate them: https://github.com/CGAL/cgal/blob/master/Polyhedron/demo/Polyhedron/Plugins/Classification/Item_classification_base.h#L182 )

3. As described in your example codes named example_generation_training, the output of the trained classifier is written in a .xml format, isn’t it?
You're talking about a different classifier (Sum of weighted features) which uses a different format. This is not related to the ETHZ Random Forest which uses the GZ format.

4. If so, how could I utilize the .xml as input for classification? Because the load_configuration function requires stream files.
XML files for Sum Of Weighted Features and GZ from ETHZ Random Forest are not compatible at all.

At this moment, I am stopped at this training and classifying step because of these confusions, even though I have my own training datasets. I really need your help and would appreciate for your explanation.

I'm doing my best to figure what's going on, but it's very complicated to help without seeing the actual code (not just 2 lines copied in a mail), the cmake output or the actual error. The screenshot of the breakpoint comes from a deep code in Boost and is not related to CGAL, the problem probably comes before that.

If you can provide more information I can investigate more.

Best,

Simon


Thank you very much! Looking forward to your reply!

Best regards,
Jinwei

On Mon 24. Feb 2020 at 16:58, Simon Giraudot <[hidden email]> wrote:

Dear Mr. Jinwei,

Le 21/02/2020 à 05:56, Zhang Jinwei a écrit :

For output configuration file I use:
std::ofstream fconfig(“classifier_config.gz”);
classifier.save_configuration(fconfig);
fconfig.close();
Note that on some OS (Windows for example), you need to specify the tag std::ios_base::binary so that the binary output is correctly written. That might be the source of your error here?

However, when I tried to produce and load my own configuration file by using save_ and load_configuration function, then I encountered  an exception errors which jumps to the boost serialization library file. I compared the file I produced with the file in your example, and I found your configuration file is ascii format while mine is binary format. So how did you generate the configuration file of the trained classifier?
You must be mistaken, the configuration files provided with CGAL are also binary (to be precise: they are compressed archives containing an ASCII file).

Another question: as shown in the examples, the cluster and mesh can also be classified by the package. But there is no example to show how to export them? In which format?
If you are talking about the configuration file, then it's no different from the point set case, the save_configuration + load_configuration should work all the same.
And how to export the results of cluster and mesh with the colors and labels?

If your clusters are defined on a CGAL::Point_set_3 (as is done in the example of the user manual), then you can just propagate the labels back to the inliers of each cluster and color them similarly to what is done in the point sets example.

For the mesh, if your are using a CGAL::Surface_mesh (as is done in the example of the user manual), then you can also generate a color for each face. The API is slightly different from Point_set: in Point_set, you need to define 3 properties of type unsigned char "r", "g" and "b", whereas for Surface_mesh, you need to define 1 face property of type CGAL::Color "v:color". Then, use CGAL::write_ply to save your mesh to the PLY format: https://doc.cgal.org/latest/Surface_mesh/group__PkgSurface__mesh.html#ga77bbb79d449c981895eedb6c3c23bd14

I hope this helps.

Best regards,

--   
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/

If you could give me help and suggestions, I would really appreciate it!

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei



On Wed 19. Feb 2020 at 16:27, Simon Giraudot <[hidden email]> wrote:

Hello,

Sorry you encountered trouble with CGAL Classification.

What version of CGAL are you using? Also, can you share a source code + the full error messages?

Best regards,


--   
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 18/02/2020 à 19:12, Zhang Jinwei a écrit :
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: CGAL classification

Zhang Jinwei
It was stopped at the algorithm running step, which is region_growing.detect(std::back_inserter(regions)).

Jinwei

On Mon 9. Mar 2020 at 18:43, Dmitry Anisimov <[hidden email]> wrote:
Ok, good, then it is not a Kernel. Could you please tell me then on where it comes from in the Region Growing (RG) part? 
What I mean is which part of the RG causes the call of the Kernel function and hence the assertion.

Thanks,
Dmitry

-- 
Dmitry Anisimov, PhD
R&D Engineer
GeometryFactory - https://geometryfactory.com/

On 9 Mar 2020 at 10:57 +0100, Zhang Jinwei <[hidden email]>, wrote:
Hi Dmitry,

Thanks for your quick reply. I tried again following your tips, and unfortunately it still produced the same error. Perhaps due to other reasons?

Jinwei

On Mon 9. Mar 2020 at 17:34, Dmitry Anisimov <[hidden email]> wrote:
Hi Jinwei,

Try to change your Kernel to the inexact one:

If you simply copy pasted the example, then you are currently running it with the Exact_predicates_exact_constructions_kernel. 
Try to use the Exact_predicates_inexact_constructions_kernel or Simple_cartesian<double>. Do not forget to include it as
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

Cheers,
Dmitry

-- 
Dmitry Anisimov, PhD
R&D Engineer
GeometryFactory - https://geometryfactory.com/

On 9 Mar 2020 at 10:26 +0100, Zhang Jinwei <[hidden email]>, wrote:
Hello Simon,

Thanks for your reply last time. It was the problem of the data format.

Now I encountered another problem, when I trying to run the example code of region_growing_on_polygon_mesh.cpp in the shape detection package for mesh segmentation. 

Still, using the example dataset is fine, but I tried to input another test dataset myself, it turns to collapse. This time I just compared the .off format of the files, they have definitely the same. I have tried several different datasets, and had the same errors. So it seems to be bugs in the codes, isn’t it?

Please see the error information in the attachment. Thank you very much!

Look forward to your reply!

Best regards,
Jinwei Zhang

<IMG_7046.jpg>


On Mon 2. Mar 2020 at 17:12, Simon Giraudot <[hidden email]> wrote:

Hello Zhang,

As explained in the manual https://doc.cgal.org/latest/Classification/classCGAL_1_1Classification_1_1ETHZ_1_1Random__forest__classifier.html#a7c0b299cb5829f598f395bcc16df72fa the expected format for the ground truth range that you give to the train() function is, for each input point, the index of its expected label in the Label_set that you used.

Judging by the breakpoint you provided, the ground truth that you pass probably contains indices which exceed the Label_set number of labels (I'm mostly guessing as you don't provide any code/data for context).

Points with label value -1 are ignored, but there's no problem in giving a fully labeled dataset to the random forest.

Best regards,

--   
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 29/02/2020 à 09:03, Zhang Jinwei a écrit :
Dear Simon, 

Thanks for your kindly reply. After reading your demo codes, I have already fixed several errors due to the file format. Now the problem occurs at the training step, where the break point locates in node.hpp from the ETHZ random forest package. If I use the example training dataset, everything is ok. However, when use my own labeled point clouds, it encounter such errors. 

So may I ask whether there is a specific definition of the format of the training dataset? In my dataset, everything point has a label in terms of integer number, denoting different classes. In your example dataset, just part of points are labeled and others with default value -1. Then I am just wondering, isn’t it allowed to give a fully labeled dataset to random forest? Or perhaps any other reasons?

Thank you again for your help.

Regards,
Jinwei



On Fri 28. Feb 2020 at 17:45, Simon Giraudot <[hidden email]> wrote:

Dear Zhang,

Le 28/02/2020 à 08:00, Zhang Jinwei a écrit :

1. Could you please specify the format and content of your generated config file after classifier training?
As I said, the format is an ASCII file compressed in a GZ archive. Same as the GZ files provided by CGAL. They *are* binary files, the fact that you can open them with a text reader is probably a feature of your text reader which may be able to decompress GZ archives on the fly an display the content of the

2. Could you explain in detail how you generate such files, e.g. b9_cluster_config and b9_mesh_config?
They were generated using the `save_configuration()` method, there are no tricks or hidden formulas here. (The line in the demo I used to generate them: https://github.com/CGAL/cgal/blob/master/Polyhedron/demo/Polyhedron/Plugins/Classification/Item_classification_base.h#L182 )

3. As described in your example codes named example_generation_training, the output of the trained classifier is written in a .xml format, isn’t it?
You're talking about a different classifier (Sum of weighted features) which uses a different format. This is not related to the ETHZ Random Forest which uses the GZ format.

4. If so, how could I utilize the .xml as input for classification? Because the load_configuration function requires stream files.
XML files for Sum Of Weighted Features and GZ from ETHZ Random Forest are not compatible at all.

At this moment, I am stopped at this training and classifying step because of these confusions, even though I have my own training datasets. I really need your help and would appreciate for your explanation.

I'm doing my best to figure what's going on, but it's very complicated to help without seeing the actual code (not just 2 lines copied in a mail), the cmake output or the actual error. The screenshot of the breakpoint comes from a deep code in Boost and is not related to CGAL, the problem probably comes before that.

If you can provide more information I can investigate more.

Best,

Simon


Thank you very much! Looking forward to your reply!

Best regards,
Jinwei

On Mon 24. Feb 2020 at 16:58, Simon Giraudot <[hidden email]> wrote:

Dear Mr. Jinwei,

Le 21/02/2020 à 05:56, Zhang Jinwei a écrit :

For output configuration file I use:
std::ofstream fconfig(“classifier_config.gz”);
classifier.save_configuration(fconfig);
fconfig.close();
Note that on some OS (Windows for example), you need to specify the tag std::ios_base::binary so that the binary output is correctly written. That might be the source of your error here?

However, when I tried to produce and load my own configuration file by using save_ and load_configuration function, then I encountered  an exception errors which jumps to the boost serialization library file. I compared the file I produced with the file in your example, and I found your configuration file is ascii format while mine is binary format. So how did you generate the configuration file of the trained classifier?
You must be mistaken, the configuration files provided with CGAL are also binary (to be precise: they are compressed archives containing an ASCII file).

Another question: as shown in the examples, the cluster and mesh can also be classified by the package. But there is no example to show how to export them? In which format?
If you are talking about the configuration file, then it's no different from the point set case, the save_configuration + load_configuration should work all the same.
And how to export the results of cluster and mesh with the colors and labels?

If your clusters are defined on a CGAL::Point_set_3 (as is done in the example of the user manual), then you can just propagate the labels back to the inliers of each cluster and color them similarly to what is done in the point sets example.

For the mesh, if your are using a CGAL::Surface_mesh (as is done in the example of the user manual), then you can also generate a color for each face. The API is slightly different from Point_set: in Point_set, you need to define 3 properties of type unsigned char "r", "g" and "b", whereas for Surface_mesh, you need to define 1 face property of type CGAL::Color "v:color". Then, use CGAL::write_ply to save your mesh to the PLY format: https://doc.cgal.org/latest/Surface_mesh/group__PkgSurface__mesh.html#ga77bbb79d449c981895eedb6c3c23bd14

I hope this helps.

Best regards,

--   
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/

If you could give me help and suggestions, I would really appreciate it!

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei



On Wed 19. Feb 2020 at 16:27, Simon Giraudot <[hidden email]> wrote:

Hello,

Sorry you encountered trouble with CGAL Classification.

What version of CGAL are you using? Also, can you share a source code + the full error messages?

Best regards,


--   
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 18/02/2020 à 19:12, Zhang Jinwei a écrit :
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: CGAL classification

Dmitry Anisimov
Could you please submit an issue on the GitHub with the reproducible error? I then could have a look and see where the error comes from.

Cheers,
Dmitry

-- 
Dmitry Anisimov, PhD
R&D Engineer
GeometryFactory - https://geometryfactory.com/

On 9 Mar 2020 at 11:59 +0100, Zhang Jinwei <[hidden email]>, wrote:
It was stopped at the algorithm running step, which is region_growing.detect(std::back_inserter(regions)).

Jinwei

On Mon 9. Mar 2020 at 18:43, Dmitry Anisimov <[hidden email]> wrote:
Ok, good, then it is not a Kernel. Could you please tell me then on where it comes from in the Region Growing (RG) part? 
What I mean is which part of the RG causes the call of the Kernel function and hence the assertion.

Thanks,
Dmitry

-- 
Dmitry Anisimov, PhD
R&D Engineer
GeometryFactory - https://geometryfactory.com/

On 9 Mar 2020 at 10:57 +0100, Zhang Jinwei <[hidden email]>, wrote:
Hi Dmitry,

Thanks for your quick reply. I tried again following your tips, and unfortunately it still produced the same error. Perhaps due to other reasons?

Jinwei

On Mon 9. Mar 2020 at 17:34, Dmitry Anisimov <[hidden email]> wrote:
Hi Jinwei,

Try to change your Kernel to the inexact one:

If you simply copy pasted the example, then you are currently running it with the Exact_predicates_exact_constructions_kernel. 
Try to use the Exact_predicates_inexact_constructions_kernel or Simple_cartesian<double>. Do not forget to include it as
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

Cheers,
Dmitry

-- 
Dmitry Anisimov, PhD
R&D Engineer
GeometryFactory - https://geometryfactory.com/

On 9 Mar 2020 at 10:26 +0100, Zhang Jinwei <[hidden email]>, wrote:
Hello Simon,

Thanks for your reply last time. It was the problem of the data format.

Now I encountered another problem, when I trying to run the example code of region_growing_on_polygon_mesh.cpp in the shape detection package for mesh segmentation. 

Still, using the example dataset is fine, but I tried to input another test dataset myself, it turns to collapse. This time I just compared the .off format of the files, they have definitely the same. I have tried several different datasets, and had the same errors. So it seems to be bugs in the codes, isn’t it?

Please see the error information in the attachment. Thank you very much!

Look forward to your reply!

Best regards,
Jinwei Zhang

<IMG_7046.jpg>


On Mon 2. Mar 2020 at 17:12, Simon Giraudot <[hidden email]> wrote:

Hello Zhang,

As explained in the manual https://doc.cgal.org/latest/Classification/classCGAL_1_1Classification_1_1ETHZ_1_1Random__forest__classifier.html#a7c0b299cb5829f598f395bcc16df72fa the expected format for the ground truth range that you give to the train() function is, for each input point, the index of its expected label in the Label_set that you used.

Judging by the breakpoint you provided, the ground truth that you pass probably contains indices which exceed the Label_set number of labels (I'm mostly guessing as you don't provide any code/data for context).

Points with label value -1 are ignored, but there's no problem in giving a fully labeled dataset to the random forest.

Best regards,

--    
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 29/02/2020 à 09:03, Zhang Jinwei a écrit :
Dear Simon, 

Thanks for your kindly reply. After reading your demo codes, I have already fixed several errors due to the file format. Now the problem occurs at the training step, where the break point locates in node.hpp from the ETHZ random forest package. If I use the example training dataset, everything is ok. However, when use my own labeled point clouds, it encounter such errors. 

So may I ask whether there is a specific definition of the format of the training dataset? In my dataset, everything point has a label in terms of integer number, denoting different classes. In your example dataset, just part of points are labeled and others with default value -1. Then I am just wondering, isn’t it allowed to give a fully labeled dataset to random forest? Or perhaps any other reasons?

Thank you again for your help.

Regards,
Jinwei



On Fri 28. Feb 2020 at 17:45, Simon Giraudot <[hidden email]> wrote:

Dear Zhang,

Le 28/02/2020 à 08:00, Zhang Jinwei a écrit :

1. Could you please specify the format and content of your generated config file after classifier training?
As I said, the format is an ASCII file compressed in a GZ archive. Same as the GZ files provided by CGAL. They *are* binary files, the fact that you can open them with a text reader is probably a feature of your text reader which may be able to decompress GZ archives on the fly an display the content of the

2. Could you explain in detail how you generate such files, e.g. b9_cluster_config and b9_mesh_config?
They were generated using the `save_configuration()` method, there are no tricks or hidden formulas here. (The line in the demo I used to generate them: https://github.com/CGAL/cgal/blob/master/Polyhedron/demo/Polyhedron/Plugins/Classification/Item_classification_base.h#L182 )

3. As described in your example codes named example_generation_training, the output of the trained classifier is written in a .xml format, isn’t it?
You're talking about a different classifier (Sum of weighted features) which uses a different format. This is not related to the ETHZ Random Forest which uses the GZ format.

4. If so, how could I utilize the .xml as input for classification? Because the load_configuration function requires stream files.
XML files for Sum Of Weighted Features and GZ from ETHZ Random Forest are not compatible at all.

At this moment, I am stopped at this training and classifying step because of these confusions, even though I have my own training datasets. I really need your help and would appreciate for your explanation.

I'm doing my best to figure what's going on, but it's very complicated to help without seeing the actual code (not just 2 lines copied in a mail), the cmake output or the actual error. The screenshot of the breakpoint comes from a deep code in Boost and is not related to CGAL, the problem probably comes before that.

If you can provide more information I can investigate more.

Best,

Simon


Thank you very much! Looking forward to your reply!

Best regards,
Jinwei

On Mon 24. Feb 2020 at 16:58, Simon Giraudot <[hidden email]> wrote:

Dear Mr. Jinwei,

Le 21/02/2020 à 05:56, Zhang Jinwei a écrit :

For output configuration file I use:
std::ofstream fconfig(“classifier_config.gz”);
classifier.save_configuration(fconfig);
fconfig.close();
Note that on some OS (Windows for example), you need to specify the tag std::ios_base::binary so that the binary output is correctly written. That might be the source of your error here?

However, when I tried to produce and load my own configuration file by using save_ and load_configuration function, then I encountered  an exception errors which jumps to the boost serialization library file. I compared the file I produced with the file in your example, and I found your configuration file is ascii format while mine is binary format. So how did you generate the configuration file of the trained classifier?
You must be mistaken, the configuration files provided with CGAL are also binary (to be precise: they are compressed archives containing an ASCII file).

Another question: as shown in the examples, the cluster and mesh can also be classified by the package. But there is no example to show how to export them? In which format?
If you are talking about the configuration file, then it's no different from the point set case, the save_configuration + load_configuration should work all the same.
And how to export the results of cluster and mesh with the colors and labels?

If your clusters are defined on a CGAL::Point_set_3 (as is done in the example of the user manual), then you can just propagate the labels back to the inliers of each cluster and color them similarly to what is done in the point sets example.

For the mesh, if your are using a CGAL::Surface_mesh (as is done in the example of the user manual), then you can also generate a color for each face. The API is slightly different from Point_set: in Point_set, you need to define 3 properties of type unsigned char "r", "g" and "b", whereas for Surface_mesh, you need to define 1 face property of type CGAL::Color "v:color". Then, use CGAL::write_ply to save your mesh to the PLY format: https://doc.cgal.org/latest/Surface_mesh/group__PkgSurface__mesh.html#ga77bbb79d449c981895eedb6c3c23bd14

I hope this helps.

Best regards,

--    
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/

If you could give me help and suggestions, I would really appreciate it!

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei



On Wed 19. Feb 2020 at 16:27, Simon Giraudot <[hidden email]> wrote:

Hello,

Sorry you encountered trouble with CGAL Classification.

What version of CGAL are you using? Also, can you share a source code + the full error messages?

Best regards,


--    
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 18/02/2020 à 19:12, Zhang Jinwei a écrit :
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: CGAL classification

Zhang Jinwei
In reply to this post by Simon Giraudot-2
Hello Simon,

Sorry for disturbing you again. As described in the user manual of classification, the color information could also be possibly input for generating features based on point colors. Now I have some questions about this issue.

Since it is not clearly described in the document that the requirement of the format for the color information as parameters in the ”feature_generator” function, so may I ask for a more specific description or an example about it?

Normally, for example, the “r g b“ values are as unsigned char type in the .ply file. So, the colormap is input as vector or as “r” “g” “b” separately? Does it read the color information into colormap by property_map() in CGAL?  Is it different for reading color information from binary or ascii data file? The colormap has the same size as the point map or label map, right?

The questions sound perhaps stupid. But...now actually I am trying to get familiar with CGAL stuffs. Therefore, I would really appreciate for your kindly explanation.

Thank you very much!

Regards,
Jinwei Zhang


On Mon 2. Mar 2020 at 17:12, Simon Giraudot <[hidden email]> wrote:

Hello Zhang,

As explained in the manual https://doc.cgal.org/latest/Classification/classCGAL_1_1Classification_1_1ETHZ_1_1Random__forest__classifier.html#a7c0b299cb5829f598f395bcc16df72fa the expected format for the ground truth range that you give to the train() function is, for each input point, the index of its expected label in the Label_set that you used.

Judging by the breakpoint you provided, the ground truth that you pass probably contains indices which exceed the Label_set number of labels (I'm mostly guessing as you don't provide any code/data for context).

Points with label value -1 are ignored, but there's no problem in giving a fully labeled dataset to the random forest.

Best regards,

-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 29/02/2020 à 09:03, Zhang Jinwei a écrit :
Dear Simon, 

Thanks for your kindly reply. After reading your demo codes, I have already fixed several errors due to the file format. Now the problem occurs at the training step, where the break point locates in node.hpp from the ETHZ random forest package. If I use the example training dataset, everything is ok. However, when use my own labeled point clouds, it encounter such errors. 

So may I ask whether there is a specific definition of the format of the training dataset? In my dataset, everything point has a label in terms of integer number, denoting different classes. In your example dataset, just part of points are labeled and others with default value -1. Then I am just wondering, isn’t it allowed to give a fully labeled dataset to random forest? Or perhaps any other reasons?

Thank you again for your help.

Regards,
Jinwei



On Fri 28. Feb 2020 at 17:45, Simon Giraudot <[hidden email]> wrote:

Dear Zhang,

Le 28/02/2020 à 08:00, Zhang Jinwei a écrit :

1. Could you please specify the format and content of your generated config file after classifier training?
As I said, the format is an ASCII file compressed in a GZ archive. Same as the GZ files provided by CGAL. They *are* binary files, the fact that you can open them with a text reader is probably a feature of your text reader which may be able to decompress GZ archives on the fly an display the content of the

2. Could you explain in detail how you generate such files, e.g. b9_cluster_config and b9_mesh_config?
They were generated using the `save_configuration()` method, there are no tricks or hidden formulas here. (The line in the demo I used to generate them: https://github.com/CGAL/cgal/blob/master/Polyhedron/demo/Polyhedron/Plugins/Classification/Item_classification_base.h#L182 )

3. As described in your example codes named example_generation_training, the output of the trained classifier is written in a .xml format, isn’t it?
You're talking about a different classifier (Sum of weighted features) which uses a different format. This is not related to the ETHZ Random Forest which uses the GZ format.

4. If so, how could I utilize the .xml as input for classification? Because the load_configuration function requires stream files.
XML files for Sum Of Weighted Features and GZ from ETHZ Random Forest are not compatible at all.

At this moment, I am stopped at this training and classifying step because of these confusions, even though I have my own training datasets. I really need your help and would appreciate for your explanation.

I'm doing my best to figure what's going on, but it's very complicated to help without seeing the actual code (not just 2 lines copied in a mail), the cmake output or the actual error. The screenshot of the breakpoint comes from a deep code in Boost and is not related to CGAL, the problem probably comes before that.

If you can provide more information I can investigate more.

Best,

Simon


Thank you very much! Looking forward to your reply!

Best regards,
Jinwei

On Mon 24. Feb 2020 at 16:58, Simon Giraudot <[hidden email]> wrote:

Dear Mr. Jinwei,

Le 21/02/2020 à 05:56, Zhang Jinwei a écrit :

For output configuration file I use:
std::ofstream fconfig(“classifier_config.gz”);
classifier.save_configuration(fconfig);
fconfig.close();
Note that on some OS (Windows for example), you need to specify the tag std::ios_base::binary so that the binary output is correctly written. That might be the source of your error here?

However, when I tried to produce and load my own configuration file by using save_ and load_configuration function, then I encountered  an exception errors which jumps to the boost serialization library file. I compared the file I produced with the file in your example, and I found your configuration file is ascii format while mine is binary format. So how did you generate the configuration file of the trained classifier?
You must be mistaken, the configuration files provided with CGAL are also binary (to be precise: they are compressed archives containing an ASCII file).

Another question: as shown in the examples, the cluster and mesh can also be classified by the package. But there is no example to show how to export them? In which format?
If you are talking about the configuration file, then it's no different from the point set case, the save_configuration + load_configuration should work all the same.
And how to export the results of cluster and mesh with the colors and labels?

If your clusters are defined on a CGAL::Point_set_3 (as is done in the example of the user manual), then you can just propagate the labels back to the inliers of each cluster and color them similarly to what is done in the point sets example.

For the mesh, if your are using a CGAL::Surface_mesh (as is done in the example of the user manual), then you can also generate a color for each face. The API is slightly different from Point_set: in Point_set, you need to define 3 properties of type unsigned char "r", "g" and "b", whereas for Surface_mesh, you need to define 1 face property of type CGAL::Color "v:color". Then, use CGAL::write_ply to save your mesh to the PLY format: https://doc.cgal.org/latest/Surface_mesh/group__PkgSurface__mesh.html#ga77bbb79d449c981895eedb6c3c23bd14

I hope this helps.

Best regards,

-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/

If you could give me help and suggestions, I would really appreciate it!

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei



On Wed 19. Feb 2020 at 16:27, Simon Giraudot <[hidden email]> wrote:

Hello,

Sorry you encountered trouble with CGAL Classification.

What version of CGAL are you using? Also, can you share a source code + the full error messages?

Best regards,


-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 18/02/2020 à 19:12, Zhang Jinwei a écrit :
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang




Reply | Threaded
Open this post in threaded view
|

Re: Fwd: CGAL classification

Simon Giraudot-2

Hello,

The requirement of the format for the color information is quite clearly described as `CGAL::Color`:
https://doc.cgal.org/latest/Classification/classCGAL_1_1Classification_1_1Point__set__feature__generator.html#a009b60ebe0ea7b220f9cd7e237d3ed56

This means that you should provide a property map that associates each input point with a CGAL::Color object. If you are not comfortable with Property Maps, I suggest you start by reading https://doc.cgal.org/latest/Property_map/index.html

If your colors are stored in 3 different arrays, then you should write a property map that constructs a CGAL::Color on-the-fly from the 3 r g b values.

Best regards,

-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 11/03/2020 à 14:02, Zhang Jinwei a écrit :
Hello Simon,

Sorry for disturbing you again. As described in the user manual of classification, the color information could also be possibly input for generating features based on point colors. Now I have some questions about this issue.

Since it is not clearly described in the document that the requirement of the format for the color information as parameters in the ”feature_generator” function, so may I ask for a more specific description or an example about it?

Normally, for example, the “r g b“ values are as unsigned char type in the .ply file. So, the colormap is input as vector or as “r” “g” “b” separately? Does it read the color information into colormap by property_map() in CGAL?  Is it different for reading color information from binary or ascii data file? The colormap has the same size as the point map or label map, right?

The questions sound perhaps stupid. But...now actually I am trying to get familiar with CGAL stuffs. Therefore, I would really appreciate for your kindly explanation.

Thank you very much!

Regards,
Jinwei Zhang


On Mon 2. Mar 2020 at 17:12, Simon Giraudot <[hidden email]> wrote:

Hello Zhang,

As explained in the manual https://doc.cgal.org/latest/Classification/classCGAL_1_1Classification_1_1ETHZ_1_1Random__forest__classifier.html#a7c0b299cb5829f598f395bcc16df72fa the expected format for the ground truth range that you give to the train() function is, for each input point, the index of its expected label in the Label_set that you used.

Judging by the breakpoint you provided, the ground truth that you pass probably contains indices which exceed the Label_set number of labels (I'm mostly guessing as you don't provide any code/data for context).

Points with label value -1 are ignored, but there's no problem in giving a fully labeled dataset to the random forest.

Best regards,

-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 29/02/2020 à 09:03, Zhang Jinwei a écrit :
Dear Simon, 

Thanks for your kindly reply. After reading your demo codes, I have already fixed several errors due to the file format. Now the problem occurs at the training step, where the break point locates in node.hpp from the ETHZ random forest package. If I use the example training dataset, everything is ok. However, when use my own labeled point clouds, it encounter such errors. 

So may I ask whether there is a specific definition of the format of the training dataset? In my dataset, everything point has a label in terms of integer number, denoting different classes. In your example dataset, just part of points are labeled and others with default value -1. Then I am just wondering, isn’t it allowed to give a fully labeled dataset to random forest? Or perhaps any other reasons?

Thank you again for your help.

Regards,
Jinwei



On Fri 28. Feb 2020 at 17:45, Simon Giraudot <[hidden email]> wrote:

Dear Zhang,

Le 28/02/2020 à 08:00, Zhang Jinwei a écrit :

1. Could you please specify the format and content of your generated config file after classifier training?
As I said, the format is an ASCII file compressed in a GZ archive. Same as the GZ files provided by CGAL. They *are* binary files, the fact that you can open them with a text reader is probably a feature of your text reader which may be able to decompress GZ archives on the fly an display the content of the

2. Could you explain in detail how you generate such files, e.g. b9_cluster_config and b9_mesh_config?
They were generated using the `save_configuration()` method, there are no tricks or hidden formulas here. (The line in the demo I used to generate them: https://github.com/CGAL/cgal/blob/master/Polyhedron/demo/Polyhedron/Plugins/Classification/Item_classification_base.h#L182 )

3. As described in your example codes named example_generation_training, the output of the trained classifier is written in a .xml format, isn’t it?
You're talking about a different classifier (Sum of weighted features) which uses a different format. This is not related to the ETHZ Random Forest which uses the GZ format.

4. If so, how could I utilize the .xml as input for classification? Because the load_configuration function requires stream files.
XML files for Sum Of Weighted Features and GZ from ETHZ Random Forest are not compatible at all.

At this moment, I am stopped at this training and classifying step because of these confusions, even though I have my own training datasets. I really need your help and would appreciate for your explanation.

I'm doing my best to figure what's going on, but it's very complicated to help without seeing the actual code (not just 2 lines copied in a mail), the cmake output or the actual error. The screenshot of the breakpoint comes from a deep code in Boost and is not related to CGAL, the problem probably comes before that.

If you can provide more information I can investigate more.

Best,

Simon


Thank you very much! Looking forward to your reply!

Best regards,
Jinwei

On Mon 24. Feb 2020 at 16:58, Simon Giraudot <[hidden email]> wrote:

Dear Mr. Jinwei,

Le 21/02/2020 à 05:56, Zhang Jinwei a écrit :

For output configuration file I use:
std::ofstream fconfig(“classifier_config.gz”);
classifier.save_configuration(fconfig);
fconfig.close();
Note that on some OS (Windows for example), you need to specify the tag std::ios_base::binary so that the binary output is correctly written. That might be the source of your error here?

However, when I tried to produce and load my own configuration file by using save_ and load_configuration function, then I encountered  an exception errors which jumps to the boost serialization library file. I compared the file I produced with the file in your example, and I found your configuration file is ascii format while mine is binary format. So how did you generate the configuration file of the trained classifier?
You must be mistaken, the configuration files provided with CGAL are also binary (to be precise: they are compressed archives containing an ASCII file).

Another question: as shown in the examples, the cluster and mesh can also be classified by the package. But there is no example to show how to export them? In which format?
If you are talking about the configuration file, then it's no different from the point set case, the save_configuration + load_configuration should work all the same.
And how to export the results of cluster and mesh with the colors and labels?

If your clusters are defined on a CGAL::Point_set_3 (as is done in the example of the user manual), then you can just propagate the labels back to the inliers of each cluster and color them similarly to what is done in the point sets example.

For the mesh, if your are using a CGAL::Surface_mesh (as is done in the example of the user manual), then you can also generate a color for each face. The API is slightly different from Point_set: in Point_set, you need to define 3 properties of type unsigned char "r", "g" and "b", whereas for Surface_mesh, you need to define 1 face property of type CGAL::Color "v:color". Then, use CGAL::write_ply to save your mesh to the PLY format: https://doc.cgal.org/latest/Surface_mesh/group__PkgSurface__mesh.html#ga77bbb79d449c981895eedb6c3c23bd14

I hope this helps.

Best regards,

-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/

If you could give me help and suggestions, I would really appreciate it!

Thank you very much! Looking forward to your reply!

Best regards,
Jinwei



On Wed 19. Feb 2020 at 16:27, Simon Giraudot <[hidden email]> wrote:

Hello,

Sorry you encountered trouble with CGAL Classification.

What version of CGAL are you using? Also, can you share a source code + the full error messages?

Best regards,


-- 
Simon Giraudot, PhD
R&D Engineer
GeometryFactory - http://geometryfactory.com/
Le 18/02/2020 à 19:12, Zhang Jinwei a écrit :
Dear Ms./Mr.,

Thank you for providing us this CGAL open source library. I am a research engineer working in the field of urban reconstruction.

I faced a problem, when I used the package Classification for point cloud and mesh classification. I want to train the classifier, and then classify the point cloud data by the trained classifier. 

So, firstly I used the example training dataset training_b9.ply, for training step by using ETHZ random forest, and save the configuration by function save_configuration as .gz file. And secondly, I load the produced configuration from last step using load_configuration, and classify the data by this trained classifier. 

However,  when I saved and loaded the configuration of classifier, it came out an unhandeled exception: boost::archive::archive_exception. I just used the example data file training_b9.ply for the whole procedure. 

So could you explain me what the reason is? And could you please help me and give me suggestions on how to solve it? What do I need to notice when I doing training and classification using configuration file? It would be better if you could provide me more examples in detail. 

Thank you very much for your support! Looking forward to your kindly reply!

Best regards,
Jinwei Zhang