diff --git a/DirectPrint/Makefile b/DirectPrint/Makefile index ff9c537..31f35ae 100644 --- a/DirectPrint/Makefile +++ b/DirectPrint/Makefile @@ -1,3 +1,3 @@ all: g++ printtxt.cpp -o printtxt - g++ printimg.cpp -o printimg `pkg-config --cflags --libs opencv` + g++ printimg.cpp dither.cpp -o printimg `pkg-config --cflags --libs opencv` diff --git a/DirectPrint/printimg b/DirectPrint/printimg index cbfab26..45aef1e 100755 Binary files a/DirectPrint/printimg and b/DirectPrint/printimg differ diff --git a/DirectPrint/printimg.cpp b/DirectPrint/printimg.cpp index 0b87dad..e0e7a2a 100644 --- a/DirectPrint/printimg.cpp +++ b/DirectPrint/printimg.cpp @@ -11,6 +11,8 @@ #include #include +#include "dither.h" + #define CHAR_HEIGHT 8 #define DOT_WIDTH 720 #define HW_RATIO 1.35 @@ -104,7 +106,7 @@ void print_buffer(int iw, char *buf, size_t len){ write(iw, seg, amnt); i += 250; //printf("Done segment!\n"); - usleep(990000); //Don't overfill buffer + usleep(200000); //Don't overfill buffer } write(iw, "\n\r", 2); @@ -144,7 +146,9 @@ Mat load_img(char * filename){ cout << "Could not open or find the image" << std::endl ; } - return image; + Mat dith = dither_image(image); + + return dith; } void print_section(int iw, Mat sec){ @@ -165,6 +169,7 @@ void print_section(int iw, Mat sec){ } write(iw, line, sec.cols); + usleep(1000000); free(line); } @@ -190,12 +195,12 @@ int main(int argc, char *argv[]){ int iw = init_port(portname); Mat image = load_img(argv[1]); - float pg_factor = 0.25; + float pg_factor = 0.75; float xScale = (pg_factor * DOT_WIDTH) / ((float)image.cols); float yScale = xScale / HW_RATIO; resize(image, image, Size(), xScale, yScale); - cvtColor(image, image, COLOR_RGB2GRAY); - threshold(image, image, 127, 255, THRESH_BINARY); + //cvtColor(image, image, COLOR_RGB2GRAY); + //threshold(image, image, 127, 255, THRESH_BINARY); print_img(iw, image); //namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.