0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

opencv.jsの作法 その10

Posted at

概要

opencv.jsの作法を調べてみた。
間違い探し、やってみた。

参考にしたページ

写真

無題.jpg

サンプルコード

var cvs0 = document.getElementById('canvasInput0');
var cvs1 = document.getElementById('canvasInput1');
var ctx0 = cvs0.getContext('2d');
var ctx1 = cvs1.getContext('2d');
var img1 = new Image();
img1.src = data1;
img1.onload = function() {
	ctx1.drawImage(img1, 0, 0);
}
var img0 = new Image();
img0.src = data0;
img0.onload = function() {
	ctx0.drawImage(img0, 0, 0);
	var src0 = cv.imread('canvasInput0');
	var src1 = cv.imread('canvasInput1');
	var dst = new cv.Mat();
  var imgDiff = new cv.Mat();
	var i;
	var j = 12;
  for (i = 0; i < src0.rows * src0.cols * 3 - j; i += 3)
	{
		src0.data[i] = src0.data[i + j];
	}
	var kernel = cv.matFromArray(3, 3, cv.CV_32FC1, [0.1111, 0.1111, 0.1111, 0.1111, 0.1112, 0.1111, 0.1111, 0.1111, 0.1111]);
	var anchor = new cv.Point(-1, -1);
	cv.filter2D(src0, src0, cv.CV_8U, kernel, anchor, 0, cv.BORDER_DEFAULT);
	cv.filter2D(src1, src1, cv.CV_8U, kernel, anchor, 0, cv.BORDER_DEFAULT);
	cv.absdiff(src0, src1, imgDiff);
	cv.bitwise_not(imgDiff, dst);
	cv.imshow('canvasOutput', dst);
	src0.delete();
	src1.delete();
  dst.delete();
}




成果物

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?