Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default alpha value to 255 #1385

Conversation

stefanbuettner
Copy link
Contributor

Hey there,
this is my suggestion to issue #1141. Some tests are failing compared to the master branch these commits are based on:

  • PCL.GroundBasedPeopleDetectionApp
  • PCL.CopyIfFieldExists
  • PCL.PLYPolygonMeshColoredIO (SegFault)

At first I looked at CopyIfFieldExists where the expected value has to change. But the value I was expecting based on my calculations still was not the result of the test. For the other two, I don't have any idea. So perhaps you guys do.

Cheers,
Stefan

@taketwo
Copy link
Member

taketwo commented Oct 18, 2015

In the unit test, CopyIfFieldExists functor is instantiated with the assumption that "rgb" field has type float:

CopyIfFieldExists<PointXYZRGBNormal, float> (p, "rgb", is_rgb, rgb_val)

Then when the functor is applied in the for_each_type loop, the following operation is carried out (lines 261 through 267):

if (name_ == pcl::traits::name<PointInT, Key>::value)
{
  exists_ = true;
  typedef typename pcl::traits::datatype<PointInT, Key>::type T;
  const uint8_t* data_ptr = reinterpret_cast<const uint8_t*>(&pt_) + pcl::traits::offset<PointInT, Key>::value;
  value_ = static_cast<OutT> (*reinterpret_cast<const T*>(data_ptr));
}

Here OutT is float and T is uint32_t (after your change). Therefore *reinterpret_cast<const T*>(data_ptr) is an unsigned integer, which is then cast to float using normal casting rules (instead of reinterpretation), which produces nonsense results. Note that before your change both types were float and therefore this worked as expected.

I think we can not apply your change, because it may affect existing user code the same way it affects unit tests. Your "second option" proposed in the previous discussion was only about changing IO functions, guess we should go that way.

@VictorLamoine
Copy link
Contributor

There are still some tests failing, can you fix them?

12: /home/travis/build/PointCloudLibrary/pcl/test/common/test_common.cpp:416: Failure
12: Value of: 0xffef40fe
12:   Actual: 4293869822

12: Expected: rgb
12: Which is: -8437506

12: [  FAILED  ] 1 test, listed below:
12: [  FAILED  ] PCL.CopyIfFieldExists
12:  1 FAILED TEST
 12/101 Test  #12: common_common ..........................***Failed    0.01 sec
test 13
        Start  13: common_copy_point

#1040 should be fixed after this pull request is merged.

@VictorLamoine
Copy link
Contributor

We're good, aren't we?

@stefanbuettner
Copy link
Contributor Author

I didn't manage to check what is failing in the test Hough3DGrouping but if it's not related to the error, we're good.

@SergioRAgostinho
Copy link
Member

It shouldn't be. That test is failing for the majority (if not all) of the (current) PRs.

@SergioRAgostinho
Copy link
Member

Squash?

@VictorLamoine
Copy link
Contributor

I think we are good to merge this one and close #1141.

* Vary alpha values in PCDReaderWriterASCIIColorPrecision test
* Save RGB as integer all point types
* Change default alpha value to 255.
* Adjust tests to new alpha values
* Print rgb values as ints in streaming operators
* Allow rgb fields to be of type uint32 and rgba fields to be of type float
@SergioRAgostinho SergioRAgostinho added this to the pcl-1.8.1 milestone Jul 14, 2016
@SergioRAgostinho SergioRAgostinho merged commit 6dc3e08 into PointCloudLibrary:master Aug 18, 2016
@stefanbuettner stefanbuettner deleted the issue#1141-setAlpha255 branch October 19, 2016 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants