Skip to content

Commit ee8484c

Browse files
PhotoCapture component (#682)
Implemented PhotoCapture component
1 parent f4f2d9b commit ee8484c

File tree

265 files changed

+15248
-13609
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

265 files changed

+15248
-13609
lines changed

apps/monk-test-app/src/i18n.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ i18n
2222
de: { translation: de },
2323
},
2424
})
25-
.catch((err) => console.error(err));
25+
.catch(console.error);
2626

2727
i18nLinkSDKInstances(i18n, [i18nCamera]);
2828

apps/monk-test-app/src/views/CameraView/components/TestPanelLastPic.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function TestPanelLastPic({ lastPicture }: TestPanelLastPicProps) {
5353
anchorRef.current.download = createFileName(lastPicture);
5454
}
5555
})
56-
.catch((err) => console.error(err));
56+
.catch(console.error);
5757
}
5858
}, [lastPicture]);
5959

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
.test-view-container {
22
height: 100%;
33
width: 100%;
4-
background-color: red;
4+
background-color: black;
55
display: flex;
66
align-items: center;
7-
justify-content: flex-end;
7+
justify-content: center;
8+
color: white;
89
}
Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,52 @@
1-
import React from 'react';
2-
import './TestView.css';
1+
import React, { useState } from 'react';
32
import { PhotoCapture } from '@monkvision/inspection-capture-web';
43
import { sights } from '@monkvision/sights';
4+
import './TestView.css';
5+
6+
const captureSights = [
7+
sights['haccord-8YjMcu0D'],
8+
sights['haccord-DUPnw5jj'],
9+
sights['haccord-hsCc_Nct'],
10+
sights['haccord-GQcZz48C'],
11+
sights['haccord-QKfhXU7o'],
12+
sights['haccord-mdZ7optI'],
13+
sights['haccord-bSAv3Hrj'],
14+
sights['haccord-W-Bn3bU1'],
15+
sights['haccord-GdWvsqrm'],
16+
sights['haccord-ps7cWy6K'],
17+
sights['haccord-Jq65fyD4'],
18+
sights['haccord-OXYy5gET'],
19+
sights['haccord-5LlCuIfL'],
20+
sights['haccord-Gtt0JNQl'],
21+
sights['haccord-cXSAj2ez'],
22+
sights['haccord-KN23XXkX'],
23+
sights['haccord-Z84erkMb'],
24+
];
25+
26+
const inspectionId = 'b072ff42-6244-ef3b-b018-5d3d6562c1bd';
27+
28+
const apiConfig = {
29+
apiDomain: 'api.preview.monk.ai/v1',
30+
authToken:
31+
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjNLUnpaNm01WDFzOWFBZWRudnBrWSJ9.eyJpc3MiOiJodHRwczovL2lkcC5wcmV2aWV3Lm1vbmsuYWkvIiwic3ViIjoiZ29vZ2xlLW9hdXRoMnwxMDY5MzYxMTEwMDU4MDYxODA1NTYiLCJhdWQiOlsiaHR0cHM6Ly9hcGkubW9uay5haS92MS8iLCJodHRwczovL21vbmstcHJldmlldy5ldS5hdXRoMC5jb20vdXNlcmluZm8iXSwiaWF0IjoxNzA3NDcxNzU5LCJleHAiOjE3MDc0Nzg5NTksImF6cCI6InNvWjdQMmM2YjlJNWphclFvUnJoaDg3eDlUcE9TYUduIiwic2NvcGUiOiJvcGVuaWQgcHJvZmlsZSBlbWFpbCIsInBlcm1pc3Npb25zIjpbIm1vbmtfY29yZV9hcGk6Y29tcGxpYW5jZXMiLCJtb25rX2NvcmVfYXBpOmRhbWFnZV9kZXRlY3Rpb24iLCJtb25rX2NvcmVfYXBpOmRhc2hib2FyZF9vY3IiLCJtb25rX2NvcmVfYXBpOmltYWdlc19vY3IiLCJtb25rX2NvcmVfYXBpOmluc3BlY3Rpb25zOmNyZWF0ZSIsIm1vbmtfY29yZV9hcGk6aW5zcGVjdGlvbnM6ZGVsZXRlIiwibW9ua19jb3JlX2FwaTppbnNwZWN0aW9uczpkZWxldGVfYWxsIiwibW9ua19jb3JlX2FwaTppbnNwZWN0aW9uczpkZWx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bU4rZheej2s0obXaXqZCUTbUOh8scL-81tbH_ZlKN3oSXfqUVMnwvpa1bnXZHmjeHi2e3bhvjxW-Jg5DrBB9gNfstxK0hugrlxtNL96y6ImEITOxOMEbURYGwOLQQtLkRqFo7AeZCu-_w6UbtFZfLJc5FlsWpTKy7I3_xMynzDGGaADRQeyazL_7DfemCb_VPXkR9aV67tF4pt6jevCetYI5CfN5X2JJrp7XNES_M2d7wGdJl5C6lbBPs3n3SA',
32+
};
533

6-
const sightsArray = Object.values(sights)
7-
.filter((value) => value.category === 'exterior')
8-
.slice(0, 5);
934
export function TestView() {
35+
const [complete, setComplete] = useState(false);
36+
1037
return (
1138
<div className='test-view-container'>
12-
<PhotoCapture sights={sightsArray} />
39+
{complete ? (
40+
'Inspection Complete!'
41+
) : (
42+
<PhotoCapture
43+
sights={captureSights}
44+
inspectionId={inspectionId}
45+
apiConfig={apiConfig}
46+
onComplete={() => setComplete(true)}
47+
onClose={() => console.log('coucou')}
48+
/>
49+
)}
1350
</div>
1451
);
1552
}

documentation/docs/getting-started.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,54 @@ sidebar_position: 2
33
---
44

55
# Getting Started
6+
## PhotoCapture
7+
If you plan on integrating the PhotoCapture workflow into your app, you can first start by installing the required
8+
dependencies :
9+
10+
```shell
11+
yarn add @monkvision/inspection-capture-web @monkvision/sights
12+
```
13+
14+
You can then create a new page in your application that will implement the PhotoCapture component in the following way :
15+
16+
```tsx
17+
import { sights } from '@monkvision/sights';
18+
import { PhotoCapture } from '@monkvision/inspection-capture-web';
19+
20+
const apiConfig = {
21+
apiDomain: 'MONK_API_DOMAIN',
22+
authToken: 'YOUR_AUTH0_ACCESS_TOKEN',
23+
};
24+
25+
const sights = [
26+
sights['fesc20-H1dfdfvH'],
27+
sights['fesc20-WMUaKDp1'],
28+
sights['fesc20-LTe3X2bg'],
29+
sights['fesc20-hp3Tk53x'],
30+
];
31+
32+
export function MonkCapturePage() {
33+
const handleSuccess = () => {
34+
// Redirect to another page once the inspection is complete.
35+
};
36+
37+
return (
38+
<PhotoCapture
39+
inspectionId={inspectionId}
40+
apiConfig={apiConfig}
41+
sights={sights}
42+
onComplete={handleSuccess}
43+
/>
44+
);
45+
}
46+
```
47+
48+
In the code snippet above, you can replace :
49+
- `MONK_API_DOMAIN` by the Monk APi Domain that you plan on using :
50+
- `api.monk.ai/v1` for production
51+
- `api.preview.monk.ai/v1` for preview
52+
- `YOUR_AUTH0_ACCESS_TOKEN` by the Auth0 authentication token that you previously generated by logging in
53+
- `sights` with an array of sights of your choice obtained from the `@monkvision/sights` package.
54+
55+
For additional configuration options for this component, please refer to the
56+
[InspectionCaptureWeb documentation page](docs/packages/inspection-capture-web.md).

documentation/docs/introduction.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ that exposes endpoints to communicate with the AI models. The usual Monk workflo
1515
should be included with every request made to the Monk API.
1616
2. Create an *Inspection* using the `POST /inspection` endpoint, and specify which AI models (which *Tasks*) you want to
1717
run during this inspection.
18-
3. Take pictures of your vehicle and add them to your inspection using the `POST /inspection/{id}/images` endpiont. For
18+
3. Take pictures of your vehicle and add them to your inspection using the `POST /inspection/{id}/images` endpoint. For
1919
each picture, specify which *Task* you want to run on it.
2020
4. *(optional)* Ask the API to analyze the quality of the images before running the AI models on them
2121
5. Once all the pictures are uploaded, tell the API to start inspection *Tasks* by using the
@@ -36,8 +36,8 @@ implement this workflow yourself, you can refer to our [API Documentation](https
3636
Among other things, the MonkJs SDK offers the following tools to implement the workflow mentionned above :
3737

3838
- A package called [network](docs/packages/network.md) that offers utility functions to easily communicate with our API.
39-
- A single-page component called [InspectionCapture](docs/packages/inspection-capture-web.md) that you can place in your
40-
app to display a camera preview and allow users to take pictures of their vehicle, analyze the quality of the pictures
39+
- Single-page components like [PhotoCapture](docs/packages/inspection-capture-web.md) that you can place in your app
40+
to display a camera preview and allow users to take pictures of their vehicle, analyze the quality of the pictures
4141
taken and upload them to the API.
4242
- A single-page component called [InspectionReport](docs/packages/inspection-report-web.md) that you can place in your app
4343
to display the results of an insepction, update the results if needed, and ask the API to generate the PDF report.

documentation/docs/packages/camera-web.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ called Camera, that lets you display a camera preview on your app as well as an
1111
to take pictures, compress images, etc.
1212

1313
Generally speaking, as a developer using our SDK, you won't have to directly use this component, since you probably
14-
want to use higher level components such as the [inspection-capture-web](docs/packages/inspection-capture-web.md) package.
14+
want to use higher level components such as the ones available in the
15+
[inspection-capture-web](docs/packages/inspection-capture-web.md) package.
1516

1617
## Complete Documentation
1718
As every other package in the SDK, please refer to

documentation/docs/packages/inspection-capture-web.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ sidebar_position: 5
66
![npm latest package](https://img.shields.io/npm/v/@monkvision/inspection-capture-web/latest.svg)
77

88
## Overview
9-
This package exports a single page component for React (Web) called InspectionCapture that implements the capture
10-
process in the Monk SDK. The capture process allows the user to take pictures of its vehicle and will automatically send
11-
the pictures to our API, start the tasks and check the quality of the images using our compliance features.
9+
This package exports single page components for React (Web) that implements different capture workflows in the Monk SDK.
10+
The capture process allows the user to take pictures of its vehicle, automatically send them to our API, start the tasks
11+
and check the quality of the images using our compliance features.
1212

1313
## Complete Documentation
1414
As every other package in the SDK, please refer to

documentation/docs/upgrading-from-v3.md

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,186 @@ sidebar_position: 3
33
---
44

55
# Upgrading From V3
6+
This documentation page provides guidlines to upgrade from the MonkJs 3.X version to the 4.X.
7+
8+
## Why upgrade?
9+
MonkJs 4 is a complete revamp of the Monk SDK, rewritten from scratch, aimed at providing :
10+
- Better performances
11+
- Better monitoring for bug catching
12+
- New and improved UX/UI
13+
- New features (Video capture, live compliance, offline management...)
14+
- TypeScript typings with TSDoc integrated
15+
- Better documentation
16+
- And many more 🚀
17+
18+
Another key thing is that MonkJs used to be developed as a cross-platform React-Native SDK for Web (iOS / Android /
19+
Web). This basically forced us to use Expo and other dependencies that were hard to maintain with such low-level
20+
features. MonkJs 4 solves this issue by offering basically two SDKs : one for Web using ReactJs, and one for Native
21+
using React-Native. Some packages of the SDK work for both web and native, while others are split into two separate
22+
pacakges every time : one ending with `-web` for Web and one ending with `-native` for Native.
23+
24+
For now, only the Web part of the SDK has been implemented, but the Native one should come soon enough!
25+
26+
## Sights
27+
The sights data previous exported as the default export of the Sights package is now split into 3 objects :
28+
- `vehicles` containing the details for each vehicle used as a model for the sights
29+
- `labels` containing translation details about each Sight label
30+
- `sights` containing the Sight data, with more or less the same structure as before, except for the vehicle details and
31+
sight label that now are simply a key reference to the other data export by the package.
32+
33+
Another major difference is that sights now include additional details such as the list of tasks recommended to be run
34+
for this sight. This means that you now don't have to specify manually which task to run for each sight when
35+
implementing a capture workflow.
36+
37+
#### How you did it in MonkJs 3
38+
```javascript
39+
import sights from '@monkvision/sights';
40+
41+
const sight = sights['fesc20-H1dfdfvH'];
42+
console.log(JSON.stringify(sight, null, 2));
43+
/*
44+
* Output :
45+
* {
46+
* "id": "fesc20-H1dfdfvH",
47+
* "category": "exterior"
48+
* "overlay": "<svg>...</svg>"
49+
* "label": {
50+
* "en":"Front Low",
51+
* "fr":"Avant (position basse)"
52+
* },
53+
* }
54+
*/
55+
```
56+
57+
#### How you do it in MonkJs 4
58+
```typescript
59+
import { sights, labels } from '@monkvision/sights';
60+
61+
const sight = sights['fesc20-H1dfdfvH'];
62+
console.log(JSON.stringify(sight, null, 2));
63+
/*
64+
* Output :
65+
* {
66+
* "id": "fesc20-H1dfdfvH",
67+
* "category": "exterior",
68+
* "label": "front-low",
69+
* "overlay": "<svg>...</svg>",
70+
* "tasks": [
71+
* "damage_detection"
72+
* ],
73+
* "vehicle": "fesc20"
74+
* }
75+
*/
76+
77+
console.log(JSON.stringify(labels[sight.label], null, 2));
78+
/*
79+
* Output :
80+
* {
81+
* "key": "front-low",
82+
* "en": "Front Low",
83+
* "fr": "Avant - vue basse",
84+
* "de": "Vorderseite Niedrig"
85+
* }
86+
*/
87+
```
88+
89+
## Camera and Inspection Capture
90+
The `@monkvision/camera` package used to provide components such as `Capture` that were used to implement the picture
91+
taking workflows (capture workflows) for inspections, as well as declaring the Camera app used by these Capture
92+
components. This package has now been split into two :
93+
94+
- `@monkvision/camera-web` : A package that export a component called `Camera` that implements a camera preview used to
95+
take pictures, as well as logic utilities used to handle this camera. Usually, as a developer using the SDK, you won't
96+
have to use this package directly.
97+
- `@monkvision/inspection-capture-web` : A package that export capture components (such as `PhotoCapture`) used to
98+
integrate the different Monk inspection capture workflows into your app.
99+
100+
#### How you did it in MonkJs 3
101+
```jsx
102+
import monk from '@monkvision/corejs';
103+
import { Capture, Controls } from '@monkvision/camera';
104+
105+
const { TaskName } = monk.types;
106+
monk.config.authConfig = { domain: 'api.monk.ai/v1' };
107+
monk.config.accessToken = 'YOUR_AUTH0_ACCESS_TOKEN';
108+
109+
const inspectionId = '1e11fb94-26fe-4956-90b6-d11ef3c87da4';
110+
111+
const sightIds = [
112+
'fesc20-H1dfdfvH',
113+
'fesc20-WMUaKDp1',
114+
'fesc20-LTe3X2bg',
115+
'fesc20-hp3Tk53x',
116+
];
117+
118+
const mapTasksToSight = [
119+
{ id: 'fesc20-H1dfdfvH', tasks: [TaskName.DAMAGE_DETECTION] },
120+
{ id: 'fesc20-WMUaKDp1', tasks: [TaskName.DAMAGE_DETECTION] },
121+
{ id: 'fesc20-LTe3X2bg', tasks: [TaskName.DAMAGE_DETECTION] },
122+
{ id: 'fesc20-hp3Tk53x', tasks: [TaskName.DAMAGE_DETECTION] },
123+
];
124+
125+
function App() {
126+
const [cameraLoading, setCameraLoading] = useState(false);
127+
128+
const controls = [
129+
{ disabled: cameraLoading, ...Controls.AddDamageButtonProps },
130+
{ disabled: cameraLoading, ...Controls.CaptureButtonProps },
131+
];
132+
133+
const handleSuccess = () => {
134+
// Update all the tasks statuses to TODO manually and then redirect to another page.
135+
};
136+
137+
return (
138+
<Capture
139+
inspectionId={inspectionId}
140+
sightIds={sightIds}
141+
mapTasksToSight={mapTasksToSight}
142+
controls={controls}
143+
loading={cameraLoading}
144+
onReady={() => setCameraLoading(false)}
145+
onStartUploadPicture={() => setCameraLoading(true)}
146+
onFinishUploadPicture={() => setCameraLoading(false)}
147+
enableComplianceCheck
148+
onComplianceCheckFinish={handleSuccess}
149+
/>
150+
);
151+
}
152+
```
153+
154+
#### How you do it in MonkJs 4
155+
```tsx
156+
import { sights } from '@monkvision/sights';
157+
import { PhotoCapture } from '@monkvision/inspection-capture-web';
158+
159+
const apiConfig = {
160+
apiDomain: 'api.monk.ai/v1',
161+
authToken: 'YOUR_AUTH0_ACCESS_TOKEN',
162+
};
163+
164+
const inspectionId = '1e11fb94-26fe-4956-90b6-d11ef3c87da4';
165+
166+
const sights = [
167+
sights['fesc20-H1dfdfvH'],
168+
sights['fesc20-WMUaKDp1'],
169+
sights['fesc20-LTe3X2bg'],
170+
sights['fesc20-hp3Tk53x'],
171+
];
172+
173+
function App() {
174+
const handleSuccess = () => {
175+
// Immediately redirect to another page.
176+
};
177+
178+
return (
179+
<PhotoCapture
180+
inspectionId={inspectionId}
181+
apiConfig={apiConfig}
182+
sights={sights}
183+
compliances={{ iqa: true }}
184+
onComplete={handleSuccess}
185+
/>
186+
);
187+
}
188+
```

documentation/docs/v3-docs/guides/upgrading-to-3.5.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,3 @@ rename those sights accordingly in the list of sight given as the `sightIds` pro
9191
| UHZkpCuK | vwtroc-UHZkpCuK |
9292
| 3a3OheoD | vwtroc-3a3OheoD |
9393
| IVcF1dOP | vwtroc-IVcF1dOP |
94-

0 commit comments

Comments
 (0)