Android Open Source - AsciiCamera Camera Preview Processing Queue






From Project

Back to project page AsciiCamera.

License

The source code is released under:

Apache License

If you think the Android project AsciiCamera listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

// Copyright (C) 2014 Bruno Ramalhete
/*from w w  w .j  a  v a2 s .c  o  m*/
package com.spectralsoftware.util;

/**
 * Specialized wrapper around SingleItemProcessingQueue for the purpose of processing camera preview images.
 */
public class CameraPreviewProcessingQueue {
    
    public static interface Processor {
        // Called in a separate thread to process a camera preview image
        public abstract void processCameraImage(byte[] data, int width, int height);
    }
    
    static class CameraPreviewImage {
        final byte[] data;
        final int width;
        final int height;
        
        public CameraPreviewImage(byte[] data, int width, int height) {
            this.data = data;
            this.width = width;
            this.height = height;
        }
    }
    
    SingleItemProcessingQueue<CameraPreviewImage> processingQueue = new SingleItemProcessingQueue<CameraPreviewImage>();

    /** Called by camera preview callback method when a frame is received.
     */
    public void processImageData(byte[] data, int width, int height) {
        processingQueue.queueData(new CameraPreviewImage(data, width, height));
    }
    
    public void start(final Processor imageProcessor) {
        processingQueue.start(new SingleItemProcessingQueue.Processor<CameraPreviewImage>() {
            @Override public void processData(CameraPreviewImage data) {
                imageProcessor.processCameraImage(data.data, data.width, data.height);
            }
        });
    }
    
    public void stop() {
        processingQueue.stop();
    }
    
    public void pause() {
        processingQueue.pause();
    }
    
    public void unpause() {
        processingQueue.unpause();
    }
}




Java Source Code List

com.spectralsoftware.asciicamera.AboutActivity.java
com.spectralsoftware.asciicamera.AsciiCamActivity.java
com.spectralsoftware.asciicamera.AsciiCamPreferences.java
com.spectralsoftware.asciicamera.AsciiConverter.java
com.spectralsoftware.asciicamera.AsciiImageWriter.java
com.spectralsoftware.asciicamera.AsciiRenderer.java
com.spectralsoftware.asciicamera.ImageDirectory.java
com.spectralsoftware.asciicamera.LibraryActivity.java
com.spectralsoftware.asciicamera.NewPictureReceiverLegacyBroadcast.java
com.spectralsoftware.asciicamera.NewPictureReceiver.java
com.spectralsoftware.asciicamera.OverlayView.java
com.spectralsoftware.asciicamera.ProcessImageOperation.java
com.spectralsoftware.asciicamera.ViewImageActivity.java
com.spectralsoftware.util.ARManager.java
com.spectralsoftware.util.AndroidUtils.java
com.spectralsoftware.util.AsyncImageLoader.java
com.spectralsoftware.util.CameraPreviewProcessingQueue.java
com.spectralsoftware.util.CameraUtils.java
com.spectralsoftware.util.ScaledBitmapCache.java
com.spectralsoftware.util.ShutterButton.java
com.spectralsoftware.util.SingleItemProcessingQueue.java