• «
  • 1
  • 2
  • »
  • Pages: 1/2     Go
主题 : tiny210+USB摄像头,二维码无法识别,程序报错。 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 76041
精华: 0
发帖: 10
金钱: 50 两
威望: 10 点
综合积分: 20 分
注册时间: 2012-08-17
最后登录: 2013-03-25
楼主  发表于: 2012-09-24 19:01

 tiny210+USB摄像头,二维码无法识别,程序报错。

我目前采购了tiny210,准备用android4.0+摄像头识别二维码。

目前我用的是市场上购买的usb摄像头,包括普通的定焦摄像头,罗技的变焦摄像头。
插入摄像头启动后,打开照相程序能看到摄像头画面,但画面明显变形,颜色为黑白家局部红绿小色块。
启动我查查、淘宝等程序扫描二维码,都无法完成,淘宝报设备不支持二维码识别,我查查没有任何反应。
加载zXing二维码程序,跟踪问题。确认是原始输入的图像格式比较特殊,二维码程序无法识别。

PixelFormat定义见附件。

================

/** 图像解码程序
* A factory method to build the appropriate LuminanceSource object based on
* the format of the preview buffers, as described by Camera.Parameters.
*
* @param data
*            A preview frame.
* @param width
*            The width of the image.
* @param height
*            The height of the image.
* @return A PlanarYUVLuminanceSource instance.
*/
public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data,
int width, int height) {
Rect rect = getFramingRectInPreview();
int previewFormat = configManager.getPreviewFormat();
String previewFormatString = configManager.getPreviewFormatString();
switch (previewFormat) {
// This is the standard Android format which all devices are REQUIRED to
// support.
// In theory, it's the only one we should ever care about.
case PixelFormat.YCbCr_420_SP:
// This format has never been seen in the wild, but is compatible as
// we only care
// about the Y channel, so allow it.
case PixelFormat.YCbCr_422_SP:
return new PlanarYUVLuminanceSource(data, width, height, rect.left,
rect.top, rect.width(), rect.height());
default:
// The Samsung Moment incorrectly uses this variant instead of the
// 'sp' version.
// Fortunately, it too has all the Y data up front, so we can read
// it.
if ("yuv420p".equals(previewFormatString)) {
return new PlanarYUVLuminanceSource(data, width, height,
rect.left, rect.top, rect.width(), rect.height());
}
}
throw new IllegalArgumentException("Unsupported picture format: "
+ previewFormat + '/' + previewFormatString);
}
-=========================

int previewFormat = configManager.getPreviewFormat();

previewFormat 的值为:
public static final int YCbCr_422_I = 0x14;

解码程序并没有对此编码做处理。
=============================
这个是否和摄像头有关系,如果用CAM130摄像头能行吗?
或者是平台的问题,有什么解决办法?多谢!
级别: 新手上路
UID: 76041
精华: 0
发帖: 10
金钱: 50 两
威望: 10 点
综合积分: 20 分
注册时间: 2012-08-17
最后登录: 2013-03-25
1楼  发表于: 2012-09-24 19:05
PixelFormat 定义文件:
==============================
* Copyright (C) 2006 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.graphics;

public class PixelFormat
{
    /* these constants need to match those
       in ui/PixelFormat.h & pixelflinger/format.h */
   
    public static final int UNKNOWN     = 0;

    /** System chooses a format that supports translucency (many alpha bits) */
    public static final int TRANSLUCENT = -3;

    /**
     * System chooses a format that supports transparency
     * (at least 1 alpha bit)
     */   
    public static final int TRANSPARENT = -2;

    /** System chooses an opaque format (no alpha bits required) */
    public static final int OPAQUE      = -1;

    public static final int RGBA_8888   = 1;
    public static final int RGBX_8888   = 2;
    public static final int RGB_888     = 3;
    public static final int RGB_565     = 4;

    public static final int RGBA_5551   = 6;
    public static final int RGBA_4444   = 7;
    public static final int A_8         = 8;
    public static final int L_8         = 9;
    public static final int LA_88       = 0xA;
    public static final int RGB_332     = 0xB;
   
    /**
     * YCbCr formats, used for video. These are not necessarily supported
     * by the hardware.
     */
    public static final int YCbCr_422_SP= 0x10;

    /** YCbCr format used for images, which uses the NV21 encoding format.  
     *  This is the default format for camera preview images, when not
     *  otherwise set with
     *  {@link android.hardware.Camera.Parameters#setPreviewFormat(int)}.
     */
    public static final int YCbCr_420_SP= 0x11;

    /** YCbCr format used for images, which uses YUYV (YUY2) encoding format.
     *  This is an alternative format for camera preview images. Whether this
     *  format is supported by the camera hardware can be determined by
     *  {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}.
     */
    public static final int YCbCr_422_I = 0x14;

    /**
     * Encoded formats.  These are not necessarily supported by the hardware.
     */
    public static final int JPEG        = 0x100;

    /*
     * We use a class initializer to allow the native code to cache some
     * field offsets.
     */
    native private static void nativeClassInit();
    static { nativeClassInit(); }

    public static native void getPixelFormatInfo(int format, PixelFormat info);
    public static boolean formatHasAlpha(int format) {
        switch (format) {
            case PixelFormat.A_8:
            case PixelFormat.LA_88:
            case PixelFormat.RGBA_4444:
            case PixelFormat.RGBA_5551:
            case PixelFormat.RGBA_8888:
            case PixelFormat.TRANSLUCENT:
            case PixelFormat.TRANSPARENT:
                return true;
        }
        return false;
    }
   
    public int  bytesPerPixel;
    public int  bitsPerPixel;
}
自由,自强,共享,共创。
级别: 论坛版主
UID: 12573
精华: 27
发帖: 8838
金钱: 46490 两
威望: 9298 点
综合积分: 18216 分
注册时间: 2010-01-09
最后登录: 2019-07-16
2楼  发表于: 2012-09-24 20:17
下载最新光盘试试吧
新手如何向我们反馈有效的信息,以便解决问题,见此贴:
http://www.arm9home.net/read.php?tid-14431.html

[注]: 此处签名链接仅为指引方向,而非解答问题本身.
级别: 新手上路
UID: 76041
精华: 0
发帖: 10
金钱: 50 两
威望: 10 点
综合积分: 20 分
注册时间: 2012-08-17
最后登录: 2013-03-25
3楼  发表于: 2012-09-25 12:51
图片:
图片:
已经下载最新的0913版本安装,摄像头还是异常。

请看截图
级别: 荣誉会员
UID: 34761
精华: 0
发帖: 1348
金钱: 6835 两
威望: 1367 点
综合积分: 2696 分
注册时间: 2010-12-21
最后登录: 2017-06-02
4楼  发表于: 2012-09-25 16:46
Android2.3能正常吗
级别: 新手上路
UID: 76041
精华: 0
发帖: 10
金钱: 50 两
威望: 10 点
综合积分: 20 分
注册时间: 2012-08-17
最后登录: 2013-03-25
5楼  发表于: 2012-09-25 18:38

 回 4楼(hacker) 的帖子

Android2.3 也不能用,提示“Please mount USB storage before using the camera”。
级别: 新手上路
UID: 79973
精华: 0
发帖: 21
金钱: 105 两
威望: 21 点
综合积分: 42 分
注册时间: 2012-10-17
最后登录: 2013-04-02
6楼  发表于: 2012-10-29 10:53
请问楼主问题解决了吗,我也想做二维码识读,能不能分享一下经验呢
级别: 侠客
UID: 80305
精华: 0
发帖: 91
金钱: 460 两
威望: 92 点
综合积分: 182 分
注册时间: 2012-10-22
最后登录: 2017-09-13
7楼  发表于: 2012-10-29 19:53
二维码识读,嗯,好主意
级别: 新手上路
UID: 80809
精华: 0
发帖: 3
金钱: 15 两
威望: 3 点
综合积分: 6 分
注册时间: 2012-10-30
最后登录: 2012-11-08
8楼  发表于: 2012-11-06 14:50
请问 买他们推荐的 罗技C270 回来就是这个图像效果啊,真令人无语!!!!
级别: 侠客
UID: 19993
精华: 0
发帖: 134
金钱: 675 两
威望: 135 点
综合积分: 268 分
注册时间: 2010-04-26
最后登录: 2024-07-11
9楼  发表于: 2012-11-13 11:26
解决了吗
  • «
  • 1
  • 2
  • »
  • Pages: 1/2     Go