Permalink
Browse files

first commit, very alpha!

  • Loading branch information...
0 parents commit d4cc5f7b3ba30ad023e3e9e0a4e74ca75a129389 @badgeek committed Sep 26, 2011
Showing with 334 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +43 −0 Makefile
  3. +67 −0 fuxPixelsBitmapSource.cpp
  4. +29 −0 fuxPixelsBitmapSource.h
  5. +118 −0 fux_qrcode.cpp
  6. +75 −0 fux_qrcode.h
  7. BIN fux_qrcode.pd_darwin
  8. BIN libs/libzxing.a
@@ -0,0 +1,2 @@
+.svn
+.DS_Store
@@ -0,0 +1,43 @@
+# change to your local directories!
+PD_APP_DIR = /Applications/Pd-extended.app/Contents/Resources
+PD_DIR = /Users/xcorex/Documents/Documents/Projects/Puredata/PdSource/Pd-0.42.5-extended/pd
+GEM_DIR = /Users/xcorex/Documents/Documents/Projects/Puredata/PdSource/Pd-0.42.5-extended/Gem
+# build flags
+
+INCLUDES = -I$(PD_DIR)/include
+CPPFLAGS = -g -O2 -fPIC -freg-struct-return -Os -falign-loops=32 -falign-functions=32 -falign-jumps=32 -funroll-loops -ffast-math -arch i386 -mmmx -fpascal-strings
+
+UNAME := $(shell uname -s)
+ifeq ($(UNAME),Linux)
+ CPPFLAGS += -DLINUX
+ INCLUDES += `pkg-config --cflags libfreenect`
+ LDFLAGS = -export_dynamic -shared
+ LIBS = `pkg-config --libs libfreenect`
+ EXTENSION = pd_linux
+endif
+ifeq ($(UNAME),Darwin)
+ CPPFLAGS += -DDARWIN
+ INCLUDES += -I/sw/include -I$(GEM_DIR)/src -I$(PD_DIR)/src -I$(PD_DIR) -Izxing
+ LDFLAGS = -c -arch i386
+ LIBS = -lm
+ EXTENSION = pd_darwin
+endif
+
+.SUFFIXES = $(EXTENSION)
+
+SOURCES = fux_qrcode
+#OUTPUT = mesh_square
+
+all:
+ g++ $(LDFLAGS) $(INCLUDES) $(CPPFLAGS) -o fuxPixelsBitmapSource.o -c fuxPixelsBitmapSource.cpp
+ g++ $(LDFLAGS) $(INCLUDES) $(CPPFLAGS) -o $(SOURCES).o -c $(SOURCES).cpp
+ g++ -o $(SOURCES).$(EXTENSION) -arch i386 -dynamiclib -mmacosx-version-min=10.3 -undefined dynamic_lookup -framework QuickTime -framework Carbon -framework AGL -framework OpenGL -arch i386 ./*.o -L/sw/lib -lfreeimage -lstdc++ -ldl -lz -lm -lpthread -L$(PD_DIR)/bin -L$(PD_DIR) -L/Users/xcorex/Documents/Documents/Projects/Puredata/PdSource/External-Dev/fux_qrcode/libs -lzxing
+ rm -fr ./*.o
+deploy:
+ rm -fr $(PD_APP_DIR)/extra/$(SOURCES).$(EXTENSION)
+ mv *.$(EXTENSION) $(PD_APP_DIR)/extra/
+clean:
+ rm -f $(SOURCES)*.o
+ rm -f $(SOURCES)*.$(EXTENSION)
+distro: clean all
+ rm *.o
@@ -0,0 +1,67 @@
+#include "fuxPixelsBitmapSource.h"
+
+namespace zxing {
+
+fuxPixelsBitmapSource::fuxPixelsBitmapSource(imageStruct& pixels) : image_(pixels) {
+ width = pixels.xsize;
+ height = pixels.ysize;
+ pixel_cache = pixels.data;
+}
+
+fuxPixelsBitmapSource::~fuxPixelsBitmapSource() {
+
+}
+
+int fuxPixelsBitmapSource::getWidth() const {
+ return width;
+}
+
+int fuxPixelsBitmapSource::getHeight() const {
+ return height;
+}
+
+unsigned char* fuxPixelsBitmapSource::getRow(int y, unsigned char* row) {
+ if (row == NULL) {
+ row = new unsigned char[width];
+ }
+ for (int x = 0; x < width; x++) {
+ const unsigned char* p = &pixel_cache[4 * (y * width + x)];
+ *p++;
+ row[x] = (unsigned char)((
+ 306 * (int)(*p++) +
+ 601 * (int)(*p++) +
+ 117 * (int)(*p++) + 0x200) >> 10);
+ }
+ return row;
+
+}
+
+unsigned char* fuxPixelsBitmapSource::getMatrix() {
+ int width = getWidth();
+ int height = getHeight();
+ unsigned char* matrix = new unsigned char[width*height];
+ unsigned char* m = matrix;
+ const unsigned char* p = pixel_cache;
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ *p++;
+ *m= (unsigned char)((
+ 306 * (int)(*p++) +
+ 601 * (int)(*p++) +
+ 117 * (int)(*p++) + 0x200) >> 10);
+ m++;
+ }
+ }
+ return matrix;
+}
+
+bool fuxPixelsBitmapSource::isRotateSupported() const {
+ return false;
+}
+
+Ref<LuminanceSource> fuxPixelsBitmapSource::rotateCounterClockwise() {
+ return Ref<fuxPixelsBitmapSource> (NULL);
+}
+
+}
+
@@ -0,0 +1,29 @@
+#pragma once
+
+#include <zxing/LuminanceSource.h>
+#include "Base/GemPixObj.h"
+
+namespace zxing {
+
+// modeled off the Image Magick demo
+class fuxPixelsBitmapSource : public LuminanceSource {
+private:
+ imageStruct& image_;
+ int width;
+ int height;
+ const unsigned char* pixel_cache;
+
+public:
+ fuxPixelsBitmapSource(imageStruct& image);
+
+ ~fuxPixelsBitmapSource();
+
+ int getWidth() const;
+ int getHeight() const;
+ unsigned char* getRow(int y, unsigned char* row);
+ unsigned char* getMatrix();
+ bool isRotateSupported() const;
+ Ref<LuminanceSource> rotateCounterClockwise();
+};
+
+}
@@ -0,0 +1,118 @@
+/*
+ * fux_qrcode.cpp
+ * gem_darwin
+ *
+ * Created by chris clepper on Mon Oct 07 2002.
+ * Copyright (c) 2002 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include "fux_qrcode.h"
+#include <zxing/Result.h>
+#include <cstring>
+
+CPPEXTERN_NEW(fux_qrcode)
+
+/////////////////////////////////////////////////////////
+//
+// fux_qrcode
+//
+/////////////////////////////////////////////////////////
+// Constructor
+//
+/////////////////////////////////////////////////////////
+//
+using namespace zxing;
+using namespace zxing::qrcode;
+
+fux_qrcode :: fux_qrcode()
+{
+
+long size,src,i;
+//inletBlur = inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("amount"));
+//inletLength = inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("length"));
+
+}
+
+/////////////////////////////////////////////////////////
+// Destructor
+//
+/////////////////////////////////////////////////////////
+fux_qrcode :: ~fux_qrcode()
+{
+ //delete saved;
+ //relocate this to on external deletion
+}
+
+void fux_qrcode::decode(imageStruct& image, bool adaptive) {
+
+ //post("trying to decode");
+
+ try {
+ Ref<fuxPixelsBitmapSource> source(new fuxPixelsBitmapSource(image));
+
+ Ref<Binarizer> binarizer(NULL);
+ if(adaptive) {
+ binarizer = new HybridBinarizer(source);
+ } else {
+ binarizer = new GlobalHistogramBinarizer(source);
+ }
+
+
+ Ref<BinaryBitmap> image(new BinaryBitmap(binarizer));
+ QRCodeReader reader;
+ DecodeHints hints;
+ hints.addFormat(BarcodeFormat_QR_CODE);
+ hints.setTryHarder(true);
+
+ Ref<Result> result(reader.decode(image, hints));
+ post("QRcode detected");
+
+ std::string QRtext = result->getText()->getText();
+
+
+
+ } catch (zxing::Exception& e) {
+ //post(e.what()); // << e.what() << endl;
+ }
+
+}
+
+
+/////////////////////////////////////////////////////////
+// processImage
+//
+/////////////////////////////////////////////////////////
+void fux_qrcode :: processRGBAImage(imageStruct &image)
+{
+ //int h,w,hlength;
+ //int R,G,B;
+ //unsigned char *pixels=image.data;
+
+ decode(image,true);
+
+ //hlength = image.xsize;
+
+}
+
+/////////////////////////////////////////////////////////
+// static member function
+//
+/////////////////////////////////////////////////////////
+void fux_qrcode :: obj_setupCallback(t_class *classPtr)
+{
+
+ class_addmethod(classPtr, (t_method)&fux_qrcode::blurCallback,gensym("amount"), A_DEFFLOAT, A_NULL);
+ class_addmethod(classPtr, (t_method)&fux_qrcode::lengthCallback,gensym("length"), A_DEFFLOAT, A_NULL);
+
+}
+
+void fux_qrcode :: blurCallback(void *data, t_floatarg value)
+{
+ //GetMyClass(data)->m_glitchAmount=(value);
+}
+
+void fux_qrcode :: lengthCallback(void *data, t_floatarg value)
+{
+ //GetMyClass(data)->m_glitchLength=(value);
+}
@@ -0,0 +1,75 @@
+/*
+ * fux_qrcode.h
+ * gem_darwin
+ *
+ * Created by chris clepper on Mon Oct 07 2002.
+ * Copyright (c) 2002 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#ifndef INCLUDE_fux_qrcode_H_
+#define INCLUDE_fux_qrcode_H_
+
+#include "Base/GemPixObj.h"
+
+#include <zxing/qrcode/QRCodeReader.h>
+#include <zxing/common/GlobalHistogramBinarizer.h>
+#include <zxing/common/HybridBinarizer.h>
+#include <zxing/Result.h>
+#include <zxing/Exception.h>
+
+#include "fuxPixelsBitmapSource.h"
+
+/*-----------------------------------------------------------------
+-------------------------------------------------------------------
+CLASS
+ fux_qrcode
+
+
+
+KEYWORDS
+ pix
+ yuv
+
+DESCRIPTION
+
+ old motion blur object. soon to be an abstraction for pix_convolve ??
+
+-----------------------------------------------------------------*/
+
+
+
+class GEM_EXTERN fux_qrcode : public GemPixObj
+{
+CPPEXTERN_HEADER(fux_qrcode, GemPixObj)
+
+ public:
+
+ //////////
+ // Constructor
+ fux_qrcode();
+ void decode(imageStruct &pixels, bool adaptive = true);
+
+ protected:
+
+ //////////
+ // Destructor
+ virtual ~fux_qrcode();
+ virtual void processRGBAImage(imageStruct &image);
+
+ unsigned int *saved;
+ t_inlet *inletBlur;
+ t_inlet *inletLength;
+ t_outlet *outletQR;
+ private:
+
+ //////////
+ // Static member functions
+ static void lengthCallback(void *data, t_floatarg value);
+ static void blurCallback(void *data, t_floatarg value);
+
+
+};
+
+#endif
+
Binary file not shown.
Binary file not shown.

0 comments on commit d4cc5f7

Please sign in to comment.