Global Mapper v25.0

GM_LoadRectifiedLayer Problems

fxrazno1
fxrazno1 Global Mapper UserTrusted User

Hi

I have this code to load a jpg image (1920X1080) with ground control points and then save it to geotif file.

The first problem is that the saved image is flipped in the X axis.

The second problem is the metadata is incorrect.

I code in Delphi. The @ sign is the address of the data.

Here is the variables:

LLA_Projection:GM_Projection_t;

aGroundControlPoints:Array of GM_GroundControlPoint_t;

aLayerHandle:GM_LayerHandle_t32;


Here is the code :

LLA_Projection.mProjSys:=GM_PRJ_GEO;

LLA_Projection.mDatum :=GM_DATUM_WGS_84;

LLA_Projection.mUnit  :=GM_PRJ_UNIT_ARC_DEGREES;

LLA_Projection.mNumAttrs:=1;

LLA_Projection.mAttrList[0].mAttr:=CENTRAL_LONGITUDE;

LLA_Projection.mAttrList[0].mValue:=0;


GM_SetProjection(@LLA_Projection);

SetLength(aGroundControlPoints,2);

aGroundControlPoints[0].mPixelX:=0;

aGroundControlPoints[0].mPixelY:=0;

aGroundControlPoints[0].mGroundX:=77.115;

aGroundControlPoints[0].mGroundY:=28.725;


aGroundControlPoints[1].mPixelX:=0;

aGroundControlPoints[1].mPixelY:=0;

aGroundControlPoints[1].mGroundX:=77.125;

aGroundControlPoints[1].mGroundY:=28.715;


aLoadFlags:=GM_LoadFlags_HideProgress;

GM_LoadRectifiedLayer(StringToPAnsiChar('C:\Temp\test.jpg'),

@aLayerHandle,aLoadFlags,

@aGroundControlPoints,2,

@LLA_Projection);


theErr:=GM_ExportRaster(StringToPAnsiChar('C:\Temp\test.tif'),

            GM_Export_GeoTIFF,

            aLayerHandle,

            Nil,

            1920,

            1080,

            GM_ExportFlags_HideProgress);

GM_CloseLayer(aLayerHandle);

Above is the Original JPG

Below is the file I got.

Can you help please ?

Thanks Allot

Raz

Answers

  • fxrazno1
    fxrazno1 Global Mapper User Trusted User

  • fxrazno1
    fxrazno1 Global Mapper User Trusted User

    I can not load the tif file for some reason....I tried rar and zip

  • BMGVictor
    BMGVictor Global Mapper User

    It looks like your referencing for the jpg image is not correct:

    aGroundControlPoints[0].mPixelX:=0;

    aGroundControlPoints[0].mPixelY:=0;

    and

    aGroundControlPoints[1].mPixelX:=0;

    aGroundControlPoints[1].mPixelY:=0;


    are referencing the same pixel value, [0,0]. Those should line up with the specific locations in the mGround values, so maybe the first one should be [0,0], and the second should be [imagewidth,imageheight]?

  • fxrazno1
    fxrazno1 Global Mapper User Trusted User

    Hi

    I copied from my code by mistake 0,0

    It is 1920,1080

    aGroundControlPoints[1].mPixelX:=1920;

    aGroundControlPoints[1].mPixelY:=1080;

    is there a way I can send you the tif file I am getting ?

    Thanks

  • BMGVictor
    BMGVictor Global Mapper User

    Please send your sample code and source data to geohelp@bluemarblegeo.com . We can take a look and try to help figure out what is going on.

  • fxrazno1
    fxrazno1 Global Mapper User Trusted User

    Hi

    Just send you the code and files.

    The subject of the email is:

    GM_LoadRectifiedLayer Problems Question By Raz Tidhar

    Thanks

    Raz

  • fxrazno1
    fxrazno1 Global Mapper User Trusted User

    Hi

    I just my problem.

    I have defined the control points as a dynamic array and the function didn't take the correct values.

    Changed

    aGroundControlPoints:Array of GM_GroundControlPoint_t;

    To

    aGroundControlPoints:Array[0..1] of GM_GroundControlPoint_t;

    Anyway...

    Thanks allot for your help !

    Raz

  • fxrazno1
    fxrazno1 Global Mapper User Trusted User

    One more question

    Is it possible when saving to tif file to say that the white area will be transparent when loading ?

    Thanks

    Raz