Skip to content

Commit

Permalink
Merge branch 'main' into feat/pointCloud
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerwin-L committed Jun 27, 2022
2 parents 27048e5 + dd90bb6 commit d467bf3
Show file tree
Hide file tree
Showing 15 changed files with 142 additions and 62 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/labelbee-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: lint
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install modules
run: npm install
- name: Run Bootstrap
run: npm run bootstrap
- name: Build Type
run: npm run build:type
- name: Run ESLint
run: npm run lint
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,49 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.7.0](https://github.com/open-mmlab/labelbee/compare/v1.6.0...v1.7.0) (2022-06-23)


### Features

* [lb-component] Add TagToolInstanceAdaptor to implement toolInstance ([85cd646](https://github.com/open-mmlab/labelbee/commit/85cd64694638e17efee32fdd841b9be7dd281dbf))
* [lb-component] Implement keydown event for tagging ([5f441fe](https://github.com/open-mmlab/labelbee/commit/5f441feb0029cbcf704110c183d81dd8c1f67480))
* [lb-components] Support and export 'VideoPlayer' ([0aea748](https://github.com/open-mmlab/labelbee/commit/0aea748991389933d4d7965af3e21345fffbffa4))
* [lb-components] VideoTagTool Support i18n on hotkeys ([8216f5d](https://github.com/open-mmlab/labelbee/commit/8216f5dfb8ed0d723ed9aa5c2e15bdbbc4edf682))
* [lb-demo] Support the use of VideoPlayer ([7ab27c2](https://github.com/open-mmlab/labelbee/commit/7ab27c2df4a794f0a5695768888da1a4a3b574be))
* Add FileInvalid and FileException components, show operation on videoTagTool ([442318c](https://github.com/open-mmlab/labelbee/commit/442318cf1e38259b8314f538d0e91ada2329168d))
* Add pageChange add stepChange callback ([ea20140](https://github.com/open-mmlab/labelbee/commit/ea201407655675ae48c7e9bcd21e7e530c3d7b7c))
* add renderEnhance function ([009a734](https://github.com/open-mmlab/labelbee/commit/009a73498873ff489f0a2f44ad9bf6ca33a4a771))
* AnntoationView-Polygon adds keypoint showing ([f414dab](https://github.com/open-mmlab/labelbee/commit/f414dab0cec2ce09f14cf7af22272632d9717c17))
* Implement pushHistory on TagToolInstanceAdaptor ([cadd8c7](https://github.com/open-mmlab/labelbee/commit/cadd8c717e22f598325f5589ad9208862d3a1773))
* Init result on state while TagToolInstanceAdaptor mounted ([954ba29](https://github.com/open-mmlab/labelbee/commit/954ba293b21c9bf5110ec7d8c6c5bec0ad0dd5bd))
* PointTool emits messageSuccess when it adsorb edge ([e643dca](https://github.com/open-mmlab/labelbee/commit/e643dca72a7e3bcff45549d63ac3c2af67bb7dc2))
* PolygonTool add combining operation ([56bb126](https://github.com/open-mmlab/labelbee/commit/56bb126da98965afeb1cad414094fea905b774c4))
* PolygonTool add cutting operation ([cbc33ac](https://github.com/open-mmlab/labelbee/commit/cbc33ac68b2b66ca5a6b8d091098a77d0daedc6b))
* Rename Image Error to FileError and replace life cycle fn 'componentWillUnmount' ([3063f7c](https://github.com/open-mmlab/labelbee/commit/3063f7cad8cff6366a209f13ab2b3daca4ba5a06))
* Support batch data acquisition ([2d26c2d](https://github.com/open-mmlab/labelbee/commit/2d26c2d252bdb4c6b73b016f6833fb2b8d24dfe1))
* TagToolInstanceAdaptor export fn: 'setValid' and getter 'valid' ([e73ca3c](https://github.com/open-mmlab/labelbee/commit/e73ca3c64cdf46cafbd235494c9e7c84aaeaa8ba))
* VideoPlayer playPause while video clicked ([c003449](https://github.com/open-mmlab/labelbee/commit/c003449ae7c55428b27abbc7773c98a33da55933))
* VideoTagToolInstance support exporting videoMetaData on exportData ([1b2166c](https://github.com/open-mmlab/labelbee/commit/1b2166c7b5cf7b756396ca7a681f463d099e29b3))


### Bug Fixes

* `GetCloestPoint` function needs to be added `hasClosed` ([1581ed1](https://github.com/open-mmlab/labelbee/commit/1581ed1614cd5c43e432afe18dbbfb78748f6748))
* Click next step jump to the first page ([83a0335](https://github.com/open-mmlab/labelbee/commit/83a033520547dae0d9e57a0a8a338a3c4f2dcfca))
* fix eslint errors ([f20b3a3](https://github.com/open-mmlab/labelbee/commit/f20b3a32572950665e20e670b1531ea8a3697d31))
* Fix problems from comment ([145d20a](https://github.com/open-mmlab/labelbee/commit/145d20a7b1afd45521d41eeb88f8122e83e26e4b))
* Fix the pr error ([4a2fa2b](https://github.com/open-mmlab/labelbee/commit/4a2fa2be649605a0378943e641863b14307d120c))
* Fix the wrong internationalization issue ([3a78658](https://github.com/open-mmlab/labelbee/commit/3a7865844d4560f4f36bb454adf9a2655e2fa784))
* PointTool for reference only to display polygons and lines ([b177dd2](https://github.com/open-mmlab/labelbee/commit/b177dd2143ca62754512bb6e0e2607102c44abc0))
* PointTool is not allowed drawing outside the target when 'drawOutsideTarget' config is false ([2668cd7](https://github.com/open-mmlab/labelbee/commit/2668cd7c5f421b9ae9f8ae9d5c169cdeeb59df43))
* remove ts-ignore ([9065c34](https://github.com/open-mmlab/labelbee/commit/9065c34421d8cbd152eba760233cf452c31e360f))
* TagTool doesn't need to rotate ([c20576c](https://github.com/open-mmlab/labelbee/commit/c20576ce64b97f8610ca1810bac94289ce87a61b))
* Temporarily supports the use of the react AnnotationTool ([004e851](https://github.com/open-mmlab/labelbee/commit/004e851b632f339ee7fe7dd73a2bcde9cfda84d2))
* Update eslint error ([6941977](https://github.com/open-mmlab/labelbee/commit/6941977ab01476aa764d91fa9b60589fc51853d6))
* VideoPlayer have error status while src changed ([0bbf25c](https://github.com/open-mmlab/labelbee/commit/0bbf25c4492e59b3d634849290fe65ae729fa438))
* VideoTag emitEvent after clear result ([865575d](https://github.com/open-mmlab/labelbee/commit/865575da1a0928736f1e61cad588e5bca0d613fa))

## [1.6.0](https://github.com/open-mmlab/labelbee/compare/v1.5.0...v1.6.0) (2022-05-16)


Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"workspaces": [
"packages/*"
],
"version": "1.6.1",
"version": "1.7.0",
"scripts": {
"start": "lerna run build:type && lerna run --parallel --stream start",
"dev": "npm run start",
"bootstrap": "lerna bootstrap --no-ci",
"build": "lerna run build",
"build:type": "lerna run build:type",
"lint": "lerna run --parallel --stream lint",
"clean": "lerna clean && rm -rf ./node_modules/ && rm -rf ./packages/**/node_modules && rm -rf ./packages/**/package-lock.json",
"version": "lerna version --conventional-graduate --yes",
Expand Down
4 changes: 2 additions & 2 deletions packages/lb-annotation/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@labelbee/lb-annotation",
"version": "1.8.0-alpha.0",
"version": "1.8.0",
"description": "Annotation tool collection",
"keywords": [
"annotation",
Expand Down Expand Up @@ -90,7 +90,7 @@
"typescript": "^4.2.3"
},
"dependencies": {
"@labelbee/lb-utils": "^1.2.0-alpha.0",
"@labelbee/lb-utils": "^1.2.0",
"@turf/turf": "5.1.6",
"@types/three": "^0.141.0",
"color-rgba": "^2.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,9 @@ class PolygonOperation extends BasicToolOperation {
}

case EKeyCode.X:
e.altKey && this.segment();
if (e.altKey) {
this.segment();
}
break;

default: {
Expand Down Expand Up @@ -1275,6 +1277,8 @@ class PolygonOperation extends BasicToolOperation {
case 2:
this.isCombined = false;
break;
default:
return;
}

return;
Expand Down
46 changes: 23 additions & 23 deletions packages/lb-annotation/src/utils/tool/PolygonUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ERotateDirection } from '@/constant/annotation';
import { difference, polygon, union } from '@turf/turf';
import { ERotateDirection } from '@/constant/annotation';
import CommonToolUtils from './CommonToolUtils';
import { IPolygonData, IPolygonPoint } from '../../types/tool/polygon';
import { ELineTypes, SEGMENT_NUMBER } from '../../constant/tool';
Expand All @@ -19,12 +19,12 @@ export default class PolygonUtils {

// 支持范围hoverPolygonID
const axisList = AxisUtils.axisArea(checkPoint, scope);
polygonPoints.forEach((polygon) => {
if (polygon.pointList) {
polygonPoints.forEach((p) => {
if (p.pointList) {
axisList.forEach((v) => {
const size = this.calcPolygonSize(polygon.pointList);
if (this.isInPolygon(v, polygon.pointList, lineType) && size < minSize) {
hoverPolygonID = polygon.id;
const size = this.calcPolygonSize(p.pointList);
if (this.isInPolygon(v, p.pointList, lineType) && size < minSize) {
hoverPolygonID = p.id;
minSize = size;
}
});
Expand Down Expand Up @@ -237,7 +237,7 @@ export default class PolygonUtils {
* @returns
*/
public static getPolygonByID(polygonList: IPolygonData[], id?: string) {
return polygonList.find((polygon) => polygon.id === id);
return polygonList.find((p) => p.id === id);
}

public static getHoverEdgeIndex(
Expand Down Expand Up @@ -502,7 +502,7 @@ export default class PolygonUtils {

// 批量对多边形进行减操作 (需要对包裹内部的多边形进行判断)
polygonList.forEach((v) => {
const backgroundPolygon = polygon([[...PolygonUtils.concatBeginAndEnd(v.pointList.map((v) => [v.x, v.y]))]]);
const backgroundPolygon = polygon([[...PolygonUtils.concatBeginAndEnd(v.pointList.map((p) => [p.x, p.y]))]]);
const diff = difference(selectedPolygon, backgroundPolygon);

if (diff) {
Expand All @@ -511,20 +511,20 @@ export default class PolygonUtils {
}
});
const resultList =
selectedPolygon?.geometry?.coordinates.map((polygon) => {
selectedPolygon?.geometry?.coordinates.map((p) => {
// 多边形需要另外判断
//@ts-ignore
if (selectedPolygon?.geometry?.type === 'MultiPolygon') {
//@ts-ignore
return polygon[0].reduce(PolygonUtils.deletePolygonLastPoint, []);
return p[0].reduce(PolygonUtils.deletePolygonLastPoint, []);
}
return polygon.reduce(PolygonUtils.deletePolygonLastPoint, []);
return p.reduce(PolygonUtils.deletePolygonLastPoint, []);
}) ?? [];
return resultList.reduce((acc, pointList) => {
const len = pointList.length;
const newPointList = pointList.filter((point: IPolygonPoint, i: number) => {
return resultList.reduce((acc, pointLists) => {
const len = pointLists.length;
const newPointList = pointLists.filter((point: IPolygonPoint, i: number) => {
const nextIndex = (i + 1) % len;
if (AxisUtils.getIsInScope(point, pointList[nextIndex], 1)) {
if (AxisUtils.getIsInScope(point, pointLists[nextIndex], 1)) {
// 前后 1 像素之差的点清除
return false;
}
Expand All @@ -538,7 +538,7 @@ export default class PolygonUtils {
return [...acc, newPointList];
}, []);
} catch (error) {
console.log(error);
console.error(error);
}
}

Expand All @@ -551,9 +551,9 @@ export default class PolygonUtils {
* @returns
*/
public static getPolygonPointList(selectedPolygonID: string, polygonList: IPolygonData[]) {
const polygon = polygonList.filter((v) => v.id === selectedPolygonID);
if (polygon[0] && polygon[0].pointList && polygon[0].pointList.length > 0) {
return polygon[0].pointList;
const p = polygonList.find((v) => v.id === selectedPolygonID);
if (p && p.pointList && p.pointList.length > 0) {
return p.pointList;
}
return [];
}
Expand All @@ -565,7 +565,7 @@ export default class PolygonUtils {
* @returns
*/
public static getWrapPolygonIndex(pointList: IPolygonPoint[], polygonList: IPolygonData[]) {
return polygonList.findIndex((polygon) => PolygonUtils.isPointListInPolygon(pointList, polygon.pointList));
return polygonList.findIndex((p) => PolygonUtils.isPointListInPolygon(pointList, p.pointList));
}

/**
Expand Down Expand Up @@ -686,14 +686,14 @@ export default class PolygonUtils {
const newPolygon = selectedPolygon;
if (unionPolygon?.geometry?.coordinates?.length === 1) {
unionList.push(combinedPolygon.id);
const pointList = unionPolygon?.geometry.coordinates.map((polygon) => {
const pointList = unionPolygon?.geometry.coordinates.map((p) => {
// 多边形需要另外判断
if (unionPolygon?.geometry?.type === 'MultiPolygon') {
//@ts-ignore
return polygon[0].reduce(PolygonUtils.deletePolygonLastPoint, []);
return p[0].reduce(PolygonUtils.deletePolygonLastPoint, []);
}
//@ts-ignore
return polygon.reduce(PolygonUtils.deletePolygonLastPoint, []);
return p.reduce(PolygonUtils.deletePolygonLastPoint, []);
})[0];
newPolygon.pointList = pointList;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/lb-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@labelbee/lb-components",
"version": "1.5.0-alpha.0",
"version": "1.5.0",
"description": "Provide a complete library of annotation components",
"main": "./dist/index.js",
"es": "./es/index.js",
Expand Down Expand Up @@ -43,8 +43,8 @@
},
"dependencies": {
"@ant-design/icons": "^4.6.2",
"@labelbee/lb-annotation": "^1.8.0-alpha.0",
"@labelbee/lb-utils": "^1.2.0-alpha.0",
"@labelbee/lb-annotation": "^1.8.0",
"@labelbee/lb-utils": "^1.2.0",
"ahooks": "^3.4.0",
"classnames": "^2.3.0",
"lodash": "^4.17.21",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class TagToolInstanceAdaptor extends React.Component<
public videoRef?: HTMLVideoElement;
public labelSelectedList: number[] = [];

constructor(props: IVideoTagInstanceAdaptorProps) {
public constructor(props: IVideoTagInstanceAdaptorProps) {
super(props);
this.state = {
tagResult: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const VideoProgress = () => {
<div className={getClassName('video-slider', 'played')} style={{ width: playedPercent }} />
</div>

<div className={getClassName('video-slider-bar')} style={{ left: playedPercent }}></div>
<div className={getClassName('video-slider-bar')} style={{ left: playedPercent }} />
</div>
);
};
Expand Down
22 changes: 12 additions & 10 deletions packages/lb-components/src/components/videoPlayer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class VideoPlayer extends React.Component<IVideoPlayerProps, IVideoPlayer
public videoRef?: React.RefObject<HTMLVideoElement>;
public timeInterval?: number;

constructor(props: IVideoPlayerProps) {
public constructor(props: IVideoPlayerProps) {
super(props);
this.state = {
playbackRate: 1,
Expand All @@ -85,11 +85,11 @@ export class VideoPlayer extends React.Component<IVideoPlayerProps, IVideoPlayer
this.videoRef = React.createRef();
}

get videoElm() {
public get videoElm() {
return this.videoRef?.current;
}

get videoSrc() {
public get videoSrc() {
const { imgIndex, imgList } = this.props;
return imgIndex > -1 ? imgList[imgIndex]?.url ?? '' : '';
}
Expand All @@ -111,7 +111,7 @@ export class VideoPlayer extends React.Component<IVideoPlayerProps, IVideoPlayer
}
};

public updateNextPlaybackRate = (isForward: boolean = true) => {
public updateNextPlaybackRate = (isForward = true) => {
const idx = PLAYBACK_RATES.findIndex((r) => r === this.state.playbackRate);
let nextIdx = isForward ? Math.min(idx + 1, PLAYBACK_RATES.length - 1) : Math.max(idx - 1, 0);
this.changePlaybackPate(PLAYBACK_RATES[nextIdx]);
Expand Down Expand Up @@ -173,15 +173,14 @@ export class VideoPlayer extends React.Component<IVideoPlayerProps, IVideoPlayer
};

public onPause = () => {
this.setState(
{
isPlay: false,
},
this.onVideoStopped,
);
this.onVideoStopped();
};

public onVideoStopped = () => {
this.setState({
isPlay: false,
});

if (this.timeInterval) {
clearInterval(this.timeInterval);
this.timeInterval = undefined;
Expand Down Expand Up @@ -212,6 +211,7 @@ export class VideoPlayer extends React.Component<IVideoPlayerProps, IVideoPlayer
currentTime: 0,
buffered: 0,
error: false,
isPlay: false,
});
this.onVideoStopped();
};
Expand Down Expand Up @@ -274,6 +274,7 @@ export class VideoPlayer extends React.Component<IVideoPlayerProps, IVideoPlayer

return (
<VideoPlayerCtx.Provider
// eslint-disable-next-line react/jsx-no-constructed-context-values
value={{
videoRef: this.videoRef,
isPlay,
Expand Down Expand Up @@ -304,6 +305,7 @@ export class VideoPlayer extends React.Component<IVideoPlayerProps, IVideoPlayer
onDurationChange={setDuration}
width='100%'
height='100%'
onClick={playPause}
/>

<FileException
Expand Down
Loading

0 comments on commit d467bf3

Please sign in to comment.