DFX Service

DFX Service

BASE-URL (unavailable currently) : http://test.xymind.cn/

1 Measure

creating a new measurement by a video stream.

this is generally provided by a common streaming media protocol,like RTSP/RTMP,etc.Make sure that streaming media can be accessed publicly with a good speed and quality.

1.1 Requirement

if the webcam is used, the measurement duration is automatically set to 30 seconds (~900 frames at 30 fps). The resolution is then set to the camera default.

propertyrequirement
FPS≥ 25 (fps)
Resolution≥ 640 x 480 (px)

1.2 Declaration

since it’s surely would take a pretty long time to measure a video stream,we cut every 5s as a chunk to do measure. it means clients would recicve results more than once(≥ 6 times). therefor,here we choose to keep long connections with clients by websocket(based on signalr.core).

clients would get chunk measurements every 150 effective frames and would get a summarization after process 900 effective frames.

1.3 Connection

signalr.core sdk is strongly recommended. it covers most of common platforms,such as Java/.Net/Python/JavaScript.If you have special custom needs,you definitely could use orginal websocket.

http://test.xymind.cn/measure
ws://test.xymind.cn/measure
plateformdemo
Java/Androidhttps://github.com/aspnet/SignalR-samples/tree/master/AndroidJavaClient
.Nethttps://github.com/aspnet/SignalR-samples/tree/master/ChatSample
JavaScripthttps://docs.microsoft.com/zh-cn/aspnet/core/signalr/javascript-client?view=aspnetcore-3.0
Pythonhttps://dev.to/mandrewcito/singlar-core-python-client-58e7

1.4 Interface

  • Server
      // test connection
      void Test()
    
      // create a measurement
      [Authorize]
      void Measure(string rtmp)
    
  • Client
      //callled by test connection
      void Test(string message)
    
      /*
      * called when errors occur
      * 
      * error example: {'code':400,'message':'something went wrongly'}
      */
      void ErrorHandler(string error)
    
      /*
      * called after every chunk measurement
      * measurement example: {"Chunk Number": 1, "Results": "Success", "SNR": 3.22, "HEART_RATE": 0.96, "HR_BPM": 57.36}
      */
      void ProcessChunkMeasurement(string measurement)
    
      /*
      * called after a whole measurement
      * measurement example: {"data": {"content": {"Id": "e12f0b5a-c3f1-4482-9b74-aaada3353ac0", "Results": {"HR_BPM": 64.1449, "SNR": 2.0117, "HEART_RATE": 1.069, "MENTAL_STRESS_INDEX": 2.6017}, "StatusID": "COMPLETE", "DataSizeBytes": 152136, "CreateTime": "2019-11-28 07:06:42"}, "message": null}, "statusCode": 200}
      */
      void ProcessMeasurement(string measurement)
    

1.5 Measurement

here are some instructions of the measurement in the table blew.

PropertyDescription
Ididentity for current measurement
StatusIdmeasurement status[1]
HR_BPMAverage heart rate in beats-per-minute (bpm). Measurable Range: 40-140bpm (0.67-2.33Hz)
SNRAverage blood flow signal SNR over the duration of the measurement
HEART_RATEAverage heart rate in Hz. Measurable Range: 40-140bpm (0.67-2.33Hz)
MENTAL_STRESS_INDEXAverage Mental Stress Index as determined by heart rate variability features. The range is [1.0 - 5.9], the higher the value, the greater the stress
Messageerror message if exists
DataSizeBytesdata size transited
CreateTimecreated time
  • [1] measurement with “MENTAL_STRESS_INDEX” will return “COMPLETE”,otherwise it will be “WARNING”
  • [2] getting “MENTAL_STRESS_INDEX” needs 30s at least

1.6 Stream Media

  • Push Stream
    • URL: rtmp://test.xymind.cn:1935/stream
    • Stream Key: GUID
  • Watch Stream
    • URL: rtmp://test.xymind.cn:1935/stream/GUID

2 Auth

authentication and authorization.

  • API docs can refer to the swagger docs.
  • the parameter named purpose of the API which is charge of sending verification code has 2 options.
      enum SmsPurpose
      {
          SignUp = 0,
          ResetPassword = 1
      }
    
  • the APIs below require authorization.

    URLMethodDescription
    /AuthPUTupdate user profile
    /Auth​/ResetPasswordPUTreset user password
    ​/Auth​/ChangePasswordPUTchange user password
  • we use JWT for authorization.you can call APIs with Bearer Token in header named Authorization.

3 Record

recording measurements and videos(if necessary) from clients.users can look back their measure history.

  • API docs can refer to the swagger docs
  • all APIs in this module require authorization.

  • the API which is in charge of backup a measurement video requires a video parameter from form-data.

4 Health

health check for current service.

All time fields involved in current service use UTC time.