adding the cpp code (Tarek will send the stitching update soon)