示例#1
0
bool ConvertADT(char *filename, char *filename2)
{
    if(!LoadADT(filename))
        return false;

    FILE *output=fopen(filename2, "wb");
    if(!output)
    {
        printf("Can't create the output file '%s'\n", filename2);
        delete [] MapLiqHeight;
        delete [] MapLiqFlag;
        return false;
    }

    // write magic header
    fwrite(MAP_MAGIC, 1, 8, output);

    for(uint32 x = 0; x < 16; ++x)
    {
        for(uint32 y = 0; y < 16; ++y)
        {
            if(mcells->ch[y][x].area_id && mcells->ch[y][x].area_id <= maxAreaId)
            {
                if(areas[mcells->ch[y][x].area_id] == 0xffff)
                    printf("\nCan't find area flag for areaid %u.\n", mcells->ch[y][x].area_id);

                fwrite(&areas[mcells->ch[y][x].area_id], 1, 2, output);
            }
            else
            {
                uint16 flag = 0xffff;
                fwrite(&flag, 1, 2, output);
            }
        }
    }

    fwrite(MapLiqFlag, 1, 256, output);
    delete [] MapLiqFlag;

    fwrite(MapLiqHeight, sizeof(float), 16384, output);
    delete [] MapLiqHeight;

    TransformData();

    fwrite(&cell->v9, 1, sizeof(cell->v9), output);
    fwrite(&cell->v8, 1, sizeof(cell->v8), output);
    fclose(output);
    delete cell;

    return true;
}
STDMETHODIMP AbstractTransformInputPin::Receive(IMediaSample* inSample) 
{
	CAutoLock locLock(mStreamLock);

	HRESULT locHR = CheckStreaming();

	if (locHR == S_OK) {
		BYTE* locBuff = NULL;
		locHR = inSample->GetPointer(&locBuff);

		if (locHR != S_OK) {
			//TODO::: Do a debug dump or something here with specific error info.
			return locHR;
		} 
		else 
		{
			/* Read DirectShow timestamps */
			REFERENCE_TIME pTimeStart, pTimeEnd;
			if (inSample->GetTime(&pTimeStart, &pTimeEnd) == NOERROR) 
			{
				m_dsTimeStart = pTimeStart/10000;
				m_dsTimeEnd = pTimeEnd/10000;
			}

            //http://windowssdk.msdn.microsoft.com/en-us/library/ms787541.aspx
            //Consider using receive to validate conditions ^^^
			HRESULT locResult = TransformData(locBuff, inSample->GetActualDataLength());
			if (locResult == S_OK) {
				return S_OK;
			} else {
				return S_FALSE;
			}
		}
	} else {
		//Not streaming - Bail out.
		return S_FALSE;
	}
}
示例#3
0
const LandmarkCollectionDataPtr ImageTransformer::TransformCollectionUsingFaceCrop(const LandmarkCollectionDataPtr& collectionData)
{
  LandmarkCollectionDataPtr newCollection(new LandmarkCollectionData(collectionData->CollectionSize()));
  
  CascadeClassifier classifier;
  collectionData->EnumerateConstColectionWithCallback([&] (const ImageLandmarkDataPtr& landmarkData, const int index, bool* stop) {

    const cv::Rect activeRect = classifier.DetectFace(landmarkData->ImageSource());
    if (activeRect.size().width != 0)
    {
      const ImageLandmarkDataPtr newData = TransformData(landmarkData, activeRect, {kImageSize, kImageSize}, true);
      newCollection->AddImageLandmarkData(newData);
    }
    else
    {
      std::cout<<"Face not found: "<<landmarkData->ImagePath()<<std::endl;
    }
    
    std::cout<<index<<std::endl;
  });
  
  return newCollection;
}
示例#4
0
文件: adt.cpp 项目: Anderss/mangos
bool ConvertADT(char * filename,char * filename2)
{
    //if(!strstr(filename,"oth_32_48"))return false;
    if(!LoadADT(filename))
        return false;

    FILE *output=fopen(filename2,"wb");
    if(!output)
    {
        printf("Can't create the output file '%s'\n",filename2);
        return false;
    }

    // write magic header
    fwrite(MAP_MAGIC,1,8,output);

    for(unsigned int x=0;x<16;x++)
    {
        for(unsigned int y=0;y<16;y++)
        {
            if(mcells->ch[y][x].area_id && mcells->ch[y][x].area_id < 0x102D)
            {
                if(areas[mcells->ch[y][x].area_id]==0xffff)
                    printf("\nCan't find area flag for areaid %u.\n",mcells->ch[y][x].area_id);

                fwrite(&areas[mcells->ch[y][x].area_id],1,2,output);
            }
            else
            {
                uint16 flag=0xffff;
                fwrite(&flag,1,2,output);
            }
        }
    }

    for(unsigned int x=0;x<16;x++)
        for(unsigned int y=0;y<16;y++)
            fwrite(&mcells->ch[y][x].flag,1,1,output);

    TransformWaterData();

    for(unsigned int x=0;x<128;x++)
        for(unsigned int y=0;y<128;y++)
            fwrite(&cell->v9[y][x],1,sizeof(float),output);

    delete cell;
    TransformData();

    for(unsigned int x=0;x<iRes;x++)
    for(unsigned int y=0;y<iRes;y++)
    {
        float z=(float)GetZ(
                    (((double)(y))*TILESIZE)/((double)(iRes-1)),
                    (((double)(x))*TILESIZE)/((double)(iRes-1)));

        fwrite(&z,1,sizeof(z),output);
    }

    fclose(output);
    delete cell;
/*
    for (std::vector<std::string>::iterator it = wmos.begin(); it != wmos.end(); ++it)
    wmomanager.delbyname(*it);

    wmos.clear();
    wmois.clear();

    for (std::vector<model>::iterator it = wmomodel.begin(); it != wmomodel.end(); ++it)
    {
        it->tr.clear();

    }
    //printf("\n %d \n",in);
    wmomodel.clear();
    //polygons.clear();*/
    return true;
}
示例#5
0
bool ConvertADT(uint32 x, uint32 y, FILE * out_file, char* name)
{
    // Figure out what rock we're under :P
    uint32 tile_x = x / CellsPerTile;
    uint32 tile_y = y / CellsPerTile;

    // For some odd reason, this stuff is reversed.. who knows why..
    char mpq_filename[256];
    sprintf(mpq_filename, "World\\Maps\\%s\\%s_%u_%u.adt", name, name, tile_y, tile_x);
    
    // See if we have it cached first.
    if(mcell_cache[tile_y][tile_x] == 0 && cell_cache[tile_y][tile_x] == 0)
    {
        if(!LoadADT(mpq_filename))
            return false;

        TransformData();
        mcell_cache[tile_y][tile_x] = mcells;

        // Cache z information.
        cz = new zstore;
        for(uint32 cx = 0; cx < MAP_RESOLUTION; ++cx)
        {
            for(uint32 cy = 0; cy < MAP_RESOLUTION; ++cy)
            {
                float cfz=(float)GetZ(
                    (((double)(cy))*TILESIZE)/((double)(iRes-1)),
                    (((double)(cx))*TILESIZE)/((double)(iRes-1)));
                cz->z[cx][cy] = cfz;
            }
        }

        cell_cache[tile_y][tile_x] = cz;
        delete cell;
    }
    else
    {
        mcells = mcell_cache[tile_y][tile_x];
        cz = cell_cache[tile_y][tile_x];
    }

    // This is our output data.
    MapCellInfo out;

    // Write out the area/water information.
    for(uint32 xc=(x%CellsPerTile)*16/CellsPerTile;xc<(x%CellsPerTile)*16/CellsPerTile+16/CellsPerTile;xc++)
    {
        for(uint32 yc=(y%CellsPerTile)*16/CellsPerTile;yc<(y%CellsPerTile)*16/CellsPerTile+16/CellsPerTile;yc++)
        {
            uint32 lx=xc%(16/CellsPerTile);
            uint32 ly=yc%(16/CellsPerTile);
            out.AreaID[lx][ly] = mcells->ch[yc][xc].area_id;
            out.LiquidType[lx][ly] = mcells->ch[yc][xc].flag;
            out.LiquidLevel[ly][ly] = mcells->ch[yc][xc].waterlevel;
        }
    }


    // Convert it into antrix cell format.
    for(uint32 cx=(x%CellsPerTile)*MAP_RESOLUTION/CellsPerTile;cx<(x%CellsPerTile)*MAP_RESOLUTION/CellsPerTile+MAP_RESOLUTION/CellsPerTile;cx++)
    {
        for(uint32 cy=(y%CellsPerTile)*MAP_RESOLUTION/CellsPerTile;cy<(y%CellsPerTile)*MAP_RESOLUTION/CellsPerTile+MAP_RESOLUTION/CellsPerTile;cy++)
        {
            uint32 lx=cx%(MAP_RESOLUTION/CellsPerTile);
            uint32 ly=cy%(MAP_RESOLUTION/CellsPerTile);
            out.Z[lx][ly] = cz->z[cx][cy];
        }
    }

    // Write out to file.
    fwrite(&out, sizeof(out), 1, out_file);
	return true;
}