This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function capture() { | |
var frame = wCap.read() | |
if (frame.empty) { | |
wCap.reset(); | |
frame = wCap.read(); | |
} | |
dbr.decodeBufferAsync(frame.getData(), frame.cols, frame.rows, frame.step, barcodeTypes, function (err, msg) { | |
// console.log(results) | |
results = msg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (results != null) { | |
for (index in results) { | |
let result = results[index]; | |
let upperLeft = new cv.Point(result.x1, result.y1) | |
let bottomLeft = new cv.Point(result.x2, result.y2) | |
let upperRight = new cv.Point(result.x3, result.y3) | |
let bottomRight = new cv.Point(result.x4, result.y4) | |
img.drawLine( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const dbr = require('barcode4nodejs'); | |
const cv = require('opencv4nodejs'); | |
dbr.initLicense("LICENSE-KEY") | |
barcodeTypes = dbr.barcodeTypes | |
const vCap = new cv.VideoCapture(0); | |
const drawParams = { color: new cv.Vec(0, 255, 0), thickness: 2 } | |
const fontFace = cv.FONT_HERSHEY_SIMPLEX; | |
const fontScale = 0.5; | |
const textColor = new cv.Vec(255, 0, 0); | |
const thickness = 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void DecodeBufferAsync(const FunctionCallbackInfo<Value>& args) { | |
if (!createDBR()) {return;} | |
Isolate* isolate = Isolate::GetCurrent(); | |
Local<Context> context = isolate->GetCurrentContext(); | |
// get arguments | |
unsigned char* buffer = (unsigned char*) node::Buffer::Data(args[0]); // file stream | |
int width = args[1]->Int32Value(context).ToChecked(); // image width | |
int height = args[2]->Int32Value(context).ToChecked(); // image height | |
int stride = args[3]->Int32Value(context).ToChecked(); // stride |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func handler(w http.ResponseWriter, r *http.Request) { | |
if r.URL.Path == "/" { | |
pageData := "<!DOCTYPE>" + | |
"<html>" + | |
" <head>" + | |
" <title>HttpListener Example</title>" + | |
" </head>" + | |
" <body>" + | |
"<img id=\"image\"/>" + | |
" <script type=\"text/javascript\">var image = document.getElementById('image');function refresh() {image.src = \"/image?\" + new Date().getTime();image.onload= function(){setTimeout(refresh, 30);}}refresh();</script> " + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import http.server | |
import socketserver | |
class MyHandler(http.server.BaseHTTPRequestHandler): | |
def do_GET(self): | |
if self.path == '/': | |
self.send_response(200) | |
self.send_header("Content-type", "text/html") | |
self.end_headers() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Text; | |
using System.Net; | |
using System.Threading.Tasks; | |
using OpenCvSharp; | |
namespace Web | |
{ | |
class Program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
var server = http.createServer(function (req, res) { | |
if (req.url === '/' || req.url === '/index.htm') { | |
res.writeHead(200, { 'Content-Type': 'text/html' }); | |
res.write(html); | |
res.end(); | |
} | |
else if (req.url.startsWith("/image")) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title>Webcam</title> | |
</head> | |
<body> | |
<img id="image"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
cap = cv2.VideoCapture(0) | |
while True: | |
ret, frame = cap.read() | |
cv2.imshow("Webcam", frame) | |
if cv2.waitKey(1) & 0xFF == 27: # use ESC to quit | |
break | |