Skip to content

Commit

Permalink
Filtered out the unwanted compliances (#612)
Browse files Browse the repository at this point in the history
Co-authored-by: souyahia-monk <samy.ouyahia@monkvision.ai>
  • Loading branch information
souyahia-monk and souyahia-monk authored Nov 22, 2023
1 parent a68e1cd commit b185d02
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';

const validErrorCodes = [
'UNKNOWN_SIGHT',
'INTERIOR_NOT_SUPPORTED',
'NO_CAR_BODY',
'UNKNOWN_VIEWPOINT',
const translatedErrorCodes = [
'TOO_ZOOMED',
'NOT_ZOOMED_ENOUGH',
'WRONG_ANGLE',
'UNKNOWN_VIEWPOINT',
'WRONG_CENTER_PART',
'MISSING_PARTS',
'HIDDEN_PARTS',
// 'TOO_ZOOMED',
// 'NOT_ZOOMED_ENOUGH',
'UNKNOWN_SIGHT',
'INTERIOR_NOT_SUPPORTED',
];

export default function useSubtitle({
Expand Down Expand Up @@ -42,7 +41,7 @@ export default function useSubtitle({

if (badQuality && iqa.reasons) {
iqa.reasons.forEach((reason, index) => {
const errorCode = validErrorCodes.find((code) => reason.startsWith(code));
const errorCode = translatedErrorCodes.find((code) => reason.startsWith(code));
if (errorCode && errorCode !== 'UNKNOWN_SIGHT') {
const first = index === 0;
reasons.push(first ? t(`uploadCenter.subtitle.reasons.${reason}`)
Expand All @@ -54,7 +53,7 @@ export default function useSubtitle({
if (badCoverage && carCov.reasons) {
carCov.reasons.forEach((reason, index) => {
const first = index === 0 && !badQuality;
const errorCode = validErrorCodes.find((code) => reason.startsWith(code));
const errorCode = translatedErrorCodes.find((code) => reason.startsWith(code));
// display all reasons expect `UNKNOWN_SIGHT`
if (errorCode && errorCode !== 'UNKNOWN_SIGHT') {
reasons.push(first ? t(`uploadCenter.subtitle.reasons.${errorCode}`)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const ALLOWED_COMPLIANCE_REASONS = [
'LOW_RESOLUTION',
'BLURRINESS',
'UNDEREXPOSURE',
'OVEREXPOSURE',
'LENS_FLARE',
'DIRTINESS',
'SNOWNESS',
'WETNESS',
'REFLECTIONS',
];

export default function filterUnwantedComplianceReasons(reasons) {
if (!Array.isArray(reasons)) {
return reasons;
}
return reasons.filter(
(reason) => ALLOWED_COMPLIANCE_REASONS
.findIndex((allowedReason) => reason.startsWith(allowedReason)) !== -1,
);
}

/*
* For reference, here is the complete list of compliances reasons known to this date.
* - Samy 22/11/23
* OTHER
* LOW_RESOLUTION
* BLURRINESS
* UNDEREXPOSURE
* OVEREXPOSURE
* LENS_FLARE
* DIRTINESS
* SNOWNESS
* WETNESS
* REFLECTIONS
* UNKNOWN_SIGHT
* UNKNOWN_VIEWPOINT
* NO_VEHICLE
* WRONG_ANGLE
* WRONG_CENTER_PART
* MISSING_PARTS
* HIDDEN_PARTS
* TOO_ZOOMED
* NOT_ZOOMED_ENOUGH
* INTERIOR_NOT_SUPPORTED
* MISSING
* LOW_QUALITY
*/
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useCallback, useMemo } from 'react';
import filterUnwantedComplianceReasons from './allowedComplianceReasons';

const getIndexById = (id, array) => array.findIndex((item) => item.id === id);
const hasTodo = (c) => c?.is_compliant === null || c?.status === 'TODO';
Expand Down Expand Up @@ -26,6 +27,10 @@ export default function useComplianceIds({
const carCov = result.data.compliances.coverage_360;
const iqa = result.data.compliances.image_quality_assessment;

// Filter unwanted reasons
carCov.reasons = filterUnwantedComplianceReasons(carCov.reasons);
iqa.reasons = filterUnwantedComplianceReasons(iqa.reasons);

// `handleChangeReasons` returns the full result object with the given compliances
const handleChangeReasons = (compliances) => ({
...item,
Expand Down
25 changes: 8 additions & 17 deletions packages/camera/src/i18n/resources/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,16 @@ const en = {
blurriness: 'is blurry',
underexposure: 'is underexposed (too dark)',
overexposure: 'is overexposed (too bright)',
'TOO_ZOOMED--too zoomed': 'is too zoomed',
'NOT_ZOOMED_ENOUGH--not zoomed enough': 'is too far from vehicle',
'WRONG_ANGLE--wrong angle': 'is taken from incorrect angle',
'UNKNOWN_VIEWPOINT--unknown viewpoint': 'doesn\'t match photo guide',
'WRONG_CENTER_PART--picture centered on the wrong parts': 'is not centered on the right part',
'MISSING_PARTS--missing some parts': 'is missing important car parts',
'HIDDEN_PARTS--some parts not visible enough': 'has some car parts not visible enough',
'NO_CAR_BODY--no car body detected': 'doesn\'t have a clear vehicle',
'NO_CAR_BODY--No car body was detected. Car parts prediction is `None`.': 'no car was detected',
TOO_ZOOMED: 'is too zoomed',
NOT_ZOOMED_ENOUGH: 'is too far from vehicle',
WRONG_ANGLE: 'is taken from incorrect angle',
UNKNOWN_VIEWPOINT: 'doesn\'t match photo guide',
WRONG_CENTER_PART: 'is not centered on the right part',
MISSING_PARTS: 'is missing important car parts',
HIDDEN_PARTS: 'has some car parts not visible enough',
NO_CAR_BODY: 'doesn\'t have a clear vehicle',
UNKNOWN_SIGHT: 'can\'t be analysed for the car coverage',
INTERIOR_NOT_SUPPORTED: 'can\'t be analysed for the car coverage',
NO_CAR_BODY: 'does not contain a car',
UNKNOWN_VIEWPOINT: 'is taken from an unknown point of vue',
WRONG_ANGLE: 'is taken from the wrong angle',
WRONG_CENTER_PART: 'is not centered on the proper car part',
MISSING_PARTS: 'is missing some car parts',
HIDDEN_PARTS: 'contains car parts not visible enough',
TOO_ZOOMED: 'is too zoomed',
NOT_ZOOMED_ENOUGH: 'is not zoomed enough',
},
},
variant: {
Expand Down
25 changes: 8 additions & 17 deletions packages/camera/src/i18n/resources/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,16 @@ const fr = {
blurriness: 'est floue',
underexposure: 'est sous-exposée (trop sombre)',
overexposure: 'est sur-exposée (trop lumineuse)',
'TOO_ZOOMED--too zoomed': 'est trop zoomée',
'NOT_ZOOMED_ENOUGH--not zoomed enough': 'est trop loin du véhicule',
'WRONG_ANGLE--wrong angle': 'est prise depuis un angle incorrect',
'UNKNOWN_VIEWPOINT--unknown viewpoint': 'ne s\'aligne pas avec le guide photo',
'WRONG_CENTER_PART--picture centered on the wrong parts': 'n\'est pas centrée au bon endroit',
'MISSING_PARTS--missing some parts': 'ne contient pas les bonnes parties de la voiture',
'HIDDEN_PARTS--some parts not visible enough': 'contient certaines parties de voiture qui ne sont pas assez visibles',
'NO_CAR_BODY--no car body detected': 'n\'a pas de véhicule clair',
'NO_CAR_BODY--No car body was detected. Car parts prediction is `None`.': 'aucune voiture n\'a été détéctée',
TOO_ZOOMED: 'est trop zoomée',
NOT_ZOOMED_ENOUGH: 'est trop loin du véhicule',
WRONG_ANGLE: 'est prise depuis un angle incorrect',
UNKNOWN_VIEWPOINT: 'ne s\'aligne pas avec le guide photo',
WRONG_CENTER_PART: 'n\'est pas centrée au bon endroit',
MISSING_PARTS: 'ne contient pas les bonnes parties de la voiture',
HIDDEN_PARTS: 'contient certaines parties de voiture qui ne sont pas assez visibles',
NO_CAR_BODY: 'n\'a pas de véhicule clair',
UNKNOWN_SIGHT: 'ne peut pas être analysée pour la couverture de voiture',
INTERIOR_NOT_SUPPORTED: 'ne peut pas être analysée pour la couverture de voiture',
NO_CAR_BODY: 'ne contient pas de voiture',
UNKNOWN_VIEWPOINT: 'est prise depuis un point de vue non reconnu',
WRONG_ANGLE: 'est prise depuis un mauvais angle',
WRONG_CENTER_PART: 'n\'est pas centrée sur la bonne partie de voiture',
MISSING_PARTS: 'ne contient pas toutes les parties de voiture',
HIDDEN_PARTS: 'contient des parties de voiture pas assez visibles',
TOO_ZOOMED: 'est trop zoomée',
NOT_ZOOMED_ENOUGH: 'n\'est pas assez zoomée',
},
},
variant: {
Expand Down

0 comments on commit b185d02

Please sign in to comment.