本文介绍了在ActionScript 3比较两个BitmapData的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有反正我可以比较两个BitmapData并获得了相似率(知道怎么极为相象,他们都是)。我已经做了一些研究和碰到bitmapData.compare(otherBmd),但只返回,如果他们的大小,或像素不同,不是他们有多么的不同。

I'd like to know if there's anyway I can compare two BitmapData and get a "similarity percentage" (knowing how look-alike they are).I've done a bit of research and came across bitmapData.compare(otherBmd), but that only returns if they differ in size, or pixel, and not how much they differ.

这点是比较一些BMD通过与图书馆图像的照相机获得的(所以这是我至今):

The point of this was to compare some Bmd obtained through a camera with a library image (so this is what I got so far):

import flash.display.Bitmap;
import flash.display.BitmapData;

var img1:BitmapData = new monaLisa();

var cam:Camera = Camera.getCamera();
var video:Video = new Video(camMock.width,camMock.height);
video.attachCamera(cam);
video.x=camMock.x;
video.y=camMock.y;
addChild(video);

var pic:BitmapData = new BitmapData(video.width,video.height);

var picBmp:Bitmap = new Bitmap(pic);
picBmp.x = camMock.x;
picBmp.y = camMock.y;

captureCam.buttonMode = true;
captureCam.addEventListener(MouseEvent.CLICK,captureImage);

function captureImage(e:MouseEvent):void {
    pic.draw(video);
    trace(pic.compare(img1));
    //compare two bmd
        //do x
}

此外,请裸跟我来。我的的新秀。

推荐答案

不到一个百分点,但它应该返回一个新的BitmapData objec,你可以指定为图像。
BitMapData.compare()

Not a percentage but it should return a new BitMapData objec that you could assign as an image.
BitMapData.compare( )

返回    对象 - 如果两个BitmapData对象相同的尺寸(宽度和高度),该方法返回一个新的BitmapData对象,它有两个对象之间的差异(请参阅主要讨论内容)。如果BitmapData对象相同,则该方法返回数字0。如果这两个BitmapData对象的宽度不相等,则该方法返回数字-3。如果BitmapData对象的高度不相等,则该方法返回数字-4。

Returns Object — If the two BitmapData objects have the same dimensions (width and height), the method returns a new BitmapData object that has the difference between the two objects (see the main discussion). If the BitmapData objects are equivalent, the method returns the number 0. If the widths of the BitmapData objects are not equal, the method returns the number -3. If the heights of the BitmapData objects are not equal, the method returns the number -4.

这篇关于在ActionScript 3比较两个BitmapData的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 10:03