Skip to content

Commit 60c1c91

Browse files
authored
Merge pull request #56 from waoai/feat/fs
Full Segmentation (MVP)
2 parents 632d4d9 + 8f8623e commit 60c1c91

File tree

35 files changed

+1252
-22580
lines changed

35 files changed

+1252
-22580
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ yarn-error.log*
2424
storybook-static
2525

2626
dist
27+
28+
secret.*
29+
secret.story.*
30+
*.secret.*

package-lock.json

Lines changed: 0 additions & 22203 deletions
This file was deleted.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
{
22
"name": "react-image-annotate",
3-
"version": "1.0.15",
3+
"version": "1.2.2",
44
"dependencies": {
55
"@fortawesome/fontawesome-svg-core": "^1.2.12",
66
"@fortawesome/free-solid-svg-icons": "^5.6.3",
77
"@fortawesome/react-fontawesome": "^0.1.3",
88
"@material-ui/core": "^4.6.0",
99
"@material-ui/icons": "^4.9.1",
1010
"@semantic-release/git": "^9.0.0",
11+
"color-alpha": "^1.0.4",
1112
"get-image-data": "^3.0.1",
1213
"material-survey": "^1.0.34",
14+
"mmgc1-cpp": "^1.0.44",
1315
"moment": "^2.23.0",
1416
"react-full-screen": "^0.2.4",
1517
"react-hotkeys": "^2.0.0",
@@ -22,6 +24,7 @@
2224
"react-use": "^13.27.0",
2325
"react-use-measure": "^2.0.0",
2426
"seamless-immutable": "^7.1.4",
27+
"shallow-equal": "^1.2.1",
2528
"storybook": "^5.3.14",
2629
"transformation-matrix-js": "^2.7.6",
2730
"use-event-callback": "^0.1.0",

src/Annotator/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type Props = {
4141
videoSrc?: string,
4242
keyframes?: Object,
4343
videoName?: string,
44+
fullImageSegmentationMode?: boolean,
4445
}
4546

4647
export const Annotator = ({
@@ -50,14 +51,22 @@ export const Annotator = ({
5051
showPointDistances,
5152
pointDistancePrecision,
5253
showTags = true,
53-
enabledTools = ["select", "create-point", "create-box", "create-polygon"],
54+
enabledTools = [
55+
"select",
56+
"create-point",
57+
"create-box",
58+
"create-polygon",
59+
"create-expanding-line",
60+
"show-mask",
61+
],
5462
selectedTool = "select",
5563
regionTagList = [],
5664
regionClsList = [],
5765
imageTagList = [],
5866
imageClsList = [],
5967
keyframes = {},
6068
taskDescription,
69+
fullImageSegmentationMode = false,
6170
RegionEditLabel,
6271
videoSrc,
6372
videoTime = 0,
@@ -83,8 +92,10 @@ export const Annotator = ({
8392
showPointDistances,
8493
pointDistancePrecision,
8594
selectedTool,
95+
fullImageSegmentationMode: fullImageSegmentationMode,
8696
mode: null,
8797
taskDescription,
98+
showMask: true,
8899
labelImages: imageClsList.length > 0 || imageTagList.length > 0,
89100
regionClsList,
90101
regionTagList,
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// @flow
2+
3+
function clamp(num, min, max) {
4+
return num <= min ? min : num >= max ? max : num
5+
}
6+
7+
export default (expandingLine) => {
8+
const expandingWidth = expandingLine.expandingWidth || 0.005
9+
const pointPairs = expandingLine.points.map(({ x, y, angle, width }, i) => {
10+
if (!angle) {
11+
const n =
12+
expandingLine.points[clamp(i + 1, 0, expandingLine.points.length - 1)]
13+
const p =
14+
expandingLine.points[clamp(i - 1, 0, expandingLine.points.length - 1)]
15+
angle = Math.atan2(p.x - n.x, p.y - n.y) + Math.PI / 2
16+
}
17+
const dx = (Math.sin(angle) * (width || expandingWidth)) / 2
18+
const dy = (Math.cos(angle) * (width || expandingWidth)) / 2
19+
return [
20+
{ x: x + dx, y: y + dy },
21+
{ x: x - dx, y: y - dy },
22+
]
23+
})
24+
const firstSection = pointPairs.map(([p1, p2]) => p1)
25+
const secondSection = pointPairs.map(([p1, p2]) => p2).asMutable()
26+
secondSection.reverse()
27+
28+
const newPoints = firstSection.concat(secondSection).map(({ x, y }) => [x, y])
29+
30+
return {
31+
...expandingLine,
32+
type: "polygon",
33+
open: false,
34+
points: newPoints,
35+
unfinished: undefined,
36+
candidatePoint: undefined,
37+
}
38+
39+
// let { expandingWidth = 0.005, points } = region
40+
// expandingWidth = points.slice(-1)[0].width || expandingWidth
41+
// const lastPoint = points.slice(-1)[0]
42+
// return (
43+
// <>
44+
// <polygon
45+
// points={
46+
// .map((p) => `${p.x * iw} ${p.y * ih}`)
47+
// .join(" ")}
48+
// return {
49+
// ...expandingLine,
50+
// unfinished: undefined,
51+
// candidatePoint: undefined,
52+
// }
53+
}

src/Annotator/reducers/fix-twisted.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @flow
2+
3+
export default (pointsWithAngles) => {
4+
// Adjacent angles should not have an angular distance of more than Math.PI
5+
return pointsWithAngles
6+
}

0 commit comments

Comments
 (0)