@servantcdh/ez-planet-labeling 0.5.23 → 0.5.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1692,6 +1692,8 @@ export declare const TOOL_INFO_SEGMENT_ANYTHING = "Segment Anything";
1692
1692
 
1693
1693
  export declare const TOOL_INFO_SEGMENT_ANYTHING_BOX = "Segment Anything Box";
1694
1694
 
1695
+ export declare const TOOL_INFO_SEGMENT_ANYTHING_POINT = "Segment Anything Point";
1696
+
1695
1697
  declare interface ToolbarDividerItemType extends CommonItemType {
1696
1698
  variant: "toolbarDivider";
1697
1699
  }
package/dist/index.js CHANGED
@@ -2233,13 +2233,15 @@ const TOOL_INFO_COMBINED_LABELS = "Combined Label";
2233
2233
  const TOOL_INFO_AUTO_LABELING = "Auto Labeling";
2234
2234
  const TOOL_INFO_SEGMENT_ANYTHING = "Segment Anything";
2235
2235
  const TOOL_INFO_SEGMENT_ANYTHING_BOX = "Segment Anything Box";
2236
+ const TOOL_INFO_SEGMENT_ANYTHING_POINT = "Segment Anything Point";
2236
2237
  const TOOL_INFO_UPLOADED_LABEL = "Uploaded Label";
2237
2238
  const SEGMENT_ANYTHING_MASKINPUT_POSITIVE = 1;
2238
2239
  const SEGMENT_ANYTHING_MASKINPUT_NEGATIVE = 0;
2239
2240
  const EXCEPTION_TOOLS = [
2240
2241
  TOOL_INFO_BRUSHCURSOR,
2241
2242
  TOOL_INFO_SUPERPIXEL_BOUNDARY,
2242
- TOOL_INFO_SEGMENT_ANYTHING_BOX
2243
+ TOOL_INFO_SEGMENT_ANYTHING_BOX,
2244
+ TOOL_INFO_SEGMENT_ANYTHING_POINT
2243
2245
  ];
2244
2246
  const MOVEMENT_LOCK_TOOLS = [
2245
2247
  TOOL_INFO_SEGMENT_ANYTHING,
@@ -3587,7 +3589,7 @@ const LIB_AUTHOR = "최동호";
3587
3589
  const LIB_CONTACT = "servantcdh@naver.com";
3588
3590
  const __EZ_PLANET_META__ = Object.freeze({
3589
3591
  name: LIB_NAME,
3590
- version: "0.5.23",
3592
+ version: "0.5.24",
3591
3593
  author: LIB_AUTHOR,
3592
3594
  contact: LIB_CONTACT,
3593
3595
  license: "Proprietary — See LICENSE"
@@ -6445,6 +6447,33 @@ const createBrushCursor = (brush, colorCode) => {
6445
6447
  renderCursor();
6446
6448
  return { brushCursor, handleOnMouseMove, handleOnMouseUp };
6447
6449
  };
6450
+ const SAM_POINT_RADIUS = 6;
6451
+ const SAM_POINT_POSITIVE_COLOR = "#22c55e";
6452
+ const SAM_POINT_NEGATIVE_COLOR = "#ef4444";
6453
+ const createSamPointMarker = (canvas2, x, y, isPositive) => {
6454
+ const color = isPositive ? SAM_POINT_POSITIVE_COLOR : SAM_POINT_NEGATIVE_COLOR;
6455
+ const zoom = canvas2.getZoom();
6456
+ const radius = SAM_POINT_RADIUS / zoom;
6457
+ const strokeWidth = 2 / zoom;
6458
+ const marker = new Circle({
6459
+ left: x,
6460
+ top: y,
6461
+ radius,
6462
+ fill: color,
6463
+ stroke: "#ffffff",
6464
+ strokeWidth,
6465
+ originX: "center",
6466
+ originY: "center",
6467
+ selectable: false,
6468
+ evented: false,
6469
+ objectCaching: false,
6470
+ lockMovementX: true,
6471
+ lockMovementY: true,
6472
+ info: TOOL_INFO_SEGMENT_ANYTHING_POINT
6473
+ });
6474
+ canvas2.add(marker);
6475
+ canvas2.renderAll();
6476
+ };
6448
6477
  const getRectInit = ({ colorCode, callback }, isBlank, isSegmentAnything = false) => {
6449
6478
  const activeCanvas = ensureCanvas();
6450
6479
  if (isSegmentAnything) {
@@ -6514,6 +6543,7 @@ const getRectInit = ({ colorCode, callback }, isBlank, isSegmentAnything = false
6514
6543
  selectable: false
6515
6544
  }) : null;
6516
6545
  if (isSegmentAnything && !rect && callback) {
6546
+ createSamPointMarker(activeCanvas, x, y, true);
6517
6547
  callback({
6518
6548
  point: { x, y, maskInput: SEGMENT_ANYTHING_MASKINPUT_POSITIVE }
6519
6549
  });
@@ -6535,6 +6565,7 @@ const getRectInit = ({ colorCode, callback }, isBlank, isSegmentAnything = false
6535
6565
  e.preventDefault();
6536
6566
  const { x, y } = getPointerWithZoom({ x: e.offsetX, y: e.offsetY });
6537
6567
  if (e.target && e.target.localName === "canvas" && callback) {
6568
+ createSamPointMarker(activeCanvas, x, y, false);
6538
6569
  callback({
6539
6570
  point: { x, y, maskInput: SEGMENT_ANYTHING_MASKINPUT_NEGATIVE }
6540
6571
  });
@@ -6560,7 +6591,7 @@ const getRectInit = ({ colorCode, callback }, isBlank, isSegmentAnything = false
6560
6591
  document.removeEventListener("contextmenu", handleOnContextMenu);
6561
6592
  activeCanvas.remove(
6562
6593
  ...getLabeledObjects(activeCanvas).filter(
6563
- ({ info }) => info === TOOL_INFO_SEGMENT_ANYTHING_BOX
6594
+ ({ info }) => info === TOOL_INFO_SEGMENT_ANYTHING_BOX || info === TOOL_INFO_SEGMENT_ANYTHING_POINT
6564
6595
  )
6565
6596
  );
6566
6597
  getLabeledObjects(activeCanvas).forEach(
@@ -26261,6 +26292,7 @@ export {
26261
26292
  LabelingWorkspace,
26262
26293
  TOOL_INFO_SEGMENT_ANYTHING,
26263
26294
  TOOL_INFO_SEGMENT_ANYTHING_BOX,
26295
+ TOOL_INFO_SEGMENT_ANYTHING_POINT,
26264
26296
  VIRTUALIZED_RECORDS_ROW_META_SYMBOL,
26265
26297
  addCanvasObjects,
26266
26298
  errorData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servantcdh/ez-planet-labeling",
3
- "version": "0.5.23",
3
+ "version": "0.5.24",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",