Exemplo n.º 1
0
int main(int arcg)
{
	

	// Access and loading program to nm-board
	C_PC_Connector_mb7707 Connector(MAC_ADDRESS,PROGRAM);
	if (!Connector.isConnected()){
		printf("Connection to mc5103 error!");
		return -1;
	}
	access=Connector.access;
	int handshake= Connector.Sync(0xC0DE0086);
	if (handshake!=0xC0DE6406){
		printf("Handshake with mc5103 error!");
		return -1;
	}
	
	if(!VS_Init())
		return 0;

	if(!VS_Bind("../../../../input/Lena224x240.bmp"))
		return 0;

	
	int width =VS_GetWidth (VS_SOURCE);
	int height=VS_GetHeight(VS_SOURCE);

	int size  =width*height;

    VS_CreateImage("Source Image", 1, width, height, VS_RGB8, 0);	// Create window for 8-bit source grayscale image
	VS_CreateImage("Sobel  Image", 2, width, height, VS_RGB8, 0);	// Create window for 8-bit result grayscale image

	Connector.Sync(width);		// Send width to nmc
	Connector.Sync(height);		// Send height to nmc
	int ok=Connector.Sync(0);	// Get	status of memory allocation from nm
	if (ok!=0x600DB00F){
		printf("Memory allocation error!");
		return -1;
	}
	unsigned srcAddr=Connector.Sync(0);
	unsigned dstAddr=Connector.Sync(0);
	
	unsigned char*  srcImg8=  new unsigned char [size];
	unsigned char*  dstImg8=  new unsigned char [size];
	
	
	
	while(VS_Run())	{
        VS_GetGrayData(VS_SOURCE, srcImg8);	// Get image from video stream
		VS_SetData(1, srcImg8);				// Put source image in window ?1

		Connector.WriteMemBlock((unsigned*)srcImg8, srcAddr, size/4);
		Connector.Sync(0);
		//... wait while sobel runs on board
		unsigned t=Connector.Sync(0);
		Connector.ReadMemBlock ((unsigned*)dstImg8, dstAddr, size/4);
			
		//profiler_print2tbl("../../nm/sobel_mb7707_nmd.map", ReadMemBlock);
		printf("\n");
	
	
		VS_SetData(2, dstImg8);
		VS_Text("%d clocks per frame, %.2f clocks per pixel, %.2f fps\r\n", t, 1.0*t/size, 320000000.0/t );
		VS_Draw(VS_DRAW_ALL);
	}

	delete srcImg8;
	delete dstImg8;
    
    return 0;
}
Exemplo n.º 2
0
int main()
{
	// Access and loading program to nm-board
	C_PC_Connector_mc7601 Connector(PROGRAM);
	if (!Connector.isConnected()){
		printf("Connection to mc7601 error!");
		return -1;
	}

	int handshake= Connector.Sync(0xC0DE0086);
	if (handshake!=0xC0DE6406){
		printf("Handshake with mc7601 error!");
		return -1;
	}
	
	if(!VS_Init())
		return 0;

	//if(!VS_Bind("//dragon/distrib/streams/video/720x576/bugs.avi"))
	if(!VS_Bind("../../../../input/bugs720x576x20.avi"))
		return 0;

	int width =VS_GetWidth (VS_SOURCE);
	int height=VS_GetHeight(VS_SOURCE);
	int size  =width*height;

    VS_CreateImage("Source Image", 1, width, height, VS_RGB8, 0);	// Create window for 8-bit source grayscale image
	VS_CreateImage("Sobel  Image", 2, width, height, VS_RGB8, 0);	// Create window for 8-bit result grayscale image

	Connector.Sync(width);		// Send width to nmc
	Connector.Sync(height);		// Send height to nmc
	int ok=Connector.Sync(0);	// Get	status of memory allocation from nm
	if (ok!=0x600DB00F){
		printf("Memory allocation error!");
		return -1;
	}
	unsigned srcAddr=Connector.Sync(0);
	unsigned dstAddr=Connector.Sync(0);
	
	unsigned char*  srcImg8=  new unsigned char [size];
	unsigned char*  dstImg8=  new unsigned char [size];
	
	
	
	while(VS_Run())	{
        VS_GetGrayData(VS_SOURCE, srcImg8);	// Get image from video stream
		VS_SetData(1, srcImg8);				// Put source image in window ?1

		Connector.WriteMemBlock((unsigned*)srcImg8, srcAddr, size/4);
		Connector.Sync(0);
		//... wait while sobel runs on board

		unsigned t=Connector.Sync(0);
		Connector.ReadMemBlock ((unsigned*)dstImg8, dstAddr, size/4);
			
		if (t==0xDEADB00F)
			VS_Text("Memory allocation error in sobel!\n");
		VS_SetData(2, dstImg8);
		VS_Text("%u clocks per frame , %.2f clocks per pixel, %.2f fps", t, 1.0*t/size, 320000000.0/t );
		VS_Draw(VS_DRAW_ALL);
	}

	Connector.close();
	delete srcImg8;
	delete dstImg8;
    return 0;
}
Exemplo n.º 3
0
bool ShapeGraph::readold( std::ifstream& stream, int version )
{
   // read in from old base class
   SpacePixel linemap;
   linemap.read(stream, version);
   const pmap<int,LineTest>& lines = linemap.getAllLines();

   m_name = linemap.getName();

   // now copy to new base class:
   init(lines.size(),linemap.getRegion());
   for (size_t i = 0; i < lines.size(); i++) {
      makeLineShape(lines[i].line);
   }
   // n.b., we now have to reclear attributes!
   m_attributes.clear();

   // continue old read:
   int pushmap = -1;
   if (version >= VERSION_SEGMENT_MAPS) {
      char segmentmapc = stream.get();
      if (segmentmapc == '1') {
         m_map_type = ShapeMap::SEGMENTMAP;
      }
      else {
         m_map_type = ShapeMap::AXIALMAP;
      }
   }
   if (version >= VERSION_GATE_MAPS) {
      char gatemapc = stream.get();
      if (gatemapc == '1') {
         m_map_type = ShapeMap::DATAMAP;
      }
      stream.read((char *)&pushmap,sizeof(pushmap));
   }

   int displayed_attribute;  // n.b., temp variable necessary to force recalc below
   stream.read((char *)&displayed_attribute,sizeof(displayed_attribute));

   m_attributes.read(stream,version);
   int size;
   stream.read((char *)&size,sizeof(size));
   for (int j = 0; j < size; j++) {
      m_keyvertices.push_back(pvecint());    // <- these were stored with the connector
      int key;
      stream.read((char *)&key,sizeof(key)); // <- key deprecated
      m_connectors.push_back(Connector());
      m_connectors[j].read(stream,version,&(m_keyvertices[j]));
   }
   stream.read((char *)&m_keyvertexcount,sizeof(m_keyvertexcount));

   if (version >= VERSION_AXIAL_LINKS) {
      m_links.read(stream);
      m_unlinks.read(stream);
   }
   // some miscellaneous extra data for mapinfo files
   if (m_mapinfodata) {
      delete m_mapinfodata;
      m_mapinfodata = NULL;
   }
   if (version >= VERSION_MAPINFO_DATA) {
      char x = stream.get();
      if (x == 'm') {
         m_mapinfodata = new MapInfoData;
         m_mapinfodata->read(stream,version);
      }
   }

   // now, as soon as loaded, must recalculate our screen display:
   // note m_displayed_attribute should be -2 in order to force recalc...
   m_displayed_attribute = -2;
   setDisplayedAttribute(displayed_attribute);

   return true;
}