From d7808a60c593531df2cca7758f2bd00c47326781 Mon Sep 17 00:00:00 2001 From: Graham Knapp <32717635+dancergraham@users.noreply.github.com> Date: Sat, 19 Oct 2024 21:55:07 +0200 Subject: [PATCH 01/12] Fix intensity values for files with and without RGB Fixes #20 Update tests to verify the correctness of intensity values for files with and without RGB. * **test_read_intensity**: Add assertions to check the range of intensity values. * **test_no_rgb_intensity**: Add a new test function to verify that files without RGB do not return intensity values. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/dancergraham/e57-python/issues/20?shareId=XXXX-XXXX-XXXX-XXXX). --- tests/test_e57.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_e57.py b/tests/test_e57.py index f34568c..f5598de 100644 --- a/tests/test_e57.py +++ b/tests/test_e57.py @@ -34,6 +34,15 @@ def test_read_intensity(): intensity = pointcloud.intensity assert isinstance(intensity, np.ndarray) assert len(intensity) == 1_220 + assert np.all(intensity >= 0.3935) + assert np.all(intensity <= 0.5555) + + +def test_no_rgb_intensity(): + pointcloud = e57.read_points(r"testdata/bunnyFloat.e57") + intensity = pointcloud.intensity + assert isinstance(intensity, np.ndarray) + assert len(intensity) == 0 def test_box_dimensions(): From ddd6f18fb27129fb2534bf1366b5f6168aa16af1 Mon Sep 17 00:00:00 2001 From: Graham Knapp <32717635+dancergraham@users.noreply.github.com> Date: Sun, 20 Oct 2024 19:02:25 +0200 Subject: [PATCH 02/12] rescale intensities to the "real" values from scale 0 to 1 (cherry picked from commit fd90816c3fa83ee01afb02b7bbccec98a42f0193) --- src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e234319..b5fd198 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,6 +52,8 @@ unsafe fn read_points(py: Python<'_>, filepath: &str) -> PyResult { let mut color_vec = Vec::with_capacity(pc.records as usize * 3); let mut intensity_vec = Vec::with_capacity(pc.records as usize); let mut nrows = 0; + let intensity_min = pc.intensity_limits.map(|limits| limits.min).unwrap_or(0.0); + let intensity_max = pc.intensity_limits.map(|limits| limits.max).unwrap_or(1.0); for pointcloud in file.pointclouds() { let mut iter = file .pointcloud_simple(&pointcloud) @@ -67,14 +69,12 @@ unsafe fn read_points(py: Python<'_>, filepath: &str) -> PyResult { point_vec.extend([x, y, z]); nrows += 1 } - // if let Some(intensity) = p.intensity{ - // vec.append(intensity as f64) - // } if let Some(color) = p.color { color_vec.extend([color.red, color.green, color.blue]) } if let Some(intensity) = p.intensity { - intensity_vec.push(intensity) + let rescaled_intensity = (intensity * (intensity_max - intensity_min)) + intensity_min; + intensity_vec.push(rescaled_intensity) } } } From c52f39b2aef3c92566a2204ea89f7b9ba73e7110 Mon Sep 17 00:00:00 2001 From: dancergraham Date: Thu, 24 Oct 2024 21:36:53 +0200 Subject: [PATCH 03/12] feature: read unnormalised intensity values --- Cargo.toml | 2 +- src/lib.rs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8714fda..c248663 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,6 @@ crate-type = ["cdylib"] [dependencies] pyo3 = "0.20.3" -e57 = { version = "0.10.5",features =["crc32c"]} +e57 = { version = "0.11.7",features =["crc32c"]} numpy = "0.20.0" ndarray = "0.15.6" diff --git a/src/lib.rs b/src/lib.rs index b5fd198..dff0cc0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,8 +52,6 @@ unsafe fn read_points(py: Python<'_>, filepath: &str) -> PyResult { let mut color_vec = Vec::with_capacity(pc.records as usize * 3); let mut intensity_vec = Vec::with_capacity(pc.records as usize); let mut nrows = 0; - let intensity_min = pc.intensity_limits.map(|limits| limits.min).unwrap_or(0.0); - let intensity_max = pc.intensity_limits.map(|limits| limits.max).unwrap_or(1.0); for pointcloud in file.pointclouds() { let mut iter = file .pointcloud_simple(&pointcloud) @@ -61,6 +59,7 @@ unsafe fn read_points(py: Python<'_>, filepath: &str) -> PyResult { iter.spherical_to_cartesian(true); iter.cartesian_to_spherical(false); iter.intensity_to_color(true); + iter.normalize_intensity(false); iter.apply_pose(true); for p in iter { @@ -73,8 +72,7 @@ unsafe fn read_points(py: Python<'_>, filepath: &str) -> PyResult { color_vec.extend([color.red, color.green, color.blue]) } if let Some(intensity) = p.intensity { - let rescaled_intensity = (intensity * (intensity_max - intensity_min)) + intensity_min; - intensity_vec.push(rescaled_intensity) + intensity_vec.push(intensity) } } } From af69aea3d892093662518e8f5aa1fb80fd931696 Mon Sep 17 00:00:00 2001 From: dancergraham Date: Thu, 24 Oct 2024 21:59:38 +0200 Subject: [PATCH 04/12] deps: update dependencies --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c248663..570b2d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ name = "e57" crate-type = ["cdylib"] [dependencies] -pyo3 = "0.20.3" +pyo3 = "0.21.2" e57 = { version = "0.11.7",features =["crc32c"]} -numpy = "0.20.0" +numpy = "0.21.0" ndarray = "0.15.6" From 9043a5e076adfe20619069102b1316a17d9c45df Mon Sep 17 00:00:00 2001 From: dancergraham Date: Thu, 24 Oct 2024 22:00:02 +0200 Subject: [PATCH 05/12] docs: minor updates to contributing guidelines --- CONTRIBUTING.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9a3de0c..838762a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,8 +1,8 @@ -# How to contribute +### How to contribute All contributions welcome -- Ideas, feature requests 💡 -- bug reports 🪲 +- [Ideas, feature requests](https://github.com/dancergraham/e57-python/issues) 💡 +- [bug reports](https://github.com/dancergraham/e57-python/issues) 🪲 - documentation 📃 - sample files 🌫️ - tests @@ -10,9 +10,7 @@ All contributions welcome - python code 🐍 - tell your friends, share the project online / via social media, ... 🗣️ -## Best practice - -If you know how, you should fork the repo, create a new branch and then submit a pull request. +Fork the repo, create a new branch and then submit a pull request. (If you are new to GitHub, you might start with a basic tutorial and check out a more detailed guide to pull requests.) From fb69b4df24abe401ea7e7079b032a1e6a3b535f6 Mon Sep 17 00:00:00 2001 From: dancergraham Date: Thu, 24 Oct 2024 22:01:27 +0200 Subject: [PATCH 06/12] release: bump version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 570b2d5..3d0b928 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "e57-python" -version = "0.1.0-a8" +version = "0.2.0-a0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 6c74f431e90b3433b8b41a466cdafa788edc6ff3 Mon Sep 17 00:00:00 2001 From: dancergraham Date: Thu, 24 Oct 2024 22:13:29 +0200 Subject: [PATCH 07/12] fix: revert previous attempts at a fix --- src/lib.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3723d4f..d882385 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,8 +52,6 @@ unsafe fn read_points(py: Python<'_>, filepath: &str) -> PyResult { let mut color_vec = Vec::with_capacity(pc.records as usize * 3); let mut intensity_vec = Vec::with_capacity(pc.records as usize); let mut nrows = 0; - let intensity_min = pc.intensity_limits.map(|limits| limits.min).unwrap_or(0.0); - let intensity_max = pc.intensity_limits.map(|limits| limits.max).unwrap_or(1.0); for pointcloud in file.pointclouds() { let mut iter = file .pointcloud_simple(&pointcloud) @@ -74,8 +72,7 @@ unsafe fn read_points(py: Python<'_>, filepath: &str) -> PyResult { color_vec.extend([color.red, color.green, color.blue]) } if let Some(intensity) = p.intensity { - let rescaled_intensity = (intensity * (intensity_max - intensity_min)) + intensity_min; - intensity_vec.push(rescaled_intensity) + intensity_vec.push(intensity); } } } From 2346d0e963bc0441bca0ba0143dc8decb91b51fa Mon Sep 17 00:00:00 2001 From: dancergraham Date: Fri, 25 Oct 2024 21:28:38 +0200 Subject: [PATCH 08/12] ci: update actions runners out of desperation --- .github/workflows/CI.yml | Bin 8476 -> 8476 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a22fff539b7d6618a570733527f2320fb6592caa..f6a9606055447fad1e4550c0b2066ff3cea9c24f 100644 GIT binary patch delta 194 zcmbQ^G{)R~Azk&&*Zu1Ah7{X?=!PMF?O`ajO0Bk1E*2!{WJe$*` XvlyW^dTb7modx4)fZY`(e~1wP()U5z delta 187 zcmbQ^G{$| From 32cb96086bc71051da086e04acedebff5132a4c4 Mon Sep 17 00:00:00 2001 From: dancergraham Date: Sat, 26 Oct 2024 08:20:53 +0200 Subject: [PATCH 09/12] ci: update actions runners to latest maturin version --- .github/workflows/CI.yml | Bin 8476 -> 15256 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f6a9606055447fad1e4550c0b2066ff3cea9c24f..df849c4814784847b299e9bdbf7acb320dfd2f44 100644 GIT binary patch literal 15256 zcmeI3eQz5@5XSd!B))^&q8bp6X+v9xghW9IAq0&|BZLr&oWyNH65HgQCW!LYf#3R}a(DYOJ3I5t%p8Ndn&Qx{?hlce{!lf2P)BW&)prj<{s$tnS0;8=dAsq-kiFT>RJ6ybbq2J zgGrfCvZd$MHuK&)ZdbjvMAd<)*;hL|y6fl~i6-bP^lfeOJy5U5db*)f-?;Dn8=epK zX2ajn>qzYsYOQ?2(;YwNfqLBc?WS)j(a{GkFn(I)S-8SG=z)9j`?2agQ;+p6w%y0B z{jxl?9qHOu8-4eu?re-@-7}5m#2sn|kM!?MCHF*8p;5tcsJF6EF!Hn<`}c*u;X_Qv zu73i>1J&gXv(;Bid!8cN_(NrOl3GWe1E=mh8 z^{L98h@)%zMnX*PTJ9fRG5_FckjH15_mUTZ`zD*#e)TP-@;>WJQIeU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a6_CM{zhba6XS>AK;& zv={ob(2YG~qFdG*!}{a9vnLv?A$ZOX(7WT$lq2rcX7&VK=66y13u&Lt`;m2hrdk^2 zjgl)bCZ4O@R;~Psm0z)(+^Sf+uZK@D&zi(M`{_+<5w?0d&${R0);z;{E-^aD$g0!z z%vTB+Uudm?9DVY@!!r=Cy4Db9y);MY%dr=64q}YK_2PL}kQeQNol_Ma#LOhE#=%DN+O^o6c8hipyt zEJJgw9pNypmNNA$S1;_4HJ`$%%i&|cjx$we&wmqtz&Nslps>0x%hNR0wQ|AJ=dPU5 z-xF+^b@nId>n*jhrB=u?B`b~=55yhLc#)aQ^K{NlgW^o*YIgjAM%nT0m6>>FYR6Wj zVrhVmk_Ixejfz-1UWJ0XvrQMHAU};(9XC(Lx@-@N|8~YIA76bblY)AhE`#v4u04=+ zT`V&_$GPt`E<2ND`^&FBe&%=@62|=L__J1a0)xF>@6Uw}G5;jY+;qSC@o($tBlm;*R!`%6 zTo8w~8}eieW%rilA6Du$=jeit)6WG}J%kupa!m~*%6$a(*U9GquPs|CSaW34{D?x? Y39LkMF5uit19&hHmZm3(f@IP6|D+&qR{#J2 delta 545 zcmbPHKF4W71gi;y9)rQgSV^YI^Gwtx?_qM8yg*1mJDQ<_!GghzAs&cL7<3pEpnMQ3 z5eSPIk{L3y!W zOwwav3=1qM2m?rZn>P==* z(t!Cy7~~UFKVWgOAhYD;1XY&FpOp20CVm2$x_N_c2_uqo&4A7jntV@v0S@Qdu;&89 zC7B_AGQW~6%yvc0a3nSKNOgzM<~qX;CaA+@COesQO`c{MF}clDZt^Zui^=n}Z6?1l px0r08t2TK9rvy-)05FUNCdXJBO`f3Qv)ReYj*(4^ftP`c0RYRlo<;xw From d14024e52f3127dd0e577787378807742791ea1c Mon Sep 17 00:00:00 2001 From: dancergraham Date: Sat, 26 Oct 2024 08:31:50 +0200 Subject: [PATCH 10/12] ci: remove failing platforms --- .github/workflows/CI.yml | Bin 15256 -> 14082 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index df849c4814784847b299e9bdbf7acb320dfd2f44..a551c3796e4dc9eb3622ca84eba968a6b099814a 100644 GIT binary patch delta 17 ZcmbPH-juhYjCJ!T)+a)nKgg_*0{~4s2v7h3 delta 260 zcmZq5n^C@@jFq#P!I;64!GNJ+vLJKu<}%hNLX!o!iYAHk$)+%*Fyt{LG9)qR16lbD z$qd;HsSHI7x^6hVJKk81nLCxCp)sJisl3P zB|wpUpja_jjV?pkmXri5$cBQ+ Date: Sat, 26 Oct 2024 08:38:12 +0200 Subject: [PATCH 11/12] ci: remove failing platforms --- .github/workflows/CI.yml | Bin 14082 -> 13706 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a551c3796e4dc9eb3622ca84eba968a6b099814a..775082cd9f6a54031dd13359fbd10976b6f07a2e 100644 GIT binary patch delta 41 mcmZq5>&o6Rg=MmovCZTav4LlHwRLm7klWI^U)-U5aKhGYga1`~!HhSbe_WuzG=Cor;1 kj^pOpyiRQnV!Z From c32326b47a6e3bfeb304059d0b61bfb38577fb96 Mon Sep 17 00:00:00 2001 From: dancergraham Date: Sat, 26 Oct 2024 09:09:43 +0200 Subject: [PATCH 12/12] release: bump version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3d0b928..bbb3e7c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "e57-python" -version = "0.2.0-a0" +version = "0.2.0-a1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html