xtravision_flutter_sdk

Creator: coderz1093

Last updated:

0 purchases

xtravision_flutter_sdk Image
xtravision_flutter_sdk Images
Add to Cart

Description:

xtravision flutter sdk

XtraVision Flutter Package #

A Flutter package for integrating Flutter App with XtraVision SaaS platform. xtravision_flutter_sdk provides an easy-to-use API for interacting with XtraVision SaaS platform's services, enabling seamless integration and streamlined user experiences.
Getting started #
Install: #
flutter pub add camera xtravision_flutter_sdk
copied to clipboard
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):
dependencies:
camera: ^0.10.4
xtravision_flutter_sdk: ^0.4.0
copied to clipboard
Import it: #
Now in your Dart code, you can use below code to import it:
import 'package:xtravision_flutter_sdk/xtravision_flutter_sdk.dart';
copied to clipboard
Integration with iOS #
Add one row to the ios/Runner/Info.plist:
Privacy - Camera Usage Description and a usage description.
If editing Info.plist as text, add:
<key>NSCameraUsageDescription</key>
<string>your usage description here</string>
copied to clipboard
Integration With Android #


Change the minimum Android sdk version to 21 (or higher) in your android/app/build.gradle file.
minSdkVersion 21
copied to clipboard


Add all required dependencies in the android/app/build.gradle file.
implementation "androidx.lifecycle:lifecycle-runtime:2.0.0"
implementation "androidx.lifecycle:lifecycle-extensions:2.0.0"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.0.0"
copied to clipboard


Integration with Codebase: #
Please refer below codebase for reference purpose.


In lib/main.dart, we get a list of cameras and select which are going to use (Either front or back). The selected camera will pass to the MyAssessmentView widget class.
import 'package:flutter/material.dart';
import 'package:camera/camera.dart';

import 'my_assessment_view.dart';

List<CameraDescription> cameras = [];

Future<void> main() async {
try {
// Ensure that plugin services are initialized so that `availableCameras()`
// can be called before `runApp()`
WidgetsFlutterBinding.ensureInitialized();

// Obtain a list of the available cameras on the device.
cameras = await availableCameras();
} on CameraException catch (e) {
debugPrint('Error in fetching the cameras: $e');
}

runApp(MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'XtraVision Demo App',
home: Scaffold(
appBar: AppBar(
title: const Text('XtraVision Demo App'),
),
body: const MyHomePage(),
)
);
}
}

class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
// 0 for back camera, and one for front camera
return MyAssessmentView(camera: cameras[1]);
}
}

copied to clipboard


lib/my_assessment_view.dart file looks like:
import 'package:flutter/material.dart';
import 'package:camera/camera.dart';
import 'package:xtravision_flutter_sdk/xtravision_flutter_sdk.dart';

class MyAssessmentView extends StatefulWidget {
final CameraDescription camera;

MyAssessmentView({required this.camera});

@override
State<MyAssessmentView> createState() => _MyAssessmentViewState();
}

class _MyAssessmentViewState extends State<MyAssessmentView> {

late XtraVisionConnectionData connectionData = XtraVisionConnectionData();
late XtraVisionLibData libData = XtraVisionLibData();
late XtraVisionEventData eventData = XtraVisionEventData();


@override
void initState() {
super.initState();
}

@override
void dispose() {
super.dispose();
}

XtraVisionConnectionData _getConnectionData() {
connectionData.assessmentName = 'SQUATS'; // Set Assessment Name
connectionData.authToken =
"__AUTH_TOKEN__"; // Set User specific auth-token

return connectionData;
}

XtraVisionLibData _getLibData() {
// Get a specific camera from the list of available cameras.
libData.camera = widget.camera;
libData.onServerResponse = onServerResponse;
libData.enableSkeletonView = true; // show skeleton view

return libData;
}

XtraVisionEventData _getEventData() {
return eventData;
}

onServerResponse(serverResponse) {
//Imp: wrap below code in try catch block.
try {
// ignore: avoid_print
print("XtraVision Server Response =============> ${serverResponse!}");
} catch (exception) {
// ignore: avoid_print
print(exception);
}
}

@override
Widget build(BuildContext context) {

return XtraVisionAssessmentWidget(
connectionData: _getConnectionData(),
libData: _getLibData(),
eventData: _getEventData(),
);
}
}

copied to clipboard


IMPORTANT: Kindly configure all required connectionData and libData in above class as per your need:
Once all required integration steps completed then server response will be printed into your flutter console:
I/flutter (26670): XtraVision Server Response =============> {"errors": [], "data": {"additional_response": {"in_pose": false, "reps": {"active_right": 0, "active_left": 0, "total": 0}, "raw_reps": [], "active_side": ""}, "angles": {"elbow_right": 39, "elbow_left": 47, "shoulder_right": 0, "shoulder_left": 0, "hip_right": 75, "hip_left": 47, "knee_right": 0, "knee_left": 0, "ankle_right": 0, "ankle_left": 0}, "corrective_feedback": [], "message": {}, "session_id": "cb7ca2bf-3e7b-4386-bb35-11ea07143a73", "assessment": "SQUATS", "timestamp": "1681394705047", "out_of_screen_feedback": {}, "meta": {}, "category": "POSE_BASED_REPS"}}
copied to clipboard
Additional information #
We are internally using GoogleML Kit for extracting body key-points. It's important to note that the GoogleML kit is not working properly on emulators So it's recommended to test your app with xtravision_flutter_sdk on a physical Android/IOS device is the best way to ensure proper functionality. Physical devices typically provide better hardware support and performance compared to emulators.
FAQs #


What data types should be set in the SDK?
There are three types of objects that need to be set on the XtraVisionAssessmentWidget.
1.1 XtraVisionConnectionData Object: This is the connection object where all connection-related data should be set, such as assessment-code, assessment-specific-config, etc.
1.2 XtraVisionLibData Object: This object holds SDK-specific configurations, including Response-Handler, need-to-enable-skeleton, skeleton-color-config, etc.
1.3 XtraVisionEventData Object: Include any specific data that needs to be sent to the XtraVision platform, such as the isEducationResponseRequired flag, etc.


How can I change the Skeleton Color?
To change the Skeleton Color, set leftPaintColor and rightPaintColor on the XtraVisionLibData object. This object is passed into the XtraVisionAssessmentWidget. Refer to the example app code for further details.


How can I retrieve body-side (front/left/right) data on the Education/Assessment Screen?
Set sideFlag = true in the XtraVisionAssessmentConfig, which is part of the XtraVisionConnectionData object.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.