Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
psenough committed May 6, 2012
0 parents commit 8d15f7b
Show file tree
Hide file tree
Showing 176 changed files with 16,769 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,12 @@
*.depend
*.layout
*.mode*v3
*.pbxuser
*.app*
*.DS_*

.svn/
obj/
bin/
build/
!data/
106 changes: 106 additions & 0 deletions src/Result.cpp
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,106 @@
#include "Result.h"

namespace ofxZxing {

Result::Result() :
found(false) {
}

Result::Result(string text, vector<ofVec2f> points) :
found(true), text(text), points(points) {
if(points.size() > 1) {
screenNormal = points[1] - points[0];
}
if(points.size() > 2) {
center = (points[0] + points[2]) / 2;
}
screenSize = screenNormal.length();
}

void drawTextBox(string text, ofVec2f position, ofColor fgColor = ofColor::white, ofColor bgColor = ofColor::black) {
ofPushStyle();

int border = 4;
ofSetColor(bgColor);
ofRect(
(int) position.x - border,
(int) position.y - 4 - border,
text.length() * 8 + (border * 2),
8 + (border * 2));

ofSetColor(fgColor);
ofDrawBitmapString(text, position);

ofPopStyle();
}

void Result::draw() {
ofPushStyle();

ofSetColor(ofColor::red);
ofSetLineWidth(3);

#ifdef OF_IPHONE

GLfloat triVertices[points.size()*2];

for(int i = 0; i < points.size(); i++) {
triVertices[i] = points[i].x;
triVertices[i+1] = points[i].y;
}

glEnableClientState(GL_VERTEX_ARRAY);

glVertexPointer(3, GL_FLOAT, 0, triVertices);
glDrawArrays(GL_TRIANGLES, 0, 3);

glDisableClientState(GL_VERTEX_ARRAY);

#elseif


glBegin(GL_LINE_LOOP);
for(int i = 0; i < points.size(); i++) {
glVertex2f(points[i].x, points[i].y);
}
glEnd();

#endif
for(int i = 0; i < points.size(); i++) {
drawTextBox(ofToString(i), points[i]);
}

drawTextBox(text, center);

ofPopStyle();
}

bool Result::getFound() const {
return found;
}

string Result::getText() const {
return text;
}

vector<ofVec2f>& Result::getPoints() {
return points;
}

ofVec2f Result::getScreenPosition() const {
return center;
}

ofVec2f Result::getScreenNormal() const {
return screenNormal;
}

float Result::getScreenSize() const {
return screenSize;
}

float Result::getRotation(ofVec2f relativeTo) const {
return relativeTo.angle(screenNormal);
}

}
38 changes: 38 additions & 0 deletions src/Result.h
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,38 @@
#pragma once

#include "ofMain.h"

namespace ofxZxing {

class Result {
public:
Result();
Result(string text, vector<ofVec2f> points);

void draw();

bool getFound() const;
string getText() const;
vector<ofVec2f>& getPoints();

ofVec2f getScreenPosition() const;
ofVec2f getScreenNormal() const;
float getScreenSize() const;
float getRotation(ofVec2f relativeTo = ofVec2f(0, -1)) const;

/*
// these would be nice:
ofVec3f getRealPosition(float physicalSize) const;
ofVec3f getRealNormal(float physicalSize) const;
*/

protected:
bool found;
string text;
vector<ofVec2f> points;
ofVec2f center;
ofVec2f screenNormal;
float screenSize;
};

}
36 changes: 36 additions & 0 deletions src/include/zxing/BarcodeFormat.cpp
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,36 @@
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
/*
* Created by Christian Brunschen on 13/05/2008.
* Copyright 2008 ZXing authors All rights reserved.
*
* 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.
*/

#include <zxing/BarcodeFormat.h>

namespace zxing {

const char *barcodeFormatNames[] = {
"None",
"QR_CODE",
"DATA_MATRIX",
"UPC_E",
"UPC_A",
"EAN_8",
"EAN_13",
"CODE_128",
"CODE_39",
"ITF"
};

}
42 changes: 42 additions & 0 deletions src/include/zxing/BarcodeFormat.h
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef __BARCODE_FORMAT_H__
#define __BARCODE_FORMAT_H__

/*
* BarcodeFormat.h
* zxing
*
* Copyright 2010 ZXing authors All rights reserved.
*
* 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.
*/

namespace zxing {

typedef enum BarcodeFormat {
BarcodeFormat_None = 0,
BarcodeFormat_QR_CODE,
BarcodeFormat_DATA_MATRIX,
BarcodeFormat_UPC_E,
BarcodeFormat_UPC_A,
BarcodeFormat_EAN_8,
BarcodeFormat_EAN_13,
BarcodeFormat_CODE_128,
BarcodeFormat_CODE_39,
BarcodeFormat_ITF
} BarcodeFormat;

/* if you update the enum, please update the name in BarcodeFormat.cpp */
extern const char *barcodeFormatNames[];
}

#endif // __BARCODE_FORMAT_H__
37 changes: 37 additions & 0 deletions src/include/zxing/Binarizer.cpp
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,37 @@
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
/*
* Binarizer.cpp
* zxing
*
* Created by Ralf Kistner on 16/10/2009.
* Copyright 2008 ZXing authors All rights reserved.
* Modified by Lukasz Warchol on 02/02/2010.
*
* 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.
*/

#include <zxing/Binarizer.h>

namespace zxing {

Binarizer::Binarizer(Ref<LuminanceSource> source) : source_(source) {
}

Binarizer::~Binarizer() {
}

Ref<LuminanceSource> Binarizer::getLuminanceSource() const {
return source_;
}

}
46 changes: 46 additions & 0 deletions src/include/zxing/Binarizer.h
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef BINARIZER_H_
#define BINARIZER_H_

/*
* Binarizer.h
* zxing
*
* Copyright 2010 ZXing authors All rights reserved.
*
* 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.
*/

#include <zxing/LuminanceSource.h>
#include <zxing/common/BitArray.h>
#include <zxing/common/BitMatrix.h>
#include <zxing/common/Counted.h>

namespace zxing {

class Binarizer : public Counted {
private:
Ref<LuminanceSource> source_;

public:
Binarizer(Ref<LuminanceSource> source);
virtual ~Binarizer();

virtual Ref<BitArray> getBlackRow(int y, Ref<BitArray> row) = 0;
virtual Ref<BitMatrix> getBlackMatrix() = 0;

Ref<LuminanceSource> getLuminanceSource() const ;
virtual Ref<Binarizer> createBinarizer(Ref<LuminanceSource> source) = 0;
};

}
#endif /* BINARIZER_H_ */
67 changes: 67 additions & 0 deletions src/include/zxing/BinaryBitmap.cpp
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* BinaryBitmap.cpp
* zxing
*
* Copyright 2010 ZXing authors All rights reserved.
*
* 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.
*/

#include <zxing/BinaryBitmap.h>

namespace zxing {

BinaryBitmap::BinaryBitmap(Ref<Binarizer> binarizer) : binarizer_(binarizer) {

}

BinaryBitmap::~BinaryBitmap() {
}

Ref<BitArray> BinaryBitmap::getBlackRow(int y, Ref<BitArray> row) {
return binarizer_->getBlackRow(y, row);
}

Ref<BitMatrix> BinaryBitmap::getBlackMatrix() {
return binarizer_->getBlackMatrix();
}

int BinaryBitmap::getWidth() const {
return getLuminanceSource()->getWidth();
}

int BinaryBitmap::getHeight() const {
return getLuminanceSource()->getHeight();
}

Ref<LuminanceSource> BinaryBitmap::getLuminanceSource() const {
return binarizer_->getLuminanceSource();
}


bool BinaryBitmap::isCropSupported() const {
return getLuminanceSource()->isCropSupported();
}

Ref<BinaryBitmap> BinaryBitmap::crop(int left, int top, int width, int height) {
return Ref<BinaryBitmap> (new BinaryBitmap(binarizer_->createBinarizer(getLuminanceSource()->crop(left, top, width, height))));
}

bool BinaryBitmap::isRotateSupported() const {
return getLuminanceSource()->isRotateSupported();
}

Ref<BinaryBitmap> BinaryBitmap::rotateCounterClockwise() {
return Ref<BinaryBitmap> (new BinaryBitmap(binarizer_->createBinarizer(getLuminanceSource()->rotateCounterClockwise())));
}
}
Loading

0 comments on commit 8d15f7b

Please sign in to comment.