欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

nude.js:使用 JavaScript 进行裸体检测 - 使用 nude.js(使用 nude.js)

最编程 2024-07-02 21:46:19
...

Start by adding nude.js adding your images to the page as usual:

首先添加nude.js,像往常一样将图像添加到页面:


<!-- No canvas for IE, so download it and include it for IE -->
<!--[if IE]>
<script type="text/javascript" src="excanvas_r3/excanvas.compiled.js"></script>	
<![endif]-->
<script src="nude.js/compressed/nude.min.js"></script>

<!-- images to check -->
<img src="dvt1.jpg" alt="Dita Von Tease" id="image1" onclick="onImageClick('image1');" />
<img src="dvt2.jpg" alt="Dita Von Tease" id="image2" onclick="onImageClick('image2');" />
<img src="dvt3.jpg" alt="Dita Von Tease" id="image3" onclick="onImageClick('image3');" />
<img src="dvt4.jpg" alt="Dita Von Tease" id="image4" onclick="onImageClick('image4');" />


Using nude.js is simple because there are only two methods to use:  <code>load</code> and <code>scan</code>.  The <code>load</code> method takes the element <code>id</code> or element itself and draws a canvas image based on the original image.  The <code>scan</code> method runs the algorithm on the canvas image data, returning <code>true</code> or <code>false</code>.

使用nude.js很简单,因为只有两种方法可以使用:<code> load </ code>和<code> scan </ code>。 <code> load </ code>方法采用元素<code> id </ code>或元素本身,并基于原始图像绘制画布图像。 <code> scan </ code>方法在画布图像数据上运行该算法,并返回<code> true </ code>或<code> false </ code>。


function onImageClick(node) {
	nude.load(node);
	// Scan it
	nude.scan(function(result){ 
		alert(result ? "Nudity found in " + node.id + "!" : "Not nude");
	});
}


As you can imagine, the process can be taxing on your browser so don't expect an immediate result.  The size of the image is an obvious consideration.  If you rely heavily on nude.js, be aware that your large images could be problematic.

可以想象,该过程可能会增加浏览器的负担,因此不要期望立即得到结果。 图像的大小是显而易见的考虑因素。 如果您严重依赖nude.js,请注意您的大图像可能会出现问题。