Coder Social home page Coder Social logo

Comments (2)

hmaarrfk avatar hmaarrfk commented on July 21, 2024

Ok I know exactly what is wrong now.

The code is ok in theory, but there is a synchronisation problem that arises when closing the kinect.

You must remember that there are technically 2 threads running, one processing events from the kinect, and the other running glut.
Upon close, we join the threads, but there are still some interrupt driven functions that are called when you get events from the kinect.

The bug is something specific to cpp.

We start destroying the device, when this happens, the virtual functions become uncallable.
But there are still some frames that need to be processed by the callback functions.

The interrupt driven functions of the libfreenect call these virtual functions.
Since libfreenect does not use locks to synchronise data across multiple threads, I believe that it is impossible to fix this synchronisation problem.

I'm simply going to call stop video and depth before destroying the structures and wait a second.
This does not solve the synchronisation problem, for example if your computer is lagging and the usb traffic is heavily buffered.

But I think it should allow you to debug your code to see if it exists properly without having to worry about this bug...

from libfreenect.

hmaarrfk avatar hmaarrfk commented on July 21, 2024

Ok So here is an other fix, that I am pretty sure is only save 99.9999% of the time, and we all know how annoying that is:

in ~MyFreenectDevice
call
stopVideo()
stopDepth()

this decreases the chances of the video causing an interrupt before the struct is destroyed and its virtual functions are no longer callable.

In my code, I'm still going to add the 1 second delay, I i like to have code that doesn't cause errors at random moments ....

from libfreenect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.