Ejemplo n.º 1
0
int main( int argc, char** argv )
{
	PrintBanner();

	if ( argc > 1 )
	{
		LoadDensityMap( argv[1] );
	}

	// prepare PRNG
	gen.seed( time( NULL ) );

	std::vector<sPoint> Points = GeneratePoissonPoints( MinDistance, k, NumPoints );

	// prepare BGR image
	cv::Mat	Img(cv::Size(ImageSize,ImageSize),CV_8UC1);
	Img.setTo(0);

	for ( auto i = Points.begin(); i != Points.end(); i++ )
	{
		int x = int( i->x * ImageSize );
		int y = int( i->y * ImageSize );
		if ( g_DensityMap )
		{
			// dice
			float R = RandomFloat();
			float P = g_DensityMap[ x + y * ImageSize ];
			if ( R > P ) continue;
		}
		Img.ptr<uchar>(y)[x]	=	255;
	}
	cv::imwrite("Poisson.bmp",Img);

	return 0;
}
Ejemplo n.º 2
0
bool cWindowSFML::Icon( const std::string& Path ) {
	mWindow.WindowConfig.Icon 	= Path;

	cImage Img( Path );

	mSFMLWindow.setIcon( Img.Width(), Img.Height(), Img.GetPixelsPtr() );

	return true;
}
Ejemplo n.º 3
0
bool_t cv_window_func(struct image_t *img) {

  if (!window_enabled)
    return FALSE;


  uint16_t coordinate[2] = {0,0};
  uint16_t response = 0;
  uint32_t integral_image[img->w * img->h];

  struct image_t gray;
  image_create(&gray, img->w, img->h, IMAGE_GRAYSCALE);
  image_to_grayscale(img, &gray);

  response = detect_window_sizes( (uint8_t*)gray.buf, (uint32_t)img->w, (uint32_t)img->h, coordinate, integral_image, MODE_BRIGHT);

  image_free(&gray);

  // Display the marker location and center-lines.
  int px = coordinate[0] & 0xFFFe;
  int py = coordinate[1] & 0xFFFe;

  if (response < 92) {

    for (int y = 0; y < img->h-1; y++) {
      Img(px, y)   = 65;
      Img(px+1, y) = 255;
    }
    for (int x = 0; x < img->w-1; x+=2) {
      Img(x, py)   = 65;
      Img(x+1, py) = 255;
    }

    uint32_t temp = coordinate[0];
    temp = temp << 16;
    temp += coordinate[1];
    blob_locator = temp;

  }

  return FALSE;
}
Ejemplo n.º 4
0
int main(int argc, char** argv)
{
    GetPot clArgs(argc,argv);

    hal::Camera Cam( clArgs.follow("", "-cam" ) );

    pb::ImageArray Imgs;

    std::vector< cv::Mat > vBuff;

    Thumbnails Thmbs;

    for(unsigned int nFrame = 0; ; ++nFrame ) {

        Cam.Capture( Imgs );

        cv::Mat Img( Imgs[0] );

        for( int ii = 0; ii < 5; ++ii ) {
            cv::Mat Tmp;
            cv::resize( Img, Tmp, cv::Size(0,0), 0.5, 0.5 );
            Img = Tmp;
        }

        vBuff.push_back( Img );

        std::vector< unsigned int >    vMatches;
        Thmbs.FindBestMatch( vBuff[vBuff.size()-1].data, nullptr, vMatches );

        std::cout << "Matches for " << nFrame << ":" << std::endl;
        for( int ii = 0; ii < vMatches.size(); ++ii ) {
            std::cout << vMatches[ii] << ", ";
        }
        std::cout << std::endl;

        Thmbs.PushThumbnails( nFrame, Img.rows * Img.cols, vBuff[vBuff.size()-1].data );


        ///----------------------------------------------------


        // clear whole screen
//        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

//        pangolin::FinishGlutFrame();

        std::cout << "."; fflush(stdout);
        sleep(1);
    }

    return 0;
}
Ejemplo n.º 5
0
// specification of example interval vector function
// (ie, vector inclusion function)
// as in Exercise 11.34 and 11.35 of AIA
ivector IVF_ex11_35(const ivector& x)
{
    // example in 2-d space R2
    // for f: R2 -> R2
    //f1(x1, x2) = x1^2 + x2 - x2^2
    //f2(x1, x2) = x1^2 + x2^2

    ivector Img(2);

    Img[1] = sqr(x[1]) + x[2] - sqr(x[2]);
    Img[2] = sqr(x[1]) + sqr(x[2]);

    return (Img);
}
wxGxObject *wxGxDiscConnectionsUI::CreateChildGxObject(const wxJSONValue& GxObjConfValue)
{
    if(!m_Conn16.IsOk())
        m_Conn16 = wxIcon(folder_conn_16_xpm);
    if(!m_Conn48.IsOk())
        m_Conn48 = wxIcon(folder_conn_48_xpm);
    if(!m_ConnDsbld16.IsOk())
    {
        wxImage Img(folder_conn_16_xpm);
        m_ConnDsbld16.CopyFromBitmap(Img.ConvertToGreyscale());
    }
    if(!m_ConnDsbld48.IsOk())
    {
        wxImage Img(folder_conn_48_xpm);
        m_ConnDsbld48.CopyFromBitmap(Img.ConvertToGreyscale());
    }

    wxString soName = GxObjConfValue[wxT("name")].AsString();
    wxString sPath = GxObjConfValue[wxT("path")].AsString();
    CPLString soPath(sPath.mb_str(wxConvUTF8));
    int nStoreId = GxObjConfValue[wxT("id")].AsInt();
    return new wxGxDiscConnectionUI(this, nStoreId, soName, soPath, m_Conn16, m_Conn48, m_ConnDsbld16, m_ConnDsbld48);
}
Ejemplo n.º 7
0
void ThemeBase::RegisterImage( int &iIndex, char const ** pXpm, const wxString & Name )
{

   wxASSERT( iIndex == -1 ); // Don't initialise same bitmap twice!
   wxBitmap Bmp( pXpm ); // a 24 bit bitmap.
   wxImage Img( Bmp.ConvertToImage() );
   Img.InitAlpha();

   //dmazzoni: the top line does not work on wxGTK
   //wxBitmap Bmp2( Img, 32 );
   //wxBitmap Bmp2( Img );

   RegisterImage( iIndex, Img, Name );
}
Ejemplo n.º 8
0
wxObject* wxsImagePanel::OnBuildPreview(wxWindow* Parent, long Flags) {
wxImagePanel    *ap;
wxsImage        *image;
wxBitmap        bmp;

// make a panel

    ap = new wxImagePanel(Parent, GetId(), Pos(Parent), Size(Parent), Style());
    if (ap == NULL) return NULL;

// get the wxsImage pointer

    image = (wxsImage *) wxsImageListEditorDlg::FindTool(this, mImage);

// and make the preview image

    if (image != NULL) {
        bmp = ((wxsImage *) image)->GetPreview();
        ap->SetBitmap(bmp);
    }
    else{
        // in case we can't find the name in ImageList, we try to interpret it as a filepath
        // see discussion http://forums.codeblocks.org/index.php/topic,22888.0.html
        wxImage Img(mImage);
        if (Img.Ok())
        {
            bmp = wxBitmap(Img);
            ap->SetBitmap(bmp);
        }
    };

// and stretch it?

    ap->SetStretch(mStretch);

// set all decorations

    SetupWindow(ap, Flags);

// add the children

    AddChildrenPreview(ap, Flags);

// done

    return ap;
}
Ejemplo n.º 9
0
struct marker_deviation_t marker(struct image_t *input, uint8_t M)
{
  struct marker_deviation_t marker_deviation;

  marker_deviation.x = 0;
  marker_deviation.y = 0;
  marker_deviation.inlier = 0;

  uint8_t *source = (uint8_t *) input->buf;
  uint16_t x, y, i, j, k;

  if (M < 1) { M = 1; }
  source = (uint8_t *) input->buf;

  int maxx = 160;
  int maxy = 120;
  int maxv = 0;

  for (j = M; j < (input->h - M); j++) {
    for (i = M; i < (input->w - M); i++) {
      int bad, good;
      good = bad = 0;
      for (k = 1; k < M; k++) {
        // Pattern must be symmetric
        bad += AbsDiff(Img(i - k, j)   , Img(i + k, j));
        bad += AbsDiff(Img(i, j - k)   , Img(i, j + k));
        bad += AbsDiff(Img(i - k, j - k) , Img(i + k, j + k));
        bad += AbsDiff(Img(i + k, j - k) , Img(i - k, j + k));

        // Pattern: Must have perpendicular contrast
        good += AbsDiff(Img(i - k, j) + Img(i + k, j),   Img(i, j - k) + Img(i, j + k));
        good += AbsDiff(Img(i - k, j - k) + Img(i + k, j + k), Img(i + k, j - k) + Img(i - k, j + k));
      }

      for (k = 4; k < M; k += 2) {
        // Pattern must be symmetric
        bad += AbsDiff(Img(i - k, j - k / 2)   , Img(i + k, j + k / 2));
        bad += AbsDiff(Img(i + k / 2, j - k)   , Img(i - k / 2, j + k));
        bad += AbsDiff(Img(i - k / 2, j - k) , Img(i + k / 2, j + k));
        bad += AbsDiff(Img(i + k, j - k / 2) , Img(i - k, j + k / 2));

        // Pattern: Must have perpendicular contrast
        good += AbsDiff(Img(i - k, j - k / 2) + Img(i + k, j + k / 2),   Img(i + k / 2, j - k) + Img(i - k / 2, j + k));
        good += AbsDiff(Img(i - k / 2, j - k) + Img(i + k / 2, j + k), Img(i + k, j - k / 2) + Img(i - k, j + k / 2));
      }

      int v = good - bad;
      if (v < 0) {
        v = 0;
      }

      if (v > maxv) {
        maxv = v;
        maxx = i;
        maxy = j;
      }

      if (v > 0) {
        Out(i, j) = 0xff;
      }
    }
  }

  // Display the marker location and center-lines.
  for (y = 0; y < input->h; y++) {
    Out(maxx, y) = 0xff;
  }
  for (x = 0; x < input->w; x++) {
    Out(x, maxy) = 0xff;
  }

  marker_deviation.x = ((int32_t)0) - ((int32_t)(input->w) / 2);
  marker_deviation.y = -((int32_t)0) + ((int32_t)(input->h) / 2);
  marker_deviation.inlier = 0;

  //printf("The number of inliers = %i\n", counter3);
  return marker_deviation;
}
Ejemplo n.º 10
0
int main(int argc, char *argv[]){
	// Window Main(argc, argv);
	Json Settings("../settings/heatmap.json");
	Message Msg("en");

	int i, j, k, m;
	char drop, buf[3];
	char string[1000];
	FILE *open;
	struct one_pixel *rawdata;
	struct {
		int byte_per_line;
		int block;
		int byte_per_pixel[2];
		char theme[100];
		struct rgb base;
	}setting;

	struct specification{
		long code;
		struct rgb color;
	};

	struct range{
		long begin;
		long end;
		struct rgb color;
	};

	struct {
		int num;
		struct specification *list;
	}specification_data;

	struct {
		int num;
		struct range *list;
	}range_data;

	// Loading Setting
	setting.byte_per_line = atoi( Settings.get("settings.block_per_line")->value );
	setting.block = atoi( Settings.get("settings.block")->value );

	setting.byte_per_pixel[0] = atoi( Settings.get("settings.block_per_pixel.width")->value );
	setting.byte_per_pixel[1] = atoi( Settings.get("settings.block_per_pixel.height")->value );

	strcpy( setting.theme, Settings.get("settings.default_theme")->value );
	color( &setting.base, Settings.get("settings.campus_color")->value );

	// Loading Theme
	sprintf(string, "../themes/%s.json", setting.theme);
	open = fopen(string, "r");
	if(!open){
		Msg.show(2);
		sprintf(string, "../themes/%s.json", setting.theme);
	}else{
		fclose(open);
	}

	Json Theme(string);

	// Default
	struct rgb theme_default;
	color( &theme_default, Theme.get("default")->value );

	// Specification
	specification_data.num = Theme.array_range("specification");

	specification_data.list = (struct specification *)calloc(specification_data.num, sizeof(struct specification));
	if(!specification_data.list)
		Msg.show(3);

	for(i=0; i<specification_data.num; i++){
		// Clear Buffer
		for(j=0; j<1000; j++)
			string[j] = 0x00;

		color( &specification_data.list[i].color, gcat(&Msg, Theme.get( gstr(string, "specification", i, "color") ))->value );
		specification_data.list[i].code = strtol( gcat(&Msg, Theme.get( gstr(string, "specification", i, "addr") ))->value, NULL, 16 );
	}

	// Range
	range_data.num = Theme.array_range("range");
	range_data.list = (struct range *)calloc(range_data.num, sizeof(struct range));
	if(!range_data.list)
		Msg.show(3);

	for(i=0; i<range_data.num; i++){
		// Clear Buffer
		for(j=0; j<1000; j++)
			string[j] = 0x00;

		color( &range_data.list[i].color, gcat(&Msg, Theme.get( gstr(string, "range", i, "color") ))->value );
		range_data.list[i].begin = strtol( Theme.get( gstr(string, "range", i, "begin") )->value, NULL, 16 );
		range_data.list[i].end = strtol( Theme.get( gstr(string, "range", i, "end") )->value, NULL, 16 );
	}

	// Prepare
	long buffer;
	int image_width = setting.byte_per_pixel[0] * setting.byte_per_line;
	int image_size = -1, image_height;

	open = fopen("../bin/main", "rb");
	if(!open)
		Msg.show(5);

	while(!feof(open)){
		fread(&buffer, (size_t)setting.block , (size_t)1, open);
		image_size++;
	}

	image_height = setting.byte_per_pixel[1] * ((image_size / setting.byte_per_line) + 1);

	rawdata = (struct one_pixel *)calloc(image_width * image_height, sizeof(struct one_pixel));
	if(!rawdata)
		Msg.show(3);


	rewind( open );

	struct rgb *line;
	line = (struct rgb *)calloc(setting.byte_per_line, sizeof(struct rgb));
	if(!line)
		Msg.show(3);

	int cur_line = 0;
	long size_pointer = 0;

	for(j=0; j<setting.byte_per_line; j++)
		line[j] = setting.base;

	int debug = 0;
	bool break_flag = false;
	while(!feof(open)){
		buffer = 0x20;
		if(fread(&buffer, (size_t)setting.block, (size_t)1, open) != 1)
			break_flag = true;

		if(!break_flag){
			// printf("%d (%d) %s\n", debug, cur_line, "Write!");
			debug++;

			// Default Color
			line[cur_line] = theme_default;

			// Range
			for(j=0; j<range_data.num; j++){
				if(buffer >= range_data.list[j].begin && buffer <= range_data.list[j].end){
					line[cur_line] = range_data.list[j].color;
					break;
				}
			}

			// Specification
			for(j=0; j<specification_data.num; j++){
				if( buffer == specification_data.list[j].code ){
					line[cur_line] = specification_data.list[j].color;
					break;
				}
			}
		}

		if(cur_line >= setting.byte_per_line - 1 || break_flag){
			// Height
			for(j=0; j<setting.byte_per_pixel[1]; j++){
				// Dots
				for(m=0; m<setting.byte_per_line; m++){
					for(k=0; k<setting.byte_per_pixel[0]; k++){
						rgb_one_pixel(&line[m], &rawdata[size_pointer]);
						size_pointer++;
					}
				}
			}

			for(j=0; j<setting.byte_per_line; j++)
				line[j] = setting.base;

			cur_line = 0;
		}else{
			cur_line++;
		}
	}

	fclose( open );

	Window Main(argc, argv, image_width, image_height, 24, rawdata);	
	Bitmap Img(&Msg, "../test_2.bmp", image_width, image_height, 24, rawdata);

	// char drop;

	struct color_set{
		char key;
	};

	// while(TRUE){
	// 	scanf("%c", &drop);

	// 	printf("%c", drop);
	// }

	return 0;
}
Ejemplo n.º 11
0
void AsmSearchDll (
    int *pnlandmarks,          // out: number of landmarks, 0 if can't get landmarks
    int landmarks[],           // out: the landmarks, caller must allocate
    const char image_name[],   // in: used in internal error messages, if necessary
    const char image_data[],   // in: image data, 3 bytes per pixel if is_color
    const int width,           // in: the width of the image
    const int height,          // in: the height of the image
    const int is_color,        // in: 1 if RGB image, 0 if grayscale
    const char conf_file0[],   // in: 1st config filename, NULL for default
    const char conf_file1[])   // in: 2nd config filename, NULL for default, "" if none
{
    ASSERT(sizeof(int) == 4);  // sanity checks
    ASSERT(image_name[0]);
    ASSERT(width > 10 && height > 10);
    ASSERT(is_color == 0 || is_color == 1);

    char sConfFile0[SLEN];
    if(conf_file0 == NULL)
        strcpy(sConfFile0, "../data/mu-68-1d.conf");
    else if(conf_file0[0] == 0)
        Err("AsmSearchDll: conf_file0[0] == 0");
    else
        strcpy(sConfFile0, conf_file0);
    ASSERT(sConfFile0[0]);

    char sConfFile1[SLEN];
    if(conf_file1 == NULL)
        strcpy(sConfFile1, "../data/mu-76-2d.conf");
    else if(conf_file1[0] == 0)
        sConfFile1[0] = 0;
    else
        strcpy(sConfFile1, conf_file1);

    RgbImage Img(width, height);

    // copy image_data into Img, flipping row order

    if(is_color)
        for (int i = 0; i < height; i++)
            for (int j = 0; j < width; j++)
                {
                int i1 = i * width + j;
                int i2 = 3 * ((height - i - 1) * width + j);
                Img.buf[i1].Blue  = image_data[i2];
                Img.buf[i1].Green = image_data[i2+1];
                Img.buf[i1].Red   = image_data[i2+2];
                }
    else
        for (int i = 0; i < height; i++)
            for (int j = 0; j < width; j++)
                {
                int i1 = i * width + j;
                Img.buf[i1].Blue = Img.buf[i1].Green = Img.buf[i1].Red =
                    image_data[(height - i - 1) * width + j];
                }

    SHAPE StartShape;           // dummy args
    DET_PARAMS DetParams;       // dummy arg for AsmSearch
    double MeanTime;            // dummy arg for AsmSearch
    SHAPE Shape = AsmSearch(StartShape, DetParams, MeanTime,
                            Img, image_name, FALSE, sConfFile0, sConfFile1);

    *pnlandmarks = 0;
    if (Shape.nrows())          // successfully located landmarks?
        {
        // convert from stasm coords to OpenCV coords

        Shape.col(VX) += Img.width / 2;
        Shape.col(VY) = Img.height / 2 - Shape.col(VY);

        *pnlandmarks = Shape.nrows();
        for (int iPoint = 0; iPoint < *pnlandmarks; iPoint++)
            {
            landmarks[2 * iPoint]     = iround(Shape(iPoint, VX));
            landmarks[2 * iPoint + 1] = iround(Shape(iPoint, VY));
            }
        }
}
Ejemplo n.º 12
0
/*
-----------------------------------------------------------------------------

-----------------------------------------------------------------------------
*/
CDesCArray* CMainContainer::GetProfilesArrayL(CArrayPtr<CGulIcon>* aIcon,const TSize& aIconsize)
{
	aIcon->AppendL(GetMyOwnIconL(aIconsize));
	
	TFindFile MyIconFile(CCoeEnv::Static()->FsSession());
	if(KErrNone == MyIconFile.FindByDir(KtxIconFileName, KNullDesC))
	{
		AddIconL(aIcon,aIconsize,MyIconFile.File(),0,1);
	}
	else
	{
		aIcon->AppendL(GetMyOwnIconL(aIconsize));
	}
	
	
	CDesCArrayFlat* MyArray = new(ELeave)CDesCArrayFlat(1);
	CleanupStack::PushL(MyArray);
	
	TFileName AddBuffer;			
	
	if(iEcomHandler)
	{
		RPointerArray<CHandlerItem> Handlers = iEcomHandler->HandlerArray();
		for(TInt i=0; i < Handlers.Count(); i++)
		{
			if(Handlers[i])
			{
				TInt IconNum(0);
				
				if(Handlers[i]->iIconfile)
				{
					TFindFile IconFile(CCoeEnv::Static()->FsSession());
					if(KErrNone == IconFile.FindByDir(*Handlers[i]->iIconfile, KNullDesC))
					{
						TInt Img(0),ImgMask(1);
						
						if(Handlers[i]->iServerName)
						{
							if(IsServerOn(*Handlers[i]->iServerName))
							{
								Img = 2;
								ImgMask = 3;
							}
						}
						
						AddIconL(aIcon,aIconsize,IconFile.File(),Img,ImgMask);
					
						IconNum = (aIcon->Count() - 1);
					}
				}
				
				AddBuffer.Num(IconNum);
				AddBuffer.Append(_L("\t"));
				if(Handlers[i]->iName)
				{
					AddBuffer.Append(*Handlers[i]->iName);
				}
				
				MyArray->AppendL(AddBuffer);			
			}
		}
	}
	
	CleanupStack::Pop(MyArray);
	return MyArray;
}