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

failed to run pcl_openni2_viewer with Kinect Xbox 360(OpenNI2 + libfreenect) #1348

Closed
ladevan opened this issue Sep 26, 2015 · 7 comments
Closed

Comments

@ladevan
Copy link

ladevan commented Sep 26, 2015

Hi,

I was trying to make my kinect for Xbox 360 to work with PCL 1.8. After ran pcl_openni2_viewer, it shows the following error:

OpenNI2-FreenectDriver: Using libfreenect v0.5.2
OpenNI2-FreenectDriver: Found device freenect://0
OpenNI2-FreenectDriver: Opening device freenect://0
[Stream 70] Negotiated packet size 1920
write_register: 0x0105 <= 0x00
write_register: 0x0006 <= 0x00
write_register: 0x0012 <= 0x03
write_register: 0x0013 <= 0x01
write_register: 0x0014 <= 0x1e
write_register: 0x0006 <= 0x02
write_register: 0x0017 <= 0x00
[Stream 80] Negotiated packet size 1920
write_register: 0x000c <= 0x00
write_register: 0x000d <= 0x01
write_register: 0x000e <= 0x1e
[Stream 70] Invalid magic fedf
[Stream 70] Invalid magic fb7f
[Stream 70] Invalid magic 94ff
[Stream 70] Invalid magic ffff
[Stream 70] Invalid magic 0901
[Stream 70] Lost 5 packets
[Stream 70] Lost 5 total packets in 4 frames (1.250000 lppf)
[Stream 70] Lost 3 packets
[Stream 70] Lost 8 total packets in 4 frames (2.000000 lppf)
[Stream 70] Inconsistent flag 75 with 238 packets in buf (242 total), resyncing...
write_register: 0x0005 <= 0x01
write_register: 0x0047 <= 0x00
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
Aborted (core dumped)

The gdb backtrace info is:

Program received signal SIGABRT, Aborted.
0x00007ffff3c2a267 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:55
55  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff3c2a267 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:55
#1  0x00007ffff3c2beca in __GI_abort () at abort.c:89
#2  0x00007ffff423606d in __gnu_cxx::__verbose_terminate_handler() ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff4233ee6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff4233f31 in std::terminate() ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff4234149 in __cxa_throw ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff428df71 in std::__throw_out_of_range_fmt(char const*, ...) ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007ffff749b37c in _M_range_check (__n=0, this=0x7fffffffd4d0)
    at /usr/include/c++/4.9/bits/stl_vector.h:803
#8  at (__n=0, this=0x7fffffffd4d0)
    at /usr/include/c++/4.9/bits/stl_vector.h:824
#9  pcl::io::openni2::OpenNI2Device::getDefaultIRMode (
    this=this@entry=0x6b70c0)
    at /home/xxxx/Downloads/pcl-master/io/src/openni2/openni2_device.cpp:545
#10 0x00007ffff749b8db in pcl::io::openni2::OpenNI2Device::OpenNI2Device (
    this=0x6b70c0, device_URI=...)
    at /home/xxxx/Downloads/pcl-master/io/src/openni2/openni2_device.cpp:94
#11 0x00007ffff74a1550 in boost::make_shared<pcl::io::openni2::OpenNI2Device, char [1]> (a1=...) at /usr/include/boost/smart_ptr/make_shared_object.hpp:711
#12 0x00007ffff74a0230 in pcl::io::openni2::OpenNI2DeviceManager::getAnyDevice
    (this=<optimized out>)
    at /home/xxxx/Downloads/pcl-master/io/src/openni2/openni2_device_manager.cpp:225
#13 0x0000000000422fba in main (argc=1, argv=0x7fffffffdd78)
    at /home/xxxx/Downloads/pcl-master/visualization/tools/openni2_viewer.cpp:340

Could anyone give suggestions on this?

Thanks,

P.S.: The working environment is Ubuntu 15.04, PCL 1.8, libfreenect, OpenNI2

@ladevan ladevan changed the title failed to run pcl_openni2_viewer with kinect failed to run pcl_openni2_viewer with Kinect Xbox 360(OpenNI2 + libfreenect) Sep 26, 2015
@taketwo
Copy link
Member

taketwo commented Sep 26, 2015

Looking at OpenNI2Device implementation, I'm pretty sure you crash on this line. I have no knowledge of the API though, so I have no clue what would be the meaning and the right way to treat a situation when there are no IR modes available...

@ladevan
Copy link
Author

ladevan commented Sep 26, 2015

Thanks, taketwo. Yes, I think the returned vector is null. However, the kinect works well with freenect_glview and OpenNI2's NiViewer. Also, the kinect should have an IR mode, right?

@taketwo
Copy link
Member

taketwo commented Sep 26, 2015

I guess so. The grabber "foresees" lack of IR stream though :D

@josuerocha
Copy link

Could anybody solve this problem? I am coming across the same. I am using Freenect + OpenNI2 + PCL. Kinect works greatly with freenect-glview and OpenNI2's NiViewer and other samples. However, with PCL it does not work, even the sample pcl_openni2_viewer it does not work. Please help.

@agrohn
Copy link
Contributor

agrohn commented Dec 12, 2017

Just stumbled upon to this issue myself. Quick and dirty way to get around it is to comment out setIRVideoMode call in openni2_device.cpp starting at line 90 ;

  if (!openni_device_->isFile ())
  {
    if (openni_device_->hasSensor (openni::SENSOR_COLOR))
    {
      setColorVideoMode (getDefaultColorMode ());
    }
    setDepthVideoMode (getDefaultDepthMode ());
    //setIRVideoMode (getDefaultIRMode ());
  }

However, producing similar hasSensor sanity check would probably be better alternative:

if (!openni_device_->isFile ())
  {
    if (openni_device_->hasSensor (openni::SENSOR_COLOR))
    {
      setColorVideoMode (getDefaultColorMode ());
    }
    if (openni_device_->hasSensor (openni::SENSOR_DEPTH))
    {
      setDepthVideoMode (getDefaultDepthMode ());
    } 
    if (openni_device_->hasSensor (openni::SENSOR_IR))
    {
       setIRVideoMode (getDefaultIRMode ());
    }
  }

I will try to give it a go shortly.

@SergioRAgostinho
Copy link
Member

👍 The proposal looks sane indeed. If it solves the problem please submit a PR.

agrohn added a commit to agrohn/pcl that referenced this issue Dec 13, 2017
agrohn added a commit to agrohn/pcl that referenced this issue Dec 15, 2017
SergioRAgostinho added a commit that referenced this issue Dec 15, 2017
fixed issue #1348 by adding device sensor check for IR and depth modesetting
@taketwo
Copy link
Member

taketwo commented Dec 15, 2017

A fix merged, reopen if still have problems.

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

No branches or pull requests

5 participants