Exemplo n.º 1
0
// ######################################################################
void PrefrontalCortexOG::
onSimEventInputFrame(SimEventQueue& q, rutz::shared_ptr<SimEventInputFrame>& e)
{
  GenericFrame gf = e->frame();
  rutz::shared_ptr<GenericFrame::MetaData>
    metaData = gf.getMetaData(std::string("SceneData"));
  if (metaData.get() != 0) {
    rutz::shared_ptr<TestImages::SceneData> sceneData;
    sceneData.dyn_cast_from(metaData);

    // Train on all objects in the scene
    // Build the target and distractor mask, if multiple objects then add
    // which ever matches the target string to the target mask, and distractor string to
    // distractor mask. If no strings are spacified, then build from all objects and/or distractor
    // that is complmant the object

    itsDistractorMask = Image<byte>(sceneData->dims, ZEROS);
    itsTargetMask = Image<byte>(sceneData->dims, ZEROS);

    for (uint i = 0; i < sceneData->objects.size(); i++) {
      TestImages::ObjData objData = sceneData->objects[i];

      // get the target mask, either it was provided as a mask image:
      if (objData.objmask.initialized())
      {
        LINFO("Drawing target mask from B/W mask file data...");
        itsTargetMask += objData.objmask;
      }

      // ... and/or with a polygon:
      if (objData.polygon.empty() == false) {
        LINFO("Drawing target mask from polygon data from %s...", objData.name.c_str());
        if (itsTargetMaskObjName.getVal().size() > 0 &&
            objData.name == itsTargetMaskObjName.getVal())
          drawFilledPolygon(itsTargetMask, objData.polygon, byte(255));

        if (itsTargetMaskObjName.getVal().size() == 0)
          drawFilledPolygon(itsTargetMask, objData.polygon, byte(255));
      }

      if (itsDistractorMaskObjName.getVal().size() > 0 &&
          objData.name == itsDistractorMaskObjName.getVal())
      {
        LINFO("Drawing distractor mask from polygon data from %s...", objData.name.c_str());
        drawFilledPolygon(itsDistractorMask, objData.polygon, byte(255));
      }
    }

    if (itsDistractorMaskObjName.getVal().size() == 0)
    {
      // Create a distractor mask from 255-targetMask:
      itsDistractorMask.clear(255);
      itsDistractorMask -= itsTargetMask;
    }
  }
}
Exemplo n.º 2
0
void drawUFO(point pos, short scale){
	point topL, topR, midTL, midTR, midBL, midBR, botL, botR;
	point myUFO[8]; 
	topL =	makePoint(pos.x-scale*2, pos.y-3*scale);
	topR =  makePoint(pos.x+scale*2, pos.y-3*scale);
	midTL=	makePoint(pos.x-scale*3, pos.y-1*scale);
	midTR=  makePoint(pos.x+scale*3, pos.y-1*scale);
	midBL=  makePoint(pos.x-scale*6, pos.y+1*scale);
	midBR=  makePoint(pos.x+scale*6, pos.y+1*scale);
	botL =  makePoint(pos.x-scale*4, pos.y+3*scale);
	botR =  makePoint(pos.x+scale*4, pos.y+3*scale);
	myUFO[0] = topL;
	myUFO[1] = topR;
	myUFO[2] = midTR;
	myUFO[3] = midBR;
	myUFO[4] = botR;
	myUFO[5] = botL;
	myUFO[6] = midBL;
	myUFO[7] = midTL;
	if(getSetting() >= 1) {
		drawFilledPolygon(myUFO, 8, PLAYER_SHADE);
	} else {
		drawPolygon(myUFO, 8, PLAYER_SHADE);
	}
	drawLine(makePoint(pos.x-scale*3, pos.y-1*scale),
					 makePoint(pos.x+scale*3, pos.y-1*scale),	0xF);
	drawLine(makePoint(pos.x-scale*6, pos.y+1*scale),
					 makePoint(pos.x+scale*6, pos.y+1*scale), 0xF);
}
Exemplo n.º 3
0
// ######################################################################
void TaskRelevanceMapSocial::inputFrame(const InputFrame& f)
{
  const Dims mapdims = f.getDims();
  const int sml = itsLevelSpec.getVal().mapLevel();
  const float EyeVal = 128.0F, MouthVal = 64.0F, FaceVal = 32.0F, BodyVal = 16.0F, PersonVal = 4.0F, BkgdVal = 1.0F;

  Image<float> BigMap;
  BigMap.resize(mapdims, true); 
  BigMap.clear(1.0F);
  
  Scene sceneData =
    itsObjectsInfo->getSceneData(itsFrame);

  // loop through all the regions on a given frame and assign z-stack order
  std::vector<float> weights(itsNumObjects, 1.0F);
  for (std::vector<Object>::iterator itrObject = sceneData.objects.begin(); itrObject != sceneData.objects.end(); itrObject++) {

    uint idx = (*itrObject).id;
    std::string ObjName = toLowerCase(itsObjectsNames[idx]);
    if (ObjName.find("eye") != std::string::npos) {weights[idx] = EyeVal;}
    else if (ObjName.find("mouth") != std::string::npos) {weights[idx] = MouthVal;}
    else if (ObjName.find("head") != std::string::npos || 
             ObjName.find("face") != std::string::npos) {weights[idx] = FaceVal;}
    else if (ObjName.find("body") != std::string::npos) {weights[idx] = BodyVal;}
    else if (ObjName.find("person") != std::string::npos ||
             ObjName.find("people") != std::string::npos ||
             ObjName.find("man") != std::string::npos ||
             ObjName.find("woman") != std::string::npos) {weights[idx] = PersonVal;}
    else {weights[idx] = BkgdVal;}
  }
  uint i,j,tmp;
  // sort z-stack weights

  const uint numInScene = sceneData.objects.size();
  std::vector<uint> zorder(numInScene);
  for (i = 0; i < numInScene; i++) zorder[i] = i;
  for (i = 0; i < numInScene; i++)  
    for (j = 0; j < numInScene-i-1; j++) 
      if(weights[sceneData.objects[zorder[j]].id] > 
         weights[sceneData.objects[zorder[j+1]].id]) {
        tmp = zorder[j];
        zorder[j] = zorder[j+1];
        zorder[j+1] = tmp;
      }  
  
  // fill BigMap from bottom of z-stack to top
  // todo: enforce C0/C1 continuity by some poisson problem?
  for (i = 0; i < numInScene; i++) {
    Object iObj = sceneData.objects[zorder[i]]; 
    drawFilledPolygon(BigMap, iObj.polygon, weights[iObj.id]);
  }
  
  itsMap = rescale(BigMap, mapdims.w() >> sml, mapdims.h() >> sml);
  itsFrame++;
}
Exemplo n.º 4
0
void drawRock(point pos, unsigned short version, unsigned short size) {
	point myRock[ROCK_VERTICIES]; int i = 0;
	version %= ROCK_TYPES;
	for(i = 0; i < ROCK_VERTICIES; i++) {
		myRock[i] = makePoint(pos.x+size*rockShapes[version][i].x,
													pos.y+size*rockShapes[version][i].y);
	}
	if(getSetting() >= 1) {
		drawFilledPolygon(myRock, ROCK_VERTICIES, ROCK_SHADE);
	} else {
		drawPolygon(myRock, ROCK_VERTICIES, ROCK_SHADE+randRange(0,1));
	}
}
Exemplo n.º 5
0
void drawPlayerExhaust(point pos, short angle) {
	point innerVertex, outerVertex, port, starboard, exhaust;
	point innerFire[4], outerFire[4];
	outerVertex = rotPoint(pos, angle, makePoint(pos.x-7, pos.y));
	port = rotPoint(pos, angle, makePoint(pos.x-5, pos.y-3));
	starboard = rotPoint(pos, angle, makePoint(pos.x-5, pos.y+3));
	exhaust = rotPoint(pos, angle, makePoint(pos.x-3, pos.y));
	outerFire[0] = outerVertex;
	outerFire[1] = port;
	outerFire[2] = exhaust;
	outerFire[3] = starboard;
	if(getSetting() >= 1) {
		innerVertex = rotPoint(pos, angle, makePoint(pos.x-5, pos.y));
		innerFire[0] = innerVertex;
		innerFire[1] = port;
		innerFire[2] = exhaust;
		innerFire[3] = starboard;
		drawFilledPolygon(outerFire, 4, PLAYER_EXHAUST_SHADE2);
		drawFilledPolygon(innerFire, 4, PLAYER_EXHAUST_SHADE);
	} else {
		drawLine(outerVertex, port, PLAYER_EXHAUST_SHADE);
		drawLine(outerVertex, starboard, PLAYER_EXHAUST_SHADE);
	}
}
Exemplo n.º 6
0
void ossimRgbImage::drawFilledArc (int cx,
                                   int cy,
                                   int w,
                                   int h,
                                   int s,
                                   int e)
{
   if(!theImageData)
   {
      return;
   }
   ossimIpt pts[3];
   int i;
   int lx = 0, ly = 0;
   // int fx, fy;
   int w2, h2;
   w2 = w / 2;
   h2 = h / 2;
   while (e < s)
   {
      e += 360;
   }
   for (i = s; (i <= e); i++)
   {
      int x, y;
      x = ((ossim_int32) gdCosT[i % 360] * (ossim_int32) w2 / 1024) + cx;
      y = ((ossim_int32) gdSinT[i % 360] * (ossim_int32) h2 / 1024) + cy;
      if (i != s)
      {
         /* This is expensive! */
         pts[0].x = lx;
         pts[0].y = ly;
         pts[1].x = x;
         pts[1].y = y;
         pts[2].x = cx;
         pts[2].y = cy;
         drawFilledPolygon (pts, 3);
      }
      // else
      // {
      //   fx = x;
      //   fy = y;
      // }
      lx = x;
      ly = y;
   }
}
Exemplo n.º 7
0
void ossimRgbImage::drawFilledEllipse (int cx,
                                       int cy,
                                       int axisMinor,
                                       int axisMajor,
                                       double rot)
{
   if(!theImageData)
   {
      return;
   }
   
   int lx = 0;
   int ly = 0;
   int w2 = axisMinor/2;
   int h2 = axisMajor/2;
   ossimIpt pts[3];
   
   float sinRot = sin(rot);
   float cosRot = cos(rot);
   
   for (int i = 0; i <= 360; ++i)
   {
      int x = ((ossim_int32) gdCosT[i % 360] * (ossim_int32) w2 / 1024);
      int y = ((ossim_int32) gdSinT[i % 360] * (ossim_int32) h2 / 1024);
      
      int rx = (ossim_int32)((float)x*cosRot - (float)y*sinRot + cx);
      int ry = (ossim_int32)((float)y*cosRot + (float)x*sinRot + cy);
      
      if (i != 0)
      {
         /* This is expensive! */
         pts[0].x = lx;
         pts[0].y = ly;
         pts[1].x = rx;
         pts[1].y = ry;
         pts[2].x = cx;
         pts[2].y = cy;
         
         drawFilledPolygon (pts, 3);
      }
      lx = rx;
      ly = ry;
   }
}
Exemplo n.º 8
0
void drawPlayer(point pos, short angle, bool doExhaust) {		//At angle = 0, player faces to the right.
	point vertex, port, starboard, exhaust;
	point myShip[4];
	vertex = rotPoint(pos, angle, makePoint(pos.x+6, pos.y));
	port = rotPoint(pos, angle, makePoint(pos.x-5, pos.y-5));
	starboard = rotPoint(pos, angle, makePoint(pos.x-5, pos.y+5));
	exhaust = rotPoint(pos, angle, makePoint(pos.x-3, pos.y));
	myShip[0] = vertex;
	myShip[1] = port;
	myShip[2] = exhaust;
	myShip[3] = starboard;
	if(getSetting() >= 1) {
		drawFilledPolygon(myShip, 4, PLAYER_SHADE);
	} else {
		drawPolygon(myShip, 4, PLAYER_SHADE);
	}
	if(doExhaust) {
		if(isExhaustOn) {
			drawPlayerExhaust(pos, angle);
		}
		isExhaustOn ^= 1; //Flip the bit.
	}
}