void bayer_copy(unsigned short * raw_16, unsigned char *rgb, int x, int y) { //G(x+1,y) = Bay(x+1,y) ; //G(x,y+1) = Bay(x,y+1); //G(x,y) = G(x+1,y+1) = (Bay(x+1,y) + Bay(x,y+1)) / 2; G(x,y) = G(x,y+1) = G(x+1,y) = G(x+1,y+1) = Bay(x,y+1); B(x,y)=B(x+1,y)=B(x,y+1)=B(x+1,y+1) = Bay(x,y); R(x,y)=R(x+1,y)=R(x,y+1)=R(x+1,y+1) = Bay(x+1,y+1); }
string FabAtHomePrinter::loadConfigFile(string filePath) { //Clear previously loaded data. axes.clear(); motors.clear(); tool.bays.clear(); XMLParser parser; string result = parser.load(filePath); if(result.compare("") != 0) { return result; } //Load constants. COM_PORT = Util::assertType<unsigned int>(parser.text("fabAtHomePrinter 0\\electronics 0\\comPort 0")); NUM_MODULES = Util::assertType<unsigned int>(parser.text("fabAtHomePrinter 0\\electronics 0\\numModules 0")); BAUD_RATE = Util::assertType<unsigned int>(parser.text("fabAtHomePrinter 0\\electronics 0\\baudRate 0")); X_Y_Z_GROUP_ADDRESS = (byte)Util::assertType<unsigned int>(parser.text("fabAtHomePrinter 0\\electronics 0\\xyzGroupAddress 0")); PLATFORM_DELTA = Util::assertType<double>(parser.text("fabAtHomePrinter 0\\motion 0\\platformDelta 0")); OLD_MSPS = Util::assertType<double>(parser.text("fabAtHomePrinter 0\\motion 0\\oldMsps 0")); //Load motors. unsigned int count = parser.count("fabAtHomePrinter 0\\electronics 0\\motor"); for(unsigned int i = 0; i < count; ++i) { string base = "fabAtHomePrinter 0\\electronics 0\\motor "+Util::toString(i)+"\\"; string name = parser.text(base+"name 0"); byte address = (byte)Util::assertType<unsigned int>(parser.text(base+"address 0")); double countsPerDistanceUnit = Util::assertType<double>(parser.text(base+"countsPerDistanceUnit 0")); short kp = Util::assertType<unsigned short>(parser.text(base+"kp 0")); short kd = Util::assertType<unsigned short>(parser.text(base+"kd 0")); short ki = Util::assertType<unsigned short>(parser.text(base+"ki 0")); short il = Util::assertType<unsigned short>(parser.text(base+"il 0")); byte ol = (byte)Util::assertType<unsigned int>(parser.text(base+"ol 0")); byte cl = (byte)Util::assertType<unsigned int>(parser.text(base+"cl 0")); short el = Util::assertType<unsigned short>(parser.text(base+"el 0")); byte sr = (byte)Util::assertType<unsigned int>(parser.text(base+"sr 0")); byte db = (byte)Util::assertType<unsigned int>(parser.text(base+"db 0")); double ticksPerSecond = Util::assertType<double>(parser.text(base+"ticksPerSecond 0")); motors[name] = Motor(name,address,countsPerDistanceUnit,ticksPerSecond,kp,kd,ki,il,ol,cl,el,sr,db); } //Load axes. count = parser.count("fabAtHomePrinter 0\\axis"); for(unsigned int i = 0; i < count; ++i) { string base = "fabAtHomePrinter 0\\axis "+Util::toString(i)+"\\"; string name = parser.text(base+"name 0"); string motorName = parser.text(base+"motorName 0"); map<string, Motor, LessThanString>::iterator motor = motors.find(motorName); if(motor == motors.end()) { return "Axis "+name+" references motor "+motorName+" which has not been loaded."; } if(name.compare("Y") == 0 || name.compare("Z") == 0) { motor->second.setReversed(true); } axes[name] = Axis(name,&(motor->second)); } //Check that axes named X, Y, and Z were loaded. if(axes.find("X") == axes.end()) { return "Must load an axis named X."; } if(axes.find("Y") == axes.end()) { return "Must load an axis named Y."; } if(axes.find("Z") == axes.end()) { return "Must load an axis named Z."; } //Load bays. count = parser.count("fabAtHomePrinter 0\\tool 0\\bay"); for(unsigned int i = 0; i < count; ++i) { string base = "fabAtHomePrinter 0\\tool 0\\bay "+Util::toString(i)+"\\"; string name = parser.text(base+"name 0"); string motorName = parser.text(base+"motorName 0"); if(motors.find(motorName) == motors.end()) { return "Bay "+name+" references motor "+motorName+" which has not been loaded."; } double x = Util::assertType<double>(parser.text(base+"location 0\\x 0")); double y = Util::assertType<double>(parser.text(base+"location 0\\y 0")); double z = Util::assertType<double>(parser.text(base+"location 0\\z 0")); tool.bays[name] = Bay(name,Point(x,y,z),&(motors.find(motorName)->second)); } //Check that at least one bay is loaded. if(tool.bays.size() == 0) { return "Must load at least one bay."; } return ""; }
void bayer_bilinear(unsigned short * raw_16, unsigned char *rgb,int x, int y) { R(x,y) = (Bay(x-1,y-1) + Bay(x+1, y+1) + Bay(x+1,y-1) + Bay(x-1,y+1)) / 4; //G(x,y) = (Bay(x-1,y) + Bay(x+1,y) + Bay(x,y-1) + Bay(x,y+1)) / 4; G(x,y) = ( Bay(x,y-1) + Bay(x,y+1)) / 2; B(x,y) = Bay(x,y); R(x+1,y) = (Bay(x+1,y-1) + Bay(x+1, y+1)) / 2; //G(x+1,y) = Bay(x+1,y); G(x+1,y) = (Bay(x,y-1) + Bay(x+2, y+1) + Bay(x+2,y-1) + Bay(x,y+1)) / 4; B(x+1,y) = (Bay(x,y) + Bay(x+2,y)) / 2 ; R(x,y+1) = (Bay(x-1,y+1) + Bay(x+1, y+1)) /2; G(x,y+1) = Bay(x,y+1); B(x,y+1) = (Bay(x,y) + Bay(x, y+2)) / 2; R(x+1,y+1) = Bay(x+1,y+1); //G(x+1,y+1) = (Bay(x+1,y) + Bay(x,y+1) + Bay(x+2,y+1) + Bay(x+1,y+2)) / 4; G(x+1,y+1) = (Bay(x,y+1) + Bay(x+2,y+1)) / 2; B(x+1,y+1) = (Bay(x,y) + Bay(x+2, y+2) + Bay(x+2,y) + Bay(x,y+2)) / 4; }