pupil-labs / pupil

Open source eye tracking
https://pupil-labs.com
GNU Lesser General Public License v3.0
1.47k stars 676 forks source link

Pupil Remote JSON Format with single quotes #708

Closed IoAg closed 7 years ago

IoAg commented 7 years ago

Hello,

The serialization library (msgpack) that is used to serialize the object created in pupil/pupil_src/capture/pupil_detectors/detector_utils.pxd creates names and strings surrounded by single quotes.

As can be seen in http://www.json.org/ the JSON standard uses double quotes.

As a result the syntax is fine for working in Python but is incompatible with other libraries that handle JSON.

papr commented 7 years ago

Dear @IoAg I think there is a misunderstanding here: msgpack is a completely different serialization format than JSON. They are not compatible with each other.

Please elaborate on the original issue if you were aware of the fact above and/or if I misunderstood you.

IoAg commented 7 years ago

Hello @papr,

The problem that I am facing is with the type of messages that I get from Pupil remote plugin in Pupil Capture.

The messages that I get with ZeroMQ and 'pupil' as filter have the following form:

{'method': '3d c++', 'timestamp': 77125.954477639, 'model_id': 1, 'diameter': 0.0, 'id': 0, 'model_birth_timestamp': 77117.731106317, 'theta': 0, 'model_confidence': 0.9999999999999898, 'diameter_3d': 0.0, 'topic': 'pupil', 'confidence': 0.0, 'sphere': {'center': [-168.70694075298337, -111.81069675697995, 443.18840646479043], 'radius': 12.0}, 'circle_3d': {'normal': [0.0, -0.0, 0.0], 'center': [0.0, -0.0, 0.0], 'radius': 0.0}, 'projected_sphere': {'angle': 90.0, 'center': [83.98682424658685, 83.58202746705882], 'axes': [33.57488549552606, 33.57488549552606]}, 'ellipse': {'angle': 90.0, 'center': [320.0, 240.0], 'axes': [0.0, 0.0]}, 'norm_pos': [0.5, 0.5], 'phi': 0}

This looks like JSON to me but with single quotes instead of double quotes. Was it supposed to be like this?

papr commented 7 years ago

@IoAg This looks like the string representation of a Python dictionary.

Could you describe your exact setup? Pupil Capture version, operating system, software that you use to deserialize pupil remote/subscription messages with?

IoAg commented 7 years ago

@papr

I am on Ubuntu, Capture v0.9.6 and I am trying to de-serialize in C++. It seams that this was not an error on your side but I thought a widely accepted standard (JSON) would be used for broadcasting messages and thus the misunderstanding.

papr commented 7 years ago

We have been using JSON before we switched to msgpack. I can recommend the usage of https://github.com/msgpack/msgpack-c for deserialization in c++.

As far as I know the hmd-eyes integration uses it as well: https://github.com/pupil-labs/hmd-eyes/blob/master/unity_integration/Assets/Scripts/PupilListener.cs

Please close the issue if it is resolved for you.