⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 horizontalflip.java~1~

📁 能够检测到人脸
💻 JAVA~1~
字号:
package visage_v3_1;import javax.media.*;import javax.media.format.*;import java.awt.*;/*  This class flipps the video stream horizontally.  ALL THE CODE WRITTEN HERE IS TAKEN FROM SUN'S 'RotationEffect' CODE SAMPLE, SLIGHT MODIFICATIONS WHERE MADE.  "THE MODIFICATIONS INCLUDE OVERRIDING THE 'process' FUNCTION SO IT'LL FLIP THE VIDEO STREAM".*/public class HorizontalFlip implements Effect {    Format inputFormat;    Format outputFormat;    Format formats[];    byte outData[];    public HorizontalFlip(CaptureDeviceInfo cdi)    {       formats = cdi.getFormats();       outData = new byte[320*240*3];    }    ///////////////////////////////    public int process(Buffer inBuffer, Buffer outBuffer)    {      byte[] inData = (byte[]) inBuffer.getData();      int pos;      for (int y = 0; y < 240; y++) //copy the bytes in reverse in each line of the frame      {        for (int x = 0; x < 960; x += 3)        {          pos = x;          outData[y * 960 + pos] = inData[y * 960 + (960 - x - 3)];          pos++;          outData[y * 960 + pos] = inData[y * 960 + (960 - x - 2)];          pos++;          outData[y * 960 + pos] = inData[y * 960 + (960 - x - 1)];        }      }      outBuffer.setData(outData);      // Copy the input attributes to the output      outBuffer.setFormat(inBuffer.getFormat());      outBuffer.setLength(inBuffer.getLength());      outBuffer.setOffset(inBuffer.getOffset());      return BUFFER_PROCESSED_OK;    }    //////////////////////////////    //methods for interface : Codec    public Format[] getSupportedInputFormats()    {        return formats;    }    public Format [] getSupportedOutputFormats(Format input)    {        if (input == null)        {          System.out.println("getSupportedOutputFormats input == null");          return formats;        }        if (matches(input, formats) != null)          return new Format[] { formats[0].intersects(input) };        else          return new Format[0];    }    public Format setInputFormat(Format input)    {        inputFormat = input;        return input;    }    public Format setOutputFormat(Format output)    {        if (output == null || matches(output, formats) == null)            return null;        RGBFormat incoming = (RGBFormat)output;        Dimension size = incoming.getSize();        int maxDataLength = incoming.getMaxDataLength();        int lineStride = incoming.getLineStride();        float frameRate = incoming.getFrameRate();        int flipped = incoming.getFlipped();        int endian = incoming.getEndian();        if (size == null)            return null;        if (maxDataLength < size.width * size.height * 3)            maxDataLength = size.width * size.height * 3;        if (lineStride < size.width * 3)            lineStride = size.width * 3;        if (flipped != Format.FALSE)            flipped = Format.FALSE;        outputFormat = formats[0].intersects(new RGBFormat(size,                                                        maxDataLength,                                                        null,                                                        frameRate,                                                        Format.NOT_SPECIFIED,                                                        Format.NOT_SPECIFIED,                                                        Format.NOT_SPECIFIED,                                                        Format.NOT_SPECIFIED,                                                        Format.NOT_SPECIFIED,                                                        lineStride,                                                        Format.NOT_SPECIFIED,                                                        Format.NOT_SPECIFIED));        return outputFormat;    }    //methods for interface : PlugIn    public String getName() {        return "Process Effect";    }    public void open() {    }    public void close() {    }    public void reset() {    }    //methods for interface : javax.media.Controls    public Object getControl(String controlType) {        return null;    }    public Object[] getControls() {        return null;    }    //Utility methods    Format matches(Format in, Format outs[])    {      for (int i = 0; i < outs.length; i++)      {        if (in.matches(outs[i]))          return outs[i];      }      return null;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -