handleClick(e, index)}
209 | onMouseEnter={(e) => handleAnnotationMouseEnter(e, index)}
210 | onMouseLeave={(e) => handleAnnotationMouseLeave(e, index)}
211 | />
212 | );
213 | bbox = {
214 | x: annotation.points[0],
215 | y: annotation.points[1],
216 | width: annotation.points[2],
217 | height: annotation.points[3],
218 | };
219 | }
220 |
221 | let labelComponent = null;
222 | if (annotation.label) {
223 | const padding = 5;
224 | labelComponent = (
225 |
237 | );
238 | }
239 |
240 | return (
241 |
242 | {shapeComponent}
243 | {labelComponent}
244 |
245 | );
246 | };
247 |
248 | const renderSelectionShape = (shape: Shape, index: number) => {
249 | if (shape.type === "rect") {
250 | return (
251 |
261 | );
262 | } else if (shape.type === "polygon") {
263 | return (
264 |
272 | );
273 | }
274 | return null;
275 | };
276 |
277 | return (
278 | // A focusable container so that key events are captured
279 |
291 |
292 |
299 |
305 | {img && }
306 | {props.annotations.map((annotation, index) =>
307 | renderAnnotation(annotation, index)
308 | )}
309 | {props.mouseSelection.map((shape, index) =>
310 | renderSelectionShape(shape, index)
311 | )}
312 | {isSelecting && (
313 |
322 | )}
323 |
324 |
325 |
326 |
327 | );
328 | };
329 |
330 | AnnotatedImage.defaultProps = {
331 | annotations: [],
332 | mouseSelection: [],
333 | annotationStyles: {},
334 | };
335 |
--------------------------------------------------------------------------------
/examples/quaero.py:
--------------------------------------------------------------------------------
1 | #