You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

bbox.js 2.6 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /** Copyright 2020 Zhejiang Lab. All Rights Reserved.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. * =============================================================
  15. */
  16. import cx from 'classnames';
  17. import { isNil } from 'lodash';
  18. import { chroma } from '@/utils';
  19. export const defaultColor = 'rgba(102, 181, 245, 1)';
  20. const defaultFill = 'rgba(102, 181, 245, 0.1)';
  21. export default {
  22. name: 'Bbox',
  23. functional: true,
  24. props: {
  25. annotate: Object,
  26. brush: Object,
  27. scale: {
  28. type: Number,
  29. default: 1,
  30. },
  31. pos: {
  32. type: Object,
  33. default: () => ({}),
  34. },
  35. dragStart: Function,
  36. dragMove: Function,
  37. dragEnd: Function,
  38. currentAnnotationId: String,
  39. transformer: Object,
  40. imgRef: HTMLImageElement,
  41. },
  42. render(h, context) {
  43. const { props } = context;
  44. const { style } = context.data;
  45. const {
  46. annotate = {},
  47. currentAnnotationId,
  48. dragStart,
  49. dragMove,
  50. dragEnd,
  51. brush,
  52. transformer,
  53. ...rest // does this work?
  54. } = props;
  55. const { data = {} } = annotate;
  56. const { bbox, color } = data;
  57. if (isNil(bbox)) return null;
  58. const bgColor = color || defaultFill;
  59. const isActive = currentAnnotationId === annotate.id;
  60. const colorAlpha = isActive ? 0.4 : 0.1;
  61. const fill = chroma(bgColor).alpha(colorAlpha);
  62. let transform = null;
  63. // 匹配当前标注
  64. if(annotate.id === transformer.id) {
  65. transform = `translate(${transformer.dx}, ${transformer.dy})`;
  66. }
  67. return (
  68. <g class={cx('bbox-group', {
  69. active: isActive,
  70. })}>
  71. <rect
  72. fill={fill}
  73. stroke={color || defaultColor}
  74. strokeWidth={4}
  75. // {...bounding} spread operator sucks...
  76. x={props.pos.x}
  77. y={props.pos.y}
  78. width={props.pos.width}
  79. height={props.pos.height}
  80. transform={transform}
  81. onMousemove={dragMove}
  82. onMouseup={dragEnd}
  83. onMousedown={dragStart}
  84. style={style}
  85. {...rest}
  86. />
  87. </g>
  88. );
  89. },
  90. };

一站式算法开发平台、高性能分布式深度学习框架、先进算法模型库、视觉模型炼知平台、数据可视化分析平台等一系列平台及工具,在模型高效分布式训练、数据处理和可视分析、模型炼知和轻量化等技术上形成独特优势,目前已在产学研等各领域近千家单位及个人提供AI应用赋能

Contributors (1)