added c++ code for tabletop detection