int bbImagesCollide( bbImage *i1,int x1,int y1,int f1,bbImage *i2,int x2,int y2,int f2 ){ debugImage( i1,f1 ); debugImage( i2,f2 ); gxCanvas *c1=i1->getFrames()[f1]; gxCanvas *c2=i2->getFrames()[f2]; return c1->collide( x1,y1,c2,x2,y2,false ); }
int bbImagesOverlap( bbImage *i1,int x1,int y1,bbImage *i2,int x2,int y2 ){ debugImage( i1 ); debugImage( i2 ); gxCanvas *c1=i1->getFrames()[0]; gxCanvas *c2=i2->getFrames()[0]; return c1->collide( x1,y1,c2,x2,y2,true ); }
void LFLineFitter::DisplayEdgeMap(Image<uchar> *inputImage,const char *outputImageName) { // for debug //Image *debugImage = cvCreateImage( cvSize(inputImage->width,inputImage->height), IPL_DEPTH_8U,1); //cvZero(debugImage); Image<uchar> debugImage(inputImage->width(),inputImage->height());; for(int i=0;i<nLineSegments_;i++) { //cvLine(debugImage,cvPoint((int)outEdgeMap_[i].sx_,(int)outEdgeMap_[i].sy_),cvPoint((int)outEdgeMap_[i].ex_,(int)outEdgeMap_[i].ey_),cvScalar(255)); ImageDraw<uchar>::Line(&debugImage,(int)outEdgeMap_[i].sx_,(int)outEdgeMap_[i].sy_,(int)outEdgeMap_[i].ex_,(int)outEdgeMap_[i].ey_,255); } if(outputImageName!=NULL) { printf("Save Image %s\n\n",outputImageName); //cvSaveImage(outputImageName,debugImage); ImageIO::SavePGM(&debugImage,outputImageName); } //else //{ // cvNamedWindow("debug",1); // cvShowImage("debug",debugImage); // cvWaitKey(0); //} //cvReleaseImage(&debugImage); }
bbImage *bbCopyImage( bbImage *i ){ debugImage( i ); vector<gxCanvas*> frames; const vector<gxCanvas*> &f=i->getFrames(); for( int k=0;k<f.size();++k ){ gxCanvas *t=f[k]; gxCanvas *c=gx_graphics->createCanvas( t->getWidth(),t->getHeight(),0 ); if( !c ){ for( --k;k>=0;--k ) gx_graphics->freeCanvas( frames[k] ); return 0; } int x,y; t->getHandle( &x,&y ); t->setHandle( 0,0 ); c->blit( 0,0,t,0,0,t->getWidth(),t->getHeight(),true ); if( auto_dirty ) c->backup(); t->setHandle( x,y ); c->setHandle( x,y ); c->setMask( t->getMask() ); frames.push_back( c ); } bbImage *t=d_new bbImage( frames ); image_set.insert( t ); return t; }
void bbGrabImage( bbImage *i,int x,int y,int n ){ debugImage( i,n ); gxCanvas *c=i->getFrames()[n]; int src_ox,src_oy,dst_hx,dst_hy; gx_canvas->getOrigin( &src_ox,&src_oy ); c->getHandle( &dst_hx,&dst_hy ); x+=src_ox-dst_hx;y+=src_oy-dst_hy; c->setViewport( 0,0,c->getWidth(),c->getHeight() ); c->blit( 0,0,gx_canvas,x,y,c->getWidth(),c->getHeight(),true ); if( auto_dirty ) c->backup(); }
void bbTFormImage( bbImage *i,float a,float b,float c,float d ){ debugImage( i ); const vector<gxCanvas*> &f=i->getFrames(); int k; for( k=0;k<f.size();++k ){ if( f[k]==gx_canvas ){ bbSetBuffer( gx_graphics->getFrontCanvas() ); break; } } float m[2][2]; m[0][0]=a;m[1][0]=b;m[0][1]=c;m[1][1]=d; for( k=0;k<f.size();++k ){ gxCanvas *c=f[k]; int hx,hy;c->getHandle( &hx,&hy ); gxCanvas *t=tformCanvas( c,m,hx,hy ); i->replaceFrame( k,t ); t->backup(); } }
cv::Mat TextLine::drawDebugImage(cv::Mat baseImage) { cv::Mat debugImage(baseImage.size(), baseImage.type()); baseImage.copyTo(debugImage); cv::cvtColor(debugImage, debugImage, CV_GRAY2BGR); fillConvexPoly(debugImage, linePolygon.data(), linePolygon.size(), Scalar(0,0,165)); fillConvexPoly(debugImage, textArea.data(), textArea.size(), Scalar(125,255,0)); line(debugImage, topLine.p1, topLine.p2, Scalar(255,0,0), 1); line(debugImage, bottomLine.p1, bottomLine.p2, Scalar(255,0,0), 1); line(debugImage, charBoxTop.p1, charBoxTop.p2, Scalar(0,125,125), 1); line(debugImage, charBoxLeft.p1, charBoxLeft.p2, Scalar(0,125,125), 1); line(debugImage, charBoxRight.p1, charBoxRight.p2, Scalar(0,125,125), 1); line(debugImage, charBoxBottom.p1, charBoxBottom.p2, Scalar(0,125,125), 1); return debugImage; }
void bbResizeImage( bbImage *i,float w,float h ){ debugImage( i ); gxCanvas *c=i->getFrames()[0]; bbTFormImage( i,w/(float)c->getWidth(),0,0,h/(float)c->getHeight() ); }
void bbRotateImage( bbImage *i,float d ){ debugImage( i ); d*=-dtor; bbTFormImage( i,cos(d),-sin(d),sin(d),cos(d) ); }
void bbDrawBlock( bbImage *i,int x,int y,int frame ){ debugImage( i,frame ); gxCanvas *c=i->getFrames()[frame]; gx_canvas->blit( x,y,c,0,0,c->getWidth(),c->getHeight(),true ); }
void bbScaleImage( bbImage *i,float w,float h ){ debugImage( i ); bbTFormImage( i,w,0,0,h ); }
int bbImageRectOverlap( bbImage *i,int x,int y,int x2,int y2,int w2,int h2 ){ debugImage( i ); gxCanvas *c=i->getFrames()[0]; return c->rect_collide( x,y,x2,y2,w2,h2,true ); }
int bbImageRectCollide( bbImage *i,int x,int y,int f,int x2,int y2,int w2,int h2 ){ debugImage( i,f ); gxCanvas *c=i->getFrames()[f]; return c->rect_collide( x,y,x2,y2,w2,h2,false ); }
void bbTileBlock( bbImage *i,int x,int y,int frame ){ debugImage( i,frame ); tile( i,x,y,frame,true ); }
void bbMaskImage( bbImage *i,int r,int g,int b ){ debugImage( i ); unsigned argb=(r<<16)|(g<<8)|b; const vector<gxCanvas*> &f=i->getFrames(); for( int k=0;k<f.size();++k ) f[k]->setMask( argb ); }
int bbSaveImage( bbImage *i,BBStr *str,int n ){ debugImage( i,n ); string t=*str;delete str; gxCanvas *c=i->getFrames()[n]; return saveCanvas( c,t ) ? 1 : 0; }
int bbImageYHandle( bbImage *i ){ debugImage( i ); int x,y; i->getFrames()[0]->getHandle( &x,&y ); return y; }
int bbImageWidth( bbImage *i ){ debugImage( i ); return i->getFrames()[0]->getWidth(); }
void bbMidHandle( bbImage *i ){ debugImage( i ); const vector<gxCanvas*> &f=i->getFrames(); for( int k=0;k<f.size();++k ) f[k]->setHandle( f[k]->getWidth()/2,f[k]->getHeight()/2 ); }
void bbHandleImage( bbImage *i,int x,int y ){ debugImage( i ); const vector<gxCanvas*> &f=i->getFrames(); for( int k=0;k<f.size();++k ) f[k]->setHandle( x,y ); }
gxCanvas *bbImageBuffer( bbImage *i,int n ){ debugImage( i,n ); return i->getFrames()[n]; }
void bbTileImage( bbImage *i,int x,int y,int frame ){ debugImage( i,frame ); tile( i,x,y,frame,false ); }
int bbImageHeight( bbImage *i ){ debugImage( i ); return i->getFrames()[0]->getHeight(); }
void bbDrawBlockRect( bbImage *i,int x,int y,int r_x,int r_y,int r_w,int r_h,int frame ){ debugImage( i,frame ); gxCanvas *c=i->getFrames()[frame]; gx_canvas->blit( x,y,c,r_x,r_y,r_w,r_h,true ); }