Skip to content

Commit

Permalink
new ep
Browse files Browse the repository at this point in the history
  • Loading branch information
realtux committed Aug 22, 2021
1 parent db2917c commit f855940
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
Binary file added 143/code.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions 143/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"axios": "*"
}
}
38 changes: 38 additions & 0 deletions 143/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const util = require('util');
const fs = require('fs/promises');
const exec = util.promisify(require('child_process').exec);
const axios = require('axios');

(async () => {
// capture frame
// await exec(
// 'ffmpeg -y -f video4linux2 -s 1280x720 ' +
// '-i /dev/video1 -frames 1 code.jpg'
// );

// convert to base 64
const image = await fs.readFile('code.jpg');
const base64 = image.toString('base64');

const url =
`https://vision.googleapis.com/v1/images:annotate` +
`?key=${process.env.gkey}`;

// send to vision api
const results = await axios
.post(url, {
requests: [{
image: {
content: base64
},
features: [{
type: 'DOCUMENT_TEXT_DETECTION'
}]
}]
});

const code = results.data.responses[0].fullTextAnnotation.text;

console.log(code);
//eval(code);
})();

0 comments on commit f855940

Please sign in to comment.