
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
react-mindee-js
Advanced tools
Computer vision SDK for image segmentation and document processing on top of mindee APIs
Check out the storybook.
This SDK was made for building interfaces on top of Mindee document parsing APIs and more generally on top of any computer vision detection APIs.
This SDK was primarily made for document processing but can be used for any type of computer vision interface:
The React SDK is compatible with React 16.8.0 +
Installing with npm
npm install --save react-mindee-js
installing with yarn
yarn add react-mindee-js
Display an image with one custom shape
import {
AnnotationViewer,
createPolygonFromCoordinates
} from "react-mindee-js";
const HelloWorld = () => {
const [image, setImage] = useState(null)
const shapes = [
{
polygon: createPolygonFromCoordinates(
[
[0.66, 0.3],
[0.12, 0.5],
[0.52, 0.8],
[0.82, 0.24]
]
),
color: "#fd3246",
data:"This is red shape",
index: 0,
active: {
color: '#00f0f0',
lineWidth: 3
}
}
]
return (
<div>
<input type="file" onChange={e => setImage(URL.createObjectURL(e.target.files[0]))}/>
{
image && <div style={{ height: '500px', width: '400px'}}>
<AnnotationViewer
shapes={shapes}
image={image}
onShapeClick={shape => console.log('shapeClicked', shape)}
onShapeHover={shape => console.log('shapeHovered', shape)}
/>
</div>
}
</div>
);
}
export default HelloWorld;
Handle multi-pages pdfs navigation using the AnnotationSidebar component.
import {
AnnotationViewer,
createPolygonFromCoordinates,
getImagesFromPDF,
AnnotationSidebar
} from "react-mindee-js";
const MultiPagesPdf = () => {
const [pdfPages, setPdfPages] = useState([])
const [currentPdfPageIndex, setCurrentPdfPageIndex] = useState(0)
const pagesShapes = [
[
{
polygon: createPolygonFromCoordinates(
[
[0.66, 0.3],
[0.12, 0.5],
[0.52, 0.8],
[0.82, 0.24]
]
),
color: "#fd3246",
data: "This is first page shape",
index: 0,
active: {
color: '#00f0f0',
lineWidth: 3
}
}
],
[
{
polygon: createPolygonFromCoordinates(
[
[0.26, 0.3],
[0.32, 0.5],
[0.52, 0.64],
[0.52, 0.28]
]
),
color: "#fd3246",
data: "This is second page shape",
index: 0,
active: {
color: '#00f0f0',
lineWidth: 3
}
}
]
]
const handleUpload = (e) => {
getImagesFromPDF(URL.createObjectURL(e.target.files[0]))
.then((_pdfPages) => {setPdfPages(_pdfPages)}
)
}
return(
<div>
<input type="file" onChange={e => handleUpload(e)}/>
{
pdfPages.length > 0 &&
<div style={{ height: '500px', width: '400px'}}>
<AnnotationViewer
image={pdfPages[currentPdfPageIndex]}
shapes={pagesShapes[currentPdfPageIndex]}
/>
<AnnotationSidebar
items={pdfPages}
activeIndex={currentPdfPageIndex}
onChange={setCurrentPdfPageIndex}
/>
</div>
}
</div>
)
}
export default MultiPagesPdf;
Create easily a zoomed area wherever you need in your app.
import {
AnnotationViewer,
createPolygonFromCoordinates,
Point,
AnnotationLens
} from "react-mindee-js";
const Lens = () => {
const [image, setImage] = useState(null)
const [lensProps, setLensProps] = useState({
cursorPosition: new Point(),
selectedShape: null,
})
const shapes = [
{
polygon: createPolygonFromCoordinates(
[
[0.66, 0.3],
[0.12, 0.5],
[0.52, 0.8],
[0.82, 0.24]
]
),
color: "#fd3246",
data:"This is red shape",
index: 0,
active: {
color: '#00f0f0',
lineWidth: 3
}
}
]
return (
<div>
<input type="file" onChange={e => setImage(URL.createObjectURL(e.target.files[0]))}/>
{
image && <div style={{position: 'relative'}}>
<div style={{ height: '500px', width: '400px'}}>
<AnnotationViewer
shapes={shapes}
image={image}
onShapeClick={shape => console.log('shapeClicked', shape)}
onShapeHover={shape => console.log('shapeHovered', shape)}
getLensProps={setLensProps}
/>
</div>
<div
style={{
position: "absolute",
left: "10px",
top: "10px",
height: '100px',
width: '100px'
}}
>
<AnnotationLens
image={image}
shapes={shapes}
{...lensProps}
/>
</div>
</div>
}
</div>
);
}
export default Lens;
To help you prototype using mindee APIs, you can directly use the formatPrediction method to create shapes from a raw Mindee API response.
There is also a fake response exported from the library so you don't have to code your API calls to get started.
import {
AnnotationViewer,
fakeResponse,
formatPrediction
} from "react-mindee-js";
const Mindee = () => {
const [image, setImage] = useState(null)
const shapes = formatPrediction(fakeResponse.predictions[0])
return (
<div>
<input type="file" onChange={e => setImage(URL.createObjectURL(e.target.files[0]))}/>
{
image && <div style={{ height: '500px', width: '400px'}}>
<AnnotationViewer
shapes={shapes}
image={image}
onShapeClick={shape => console.log('shapeClicked', shape)}
onShapeHover={shape => console.log('shapeHovered', shape)}
/>
</div>
}
</div>
);
}
export default Mindee;
import { AnnotationViewer } from 'react-mindee-js';
<AnnotationViewer
shapes={shapes}
image={image}
onShapeClick={shape => console.log('shapeClicked', shape)}
onShapeHover={shape => console.log('shapeHovered', shape)}
/>
The annotation viewer is the main component on which you can feed an image or pdf, and display a list of shapes (items).
active: {
color: '#00ff00',
lineWidth: 3
}
import { createPolygonFromCoordinates } from "react-mindee-js";
const shapes = [
{
polygon: createPolygonFromCoordinates(
[
[0.66, 0.3],
[0.12, 0.5],
[0.52, 0.8],
[0.82, 0.24]
]
),
color: "#fd3246",
data:"This is red shape",
index: 0,
active: {
color: '#00ff00',
lineWidth: 3
}
}
]
The AnnotationLens component is a zoomed window displaying the area arround the user's pointer.
It works combined with a AnnotationViewer, check out the related use case below for an example.
<AnnotationLens
image={image}
shapes={shapes}
cursorPosition={cursorPosition}
selectedShape={selectedShape}
/>
The AnnotationSidebar is a vertical carousel displaying thumbnails of pdf pages.
<AnnotationSidebar
items={pdfPages}
activeIndex={currentPdfPageIndex}
onChange={setCurrentPdfPageIndex}
/>
The Fullscreen component enables a fullscreen mode for its children.
<Fullscreen
customButton={(onClick) => <div onClick={onClick}>My custom Button</div>}
>
<AnnotationViewer
items={items}
source={file.preview}
type={file.type}
/>
</Fullscreen>
This function formats raw predictions from Mindee APIs to feed the AnnotationViewer shapes easily.
const shapes = formatPrediction(mindeeAPIResponse.predictions[0])
This function generate sub images from a source image corresponding to shapes.
getShapesWithImages(file.preview, styled_shapes).then(
_shapesWithImages => {
// Do something with shapesWithImages
}
)
This function generate images from a pdf.
getImagesFromPDF(pdfFile)
.then((_pdfPages) => {
// Do something with images pdf pages
}
)
Feel free to use github to submit issues, pull requests or general feedback. You can also visit our website or drop us an email.
Please read our Contributing section before contributing.
GPLv3 © mindee
v1.1.2 (05/08/2020)
FAQs
Front-End Computer Vision SDK for React
The npm package react-mindee-js receives a total of 460 weekly downloads. As such, react-mindee-js popularity was classified as not popular.
We found that react-mindee-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.