Sensor Data
Sensor Data from Smarter AI Camera
Smarter AI camera with sensors can provide different sensor information.
Smarter AI camera platform currently supports the following types of sensor information from camera.
Geo Location
Live GPS location of camera. Suggested uses are for tracking dashcams.Temperature
Temperature of the environment.Humidity
Humidity of the environment.Pressure
Pressure of the environment.
To fetch sensor data, follow the steps below:
Android
- Implement
Access.SensorSamplesListenerand register it usingRegisterSensorSamplesListener(SensorSamplesListener listener)method ofAccessclass. This is required to be registered only once.AnyConnectApi.get().getAccess().RegisterSensorSamplesListener(listener);
- Call
getSensorSamples(String endpointId, int pageSize, String sensorReportType, String continuationToken, String fromDate, String toDate)of Access.
You may call this as many times you want to get sensor data of any time slot.AnyConnectApi.get().getAccess().getSensorSamples(endpointId, pageSize, sensorReportType, continuationToken, fromDate, toDate);void getSensorSamples(String endpointId, int pageSize, String sensorReportType, String continuationToken, String fromDate, String toDate) { // endpointId, endpointId of the streaming camera // pageSize, an amount of data that can be fetched at a single call (10-100) // sensorReportType, a string that indicates the sensor type to fetch data. Check the link in the description for supported sensor types. // continuationToken, non-null string if there is any remaining data at the interval of fromDate and toDate, null otherwise // fromDate, string representation of time milliseconds of starting time of the data window // toDate, string representation of time milliseconds of end time of the data window }Check supported sensor types here
- You will get the response of sensor data to the
onReceiveSensorSamples(int apiStatus, String endpointId, String sensorReportType, Access.SensorReportsResponse sensorSamples)callback method.listener = new Access.SensorSamplesListener() { @Override public void onReceiveSensorSamples(int apiStatus, String endpointId, String sensorReportType, Access.SensorReportsResponse sensorSamples) { // apiStatus, 0 for successful response // sensorReportType, report type of sensor data as per Given in SensorType enum // sensorSamples, response that holds sensor data } };
iOS
- Call
getSensorSamplesmethod ofAccessclass.AccessRet getSensorSamples(const Endpoint endpointId, int32_t pageSize, std::string sensorReportType, std::string continuationToken, std::string fromDate, std::string toDate, SensorSampleCallback callback ); // endpointId, endpointId of the streaming camera // pageSize, an amount of data that can be fetched at a single call (10-100) // sensorReportType, a string that indicates the sensor type to fetch data. Check the link in the description for supported sensor types. // continuationToken, non-null string if there is any remaining data at the interval of fromDate and toDate, null otherwise // fromDate, string representation of time in milliseconds of starting time of the data block // toDate, string representation of time in milliseconds of end time of the data blockYou need to call this method as many times you want to get sensor data of any time slot.
- You will get the response of sensor data through the
SensorSampleCallbackcallback method.Declaration of
SensorSampleCallbackis:typedef std::function<void(const int apiStatus, const std::shared_ptr<types::SensorReportsResponse> sensorSampleList)> SensorSampleCallback;Sample code example is:
retValue = access->getSensorSamples(endpointID, pageSize, senType, contToken, fromDate, toDate, [=](const int apiStatus, const std::shared_ptr<types::SensorReportsResponse> sensorSampleList) { if(apiStatus==OK) { NSString *continueToken = [NSString stringWithUTF8String:sensorSampleList->getContinuationToken().c_str()]; std::vector<std::shared_ptr<types::SensorSample>> samplesVector = sensorSampleList->getData(); NSMutableArray *dataArray = [NSMutableArray arrayWithCapacity:samplesVector.size()]; for(int i=0 ;i<samplesVector.size(); i++) { std::shared_ptr<types::SensorSample> sample= samplesVector[i]; NSString *dataStr = [NSString stringWithUTF8String:sample->getSensorData().c_str()]; [dataArray addObject:dataStr]; } } });
Updated about 1 month ago