Obsolete unused backup project such as OK6410
guowenxue
2019-07-29 7fe273e8e8bd1ffd4735cb5d6f09ad8e58a39a96
add opencv-zbar source code
4 files added
124 ■■■■■ changed files
ok335xD/program/opencv-zbar/cvzbar.c 14 ●●●●● patch | view | raw | blame | history
ok335xD/program/opencv-zbar/decoder.cpp 64 ●●●●● patch | view | raw | blame | history
ok335xD/program/opencv-zbar/decoder.h 19 ●●●●● patch | view | raw | blame | history
ok335xD/program/opencv-zbar/makefile 27 ●●●●● patch | view | raw | blame | history
ok335xD/program/opencv-zbar/cvzbar.c
New file
@@ -0,0 +1,14 @@
#include<stdio.h>
#include"decoder.h"
int main()
{
    struct code_msg msg;
    if(decoder(0,&msg)<0)
        return -1;
    printf("type:%s\n",msg.get_type_name);
    printf("data:%s\n",msg.get_data);
    return 0;
}
ok335xD/program/opencv-zbar/decoder.cpp
New file
@@ -0,0 +1,64 @@
#include<string.h>
#include<iostream>
#include<opencv2/core.hpp>
#include<opencv2/highgui.hpp>
#include<opencv2/imgproc.hpp>
#include<zbar.h>
#include"decoder.h"
using namespace std;
using namespace cv;
using namespace zbar;
int decoder(int carame_num,struct code_msg* code_msg)
{
    Mat image;
    VideoCapture capture(carame_num);
    int flag = 0;
    if(!capture.isOpened())
    {
        cout<<"Open Camera failure"<<endl;
        return -1;
    }
    cout << "Open Camera ok"<<endl;
    while(!flag)
    {
        capture >> image;//读取视频帧
        if(!image.empty())
        {
            cout << "Get video framer from camera"<<endl;
#if 0 //置1打开图形窗口进行对焦等操作
            imshow("source",image);
#endif
            cvtColor(image,image,CV_RGB2GRAY);//灰度图
        //    imshow("imageGray",image);
        //    cout << "灰度图转换成功"<<endl;
            //zbar解码
            int width = image.cols;
            int heigth = image.rows;
            uchar *raw = (uchar *)image.data;
            Image imagezbar(width,heigth,"Y800",raw,width*heigth);
            ImageScanner scanner;
            scanner.scan(imagezbar);
            Image::SymbolIterator symbol = imagezbar.symbol_begin();
            for(;symbol != imagezbar.symbol_end();++symbol)//解码成功
            {
                //cout << "type:" <<symbol->get_type_name()<<endl;
                strcpy(code_msg->get_type_name,symbol->get_type_name().c_str());
                //cout << "data:" <<symbol->get_data()<<endl;
                strcpy(code_msg->get_data,symbol->get_data().c_str());
                flag = 1;
            }
        }
        //if(waitKey(10) == 0x0d)
        //    break;
    }
    return 0;
}
ok335xD/program/opencv-zbar/decoder.h
New file
@@ -0,0 +1,19 @@
#ifndef _DECODER_H_
#define _DECODER_H_
struct code_msg{
    char get_type_name[10];
    char get_data[20];
};
#ifdef __cplusplus
extern "C"{
#endif
int decoder(int carame_num,struct code_msg* code_msg);
#ifdef __cplusplus
}
#endif
#endif
ok335xD/program/opencv-zbar/makefile
New file
@@ -0,0 +1,27 @@
APPNAME=cvzbar
CROSSTOOL=/opt/crosstool/cortex-a7/bin/arm-linux-gnueabi-
GPP=${CROSSTOOL}g++
GCC=${CROSSTOOL}gcc
PRJ_PATH=${shell pwd}
LIBS_PATH=${PRJ_PATH}/../../3rdparty/install
OPENCV_PKGCONFIG=${LIBS_PATH}/lib/pkgconfig
CPPFLAGS = `export PKG_CONFIG_PATH=${OPENCV_PKGCONFIG} && pkg-config --cflags --libs opencv`
CFLAGS+=-I${LIBS_PATH}/include
LDFLAGS=-L${LIBS_PATH}/lib -lzbar -liconv
all:
    echo $PKG_CONFIG_PATH
    ${GPP} ${CFLAGS} -c decoder.cpp -o decoder.o $(CPPFLAGS) -Wall
    ${GCC} -c cvzbar.c -Wall
    ${GPP} decoder.o cvzbar.o -o ${APPNAME} $(CPPFLAGS) -lstdc++ ${LDFLAGS}
    cp ${APPNAME} /tftp
clean:
    rm -f *.o ${APPNAME}
distclean: clean
    rm -f cscope* tags