1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge pull request #23805 from starga2er777:5.x

GSoC: Modified PLY reader to support color attribute read/write #23805

* Modified PLY reader to support color attribute read/write
* Fix bugs & Modified OBJ reader for color IO
* Replace with correct test file
* Fix I/O of property [w] in OBJ files

### Pull Request Readiness Checklist

**Merged with https://github.com/opencv/opencv_extra/pull/1075**

[Issue for GSoC 2023](https://github.com/opencv/opencv/issues/23624)
The ply loader in 3D module doesn't support color attribute reading. I modified that to support color attribute reading & writing for the color attribute compression as described in proposal.

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Zhangjie Chen
2023-07-25 21:05:56 +08:00
committed by GitHub
parent 18f280b869
commit 4d695cd2f4
9 changed files with 139 additions and 48 deletions
+26 -7
View File
@@ -22,6 +22,7 @@ TEST(PointCloud, LoadObj)
{0.399941f, 1.86743f, 2.55837f},
{0.399941f, -0.13257f, -1.16339f},
{0.399941f, 1.86743f, -1.16339f}};
std::vector<cv::Point3f> normals_gold = {
{-1.0000f, 0.0000f, 0.0000f},
{0.0000f, 0.0000f, -1.0000f},
@@ -30,13 +31,25 @@ TEST(PointCloud, LoadObj)
{0.0000f, -1.0000f, 0.0000f},
{0.0000f, 1.0000f, 0.0000f}};
std::vector<cv::Point3_<uchar>> rgb_gold = {
{19, 144, 149},
{219, 28, 216},
{218, 157, 101},
{11, 161, 78},
{248, 183, 214},
{63, 196, 6},
{165, 190, 153},
{89, 203, 11}};
std::vector<cv::Point3f> points;
std::vector<cv::Point3f> normals;
std::vector<cv::Point3_<uchar>> rgb;
auto folder = cvtest::TS::ptr()->get_data_path();
cv::loadPointCloud(folder + "pointcloudio/orig.obj", points, normals);
cv::loadPointCloud(folder + "pointcloudio/orig.obj", points, normals, rgb);
EXPECT_EQ(points_gold, points);
EXPECT_EQ(rgb_gold, rgb);
EXPECT_EQ(normals_gold, normals);
}
@@ -66,20 +79,23 @@ TEST(PointCloud, SaveObj)
{
std::vector<cv::Point3f> points_gold;
std::vector<cv::Point3f> normals_gold;
std::vector<cv::Point3_<uchar>> rgb_gold;
auto folder = cvtest::TS::ptr()->get_data_path();
auto new_path = tempfile("new.obj");
cv::loadPointCloud(folder + "pointcloudio/orig.obj", points_gold, normals_gold);
cv::savePointCloud(new_path, points_gold, normals_gold);
cv::loadPointCloud(folder + "pointcloudio/orig.obj", points_gold, normals_gold, rgb_gold);
cv::savePointCloud(new_path, points_gold, normals_gold, rgb_gold);
std::vector<cv::Point3f> points;
std::vector<cv::Point3f> normals;
std::vector<cv::Point3_<uchar>> rgb;
cv::loadPointCloud(new_path, points, normals);
cv::loadPointCloud(new_path, points, normals, rgb);
EXPECT_EQ(normals, normals_gold);
EXPECT_EQ(points, points_gold);
EXPECT_EQ(rgb, rgb_gold);
std::remove(new_path.c_str());
}
@@ -87,20 +103,23 @@ TEST(PointCloud, LoadSavePly)
{
std::vector<cv::Point3f> points;
std::vector<cv::Point3f> normals;
std::vector<cv::Point3_<uchar>> rgb;
auto folder = cvtest::TS::ptr()->get_data_path();
std::string new_path = tempfile("new.ply");
cv::loadPointCloud(folder + "pointcloudio/orig.ply", points, normals);
cv::savePointCloud(new_path, points, normals);
cv::loadPointCloud(folder + "pointcloudio/orig.ply", points, normals, rgb);
cv::savePointCloud(new_path, points, normals, rgb);
std::vector<cv::Point3f> points_gold;
std::vector<cv::Point3f> normals_gold;
std::vector<cv::Point3_<uchar>> rgb_gold;
cv::loadPointCloud(new_path, points_gold, normals_gold);
cv::loadPointCloud(new_path, points_gold, normals_gold, rgb_gold);
EXPECT_EQ(normals_gold, normals);
EXPECT_EQ(points_gold, points);
EXPECT_EQ(rgb_gold, rgb);
std::remove(new_path.c_str());
}