Comments (12)
Can you provide the complete code? Are there any errors in the console?
from jscanify.
from jscanify.
I'm going to need you to be more specific. All the starter code has been verified to work, so I will need you to send me the code that you are using.
from jscanify.
Ok sorry about that. I switched to the camera example but the 2 output windows are very small
index.html:
<html>
<head>
<script src="https://docs.opencv.org/4.7.0/opencv.js" async></script>
<!-- warning: loading OpenCV can take some time. Load asynchronously -->
<script src="https://cdn.jsdelivr.net/gh/ColonelParrot/jscanify@master/src/jscanify.min.js"></script>
</head>
<body>
<h4>Tiny TFJS example<hr/></h4>
<video id="video"></video> <canvas id="canvas"></canvas>
<!-- original video -->
<canvas id="result"></canvas>
<!-- highlighted video -->
<script src="./index.js"> </script>
</body>
</html>
index.js:
const scanner = new jscanify();
const canvasCtx = canvas.getContext("2d");
const resultCtx = result.getContext("2d");
navigator.mediaDevices.getUserMedia({ video: true }).then((stream) => {
video.srcObject = stream;
video.onloadedmetadata = () => {
video.play();
setInterval(() => {
canvasCtx.drawImage(video, 0, 0);
const resultCanvas = scanner.highlightPaper(canvas);
resultCtx.drawImage(resultCanvas, 0, 0);
}, 10);
};
});
from jscanify.
canvas
has a default height and width of 150px and 300px respectively. You have to resize the canvas to the dimensions of the video stream.
The working index.js
code should be:
const scanner = new jscanify();
const canvasCtx = canvas.getContext("2d");
const resultCtx = result.getContext("2d");
navigator.mediaDevices.getUserMedia({
video: true
}).then((stream) => {
video.srcObject = stream;
video.onloadedmetadata = () => {
video.play();
canvas.height = result.height = video.videoHeight;
canvas.width = result.width = video.videoWidth;
setInterval(() => {
canvasCtx.drawImage(video, 0, 0);
const resultCanvas = scanner.highlightPaper(canvas);
resultCtx.drawImage(resultCanvas, 0, 0);
}, 10);
};
});
from jscanify.
I will test this
from jscanify.
Does the example only work with white paper?
from jscanify.
hmm, when I run this code, the final highlighted image does not appear.
<html>
<head>
<script src="https://docs.opencv.org/4.7.0/opencv.js" async></script>
<!-- warning: loading OpenCV can take some time. Load asynchronously -->
<script src="https://cdn.jsdelivr.net/gh/ColonelParrot/jscanify@master/src/jscanify.min.js"></script>
</head>
<body>
<img src="images.png" id="image" />
<script src="./index.js"> </script>
</body>
</html>
const scanner = new jscanify();
image.onload = function () {
const highlightedCanvas = scanner.highlightPaper(image);
document.body.appendChild(highlightedCanvas);
};
from jscanify.
Does the example only work with white paper?
No, if the contrast between the paper and the background is enough, it should also detect it. Detection is always based on contrast, not color.
from jscanify.
hmm, when I run this code, the final highlighted image does not appear.
Any errors in the console?
from jscanify.
from jscanify.
It takes longer to load jscanify
than it takes to load your image - you have to ensure that OpenCV.js has loaded.
To ensure both have loaded, wrap your code in a load
event listener.
Like so:
window.addEventListener("load", function() {
const scanner = new jscanify();
const highlightedCanvas = scanner.highlightPaper(image);
document.body.appendChild(highlightedCanvas);
});
Although technically if this were the issue there would be an error in the console.
from jscanify.
Related Issues (20)
- Documentation implies findPaperContour takes HTML image input HOT 1
- There is no support for Typescript :( HOT 3
- Do you have the document detection in real time while using the camera to get the photo through MediaCapture API ? HOT 5
- WebRTC is very complicated for photos HOT 5
- Any way to use this library in Angular? HOT 3
- [ Demo Vison ] Update to work with User Input image HOT 1
- IOS Compatibility HOT 27
- Improvements to the recognition algorithm
- Poor Image Quality HOT 7
- Fails to install with Python 3.12 HOT 1
- extractPaper not working with cluttered background HOT 2
- Size Ratio for exported canvas. HOT 5
- cv.approxPolyDP maxContour. HOT 2
- Error importing jscanify library in React application HOT 2
- Passing a number "-1" from JS side to C/C++ side to an argument of type "unsigned long" HOT 1
- Calling getCornerPoints throws an Uncaught (in promise) 23302432 HOT 2
- React js import support? HOT 3
- Doesn't work in web (React) HOT 3
- Does not work inside vue.js or nuxt project HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jscanify.