KlassenKlassenKlassenKlassen | | | | Operatoren

gen_image_to_world_plane_mapT_gen_image_to_world_plane_mapGenImageToWorldPlaneMapgen_image_to_world_plane_mapGenImageToWorldPlaneMapGenImageToWorldPlaneMap (Operator)

Name

gen_image_to_world_plane_mapT_gen_image_to_world_plane_mapGenImageToWorldPlaneMapgen_image_to_world_plane_mapGenImageToWorldPlaneMapGenImageToWorldPlaneMap — Berechnen der Abbildung von der Bildebene in die Ebene z=0 eines Weltkoordinatensystems.

Signatur

gen_image_to_world_plane_map( : Map : CameraParam, WorldPose, WidthIn, HeightIn, WidthMapped, HeightMapped, Scale, MapType : )

Herror T_gen_image_to_world_plane_map(Hobject* Map, const Htuple CameraParam, const Htuple WorldPose, const Htuple WidthIn, const Htuple HeightIn, const Htuple WidthMapped, const Htuple HeightMapped, const Htuple Scale, const Htuple MapType)

Herror gen_image_to_world_plane_map(Hobject* Map, const HTuple& CameraParam, const HTuple& WorldPose, const HTuple& WidthIn, const HTuple& HeightIn, const HTuple& WidthMapped, const HTuple& HeightMapped, const HTuple& Scale, const HTuple& MapType)

HImage HImage::GenImageToWorldPlaneMap(const HTuple& CameraParam, const HTuple& WorldPose, const HTuple& WidthIn, const HTuple& HeightIn, const HTuple& WidthMapped, const HTuple& HeightMapped, const HTuple& Scale, const HTuple& MapType)

void GenImageToWorldPlaneMap(HObject* Map, const HTuple& CameraParam, const HTuple& WorldPose, const HTuple& WidthIn, const HTuple& HeightIn, const HTuple& WidthMapped, const HTuple& HeightMapped, const HTuple& Scale, const HTuple& MapType)

void HImage::GenImageToWorldPlaneMap(const HTuple& CameraParam, const HPose& WorldPose, Hlong WidthIn, Hlong HeightIn, Hlong WidthMapped, Hlong HeightMapped, const HTuple& Scale, const HString& MapType)

void HImage::GenImageToWorldPlaneMap(const HTuple& CameraParam, const HPose& WorldPose, Hlong WidthIn, Hlong HeightIn, Hlong WidthMapped, Hlong HeightMapped, const HString& Scale, const HString& MapType)

void HImage::GenImageToWorldPlaneMap(const HTuple& CameraParam, const HPose& WorldPose, Hlong WidthIn, Hlong HeightIn, Hlong WidthMapped, Hlong HeightMapped, const char* Scale, const char* MapType)

HImage HPose::GenImageToWorldPlaneMap(const HTuple& CameraParam, Hlong WidthIn, Hlong HeightIn, Hlong WidthMapped, Hlong HeightMapped, const HTuple& Scale, const HString& MapType) const

HImage HPose::GenImageToWorldPlaneMap(const HTuple& CameraParam, Hlong WidthIn, Hlong HeightIn, Hlong WidthMapped, Hlong HeightMapped, const HString& Scale, const HString& MapType) const

HImage HPose::GenImageToWorldPlaneMap(const HTuple& CameraParam, Hlong WidthIn, Hlong HeightIn, Hlong WidthMapped, Hlong HeightMapped, const char* Scale, const char* MapType) const

void HOperatorSetX.GenImageToWorldPlaneMap(
[out] IHUntypedObjectX*Map, [in] VARIANT CameraParam, [in] VARIANT WorldPose, [in] VARIANT WidthIn, [in] VARIANT HeightIn, [in] VARIANT WidthMapped, [in] VARIANT HeightMapped, [in] VARIANT Scale, [in] VARIANT MapType)

void HImageX.GenImageToWorldPlaneMap(
[in] VARIANT CameraParam, [in] VARIANT WorldPose, [in] Hlong WidthIn, [in] Hlong HeightIn, [in] Hlong WidthMapped, [in] Hlong HeightMapped, [in] VARIANT Scale, [in] BSTR MapType)

IHImageX* HPoseX.GenImageToWorldPlaneMap(
[in] VARIANT CameraParam, [in] VARIANT WorldPose, [in] Hlong WidthIn, [in] Hlong HeightIn, [in] Hlong WidthMapped, [in] Hlong HeightMapped, [in] VARIANT Scale, [in] BSTR MapType)

static void HOperatorSet.GenImageToWorldPlaneMap(out HObject map, HTuple cameraParam, HTuple worldPose, HTuple widthIn, HTuple heightIn, HTuple widthMapped, HTuple heightMapped, HTuple scale, HTuple mapType)

void HImage.GenImageToWorldPlaneMap(HTuple cameraParam, HPose worldPose, int widthIn, int heightIn, int widthMapped, int heightMapped, HTuple scale, string mapType)

void HImage.GenImageToWorldPlaneMap(HTuple cameraParam, HPose worldPose, int widthIn, int heightIn, int widthMapped, int heightMapped, string scale, string mapType)

HImage HPose.GenImageToWorldPlaneMap(HTuple cameraParam, int widthIn, int heightIn, int widthMapped, int heightMapped, HTuple scale, string mapType)

HImage HPose.GenImageToWorldPlaneMap(HTuple cameraParam, int widthIn, int heightIn, int widthMapped, int heightMapped, string scale, string mapType)

Beschreibung

gen_image_to_world_plane_mapgen_image_to_world_plane_mapGenImageToWorldPlaneMapgen_image_to_world_plane_mapGenImageToWorldPlaneMapGenImageToWorldPlaneMap errechnet die Abbildung MapMapMapMapMapmap von der Bildebene in die Ebene z=0 (Messebene) eines Weltkoordinatensystems. Diese Abbildung kann z.B. dazu verwendet werden kann, ein Bild mit dem Operator map_imagemap_imageMapImagemap_imageMapImageMapImage zu rektifizieren. Das rektifizierte Bild weist dann weder radiale noch perspektivische Verzerrungen auf; es entspricht einem Bild, das von einer verzerrungsfreien Kamera aufgenommen wird, die senkrecht auf die Messebene im Weltkoordinatensystem schaut. Das Weltkoordinatensystem wird gewählt, indem man seine 3D-Lage in Kamerakoordinaten in WorldPoseWorldPoseWorldPoseWorldPoseWorldPoseworldPose übergibt. In CameraParamCameraParamCameraParamCameraParamCameraParamcameraParam müssen die internen Kameraparameter übergeben werden (siehe write_cam_parwrite_cam_parWriteCamParwrite_cam_parWriteCamParWriteCamPar für ihre Reihenfolge und das zu Grunde liegende Kameramodell).

In vielen Fällen sind CameraParamCameraParamCameraParamCameraParamCameraParamcameraParam und WorldPoseWorldPoseWorldPoseWorldPoseWorldPoseworldPose das Ergebnis einer vorherigen Kamerakalibrierung mit dem Operator calibrate_camerascalibrate_camerasCalibrateCamerascalibrate_camerasCalibrateCamerasCalibrateCameras. Ein Beispiel findet sich weiter unten.

Die Größe der zu transformierenden Bilder kann mit WidthInWidthInWidthInWidthInWidthInwidthIn und HeightInHeightInHeightInHeightInHeightInheightIn angegeben werden. Die Pixel-Position der linken oberen Ecke des Ergebnisbildes ist durch den Ursprung des Weltkoordinatensystems festgelegt. Die Ausdehnung des Ergebnisbildes kann durch die Parameter WidthMappedWidthMappedWidthMappedWidthMappedWidthMappedwidthMapped, HeightMappedHeightMappedHeightMappedHeightMappedHeightMappedheightMapped und ScaleScaleScaleScaleScalescale gewählt werden. Dabei sind WidthMappedWidthMappedWidthMappedWidthMappedWidthMappedwidthMapped und HeightMappedHeightMappedHeightMappedHeightMappedHeightMappedheightMapped in Pixel anzugeben.

Mit dem Parameter ScaleScaleScaleScaleScalescale kann die Größe eines Pixels im transformierten Bild festgelegt werden. Hierbei gibt es zwei typische Szenarien: Erstens kann das Bild so skaliert werden, dass Pixelkoordinaten im transformierten Bild direkt in einer metrischen Einheit vorliegen, dass ein Pixel also z.B. einem Mikrometer entspricht. Dies ist nützlich, falls im transformierten Bild Messaufgaben durchgeführt werden sollen, deren Ergebnisse dann automatisch in metrischen Einheiten vorliegen. Im zweiten Szenario skaliert man das Bild so, dass sein Inhalt im transformierten Bild in ähnlicher Größe vorliegt wie im Originalbild. Diese Art der Skalierung ist z.B. günstig, wenn man im transformierten Bild formbasiertes Matching anwenden will.

ScaleScaleScaleScaleScalescale entspricht dem Verhältnis gewünschte Pixelgröße/ursprüngliche Einheit. Ein Pixelgröße von 1um heißt, dass ein Pixel im transformierten Bild der Fläche 1um x 1um in der Messebene entspricht. Die ursprüngliche Einheit ist durch die Koordinaten des Kalibrierkörpers gegeben. Falls dies, wie bei der Standard-Kalibrierplatte, Meter sind, ist es auch möglich, die gewünschte Einheit der Pixelkoordinaten direkt durch 'm'"m""m""m""m""m", 'cm'"cm""cm""cm""cm""cm", 'mm'"mm""mm""mm""mm""mm", 'microns'"microns""microns""microns""microns""microns" oder 'um'"um""um""um""um""um" anzugeben.

Die Abbildungsvorschrift wird in dem Ausgabebild MapMapMapMapMapmap gespeichert. Dieses hat die gleiche Größe wie die Ergebnisbilder nach der Abbildung. Der Parameter MapTypeMapTypeMapTypeMapTypeMapTypemapType gibt an, in welchem Typ die Abbildungsvorschrift gespeichert werden soll. Wurde 'nearest_neighbor'"nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor" gewählt, so besteht MapMapMapMapMapmap aus einem Bild mit einem Kanal, in dem für jedes Pixel des Ergebnisbildes die linearen Koordinaten desjenigen Pixels des Eingabebildes stehen, welches den transformierten Koordinaten am nächsten liegt. Wurde die bilineare Interpolation ('bilinear'"bilinear""bilinear""bilinear""bilinear""bilinear") gewählt, so besteht MapMapMapMapMapmap aus einem Bild mit fünf Kanälen. Der erste Kanal enthält für jedes Pixel des Ergebnisbildes die linearen Koordinaten desjenigen Pixels des Eingabebildes, welches links oberhalb von den transformierten Koordinaten liegt. Die übrigen vier Kanäle enthalten die Gewichte der einzelnen vier Nachbarpixel der transformierten Koordinaten für die bilineare Interpolation in folgender Reihenfolge:

+---+---+
| 2 | 3 |
+---+---+
| 4 | 5 |
+---+---+

Der zweite Kanal z.B. enthält die Gewichte der Pixel, die links oberhalb der transformierten Koordinaten liegen. Wurde 'coord_map_sub_pix'"coord_map_sub_pix""coord_map_sub_pix""coord_map_sub_pix""coord_map_sub_pix""coord_map_sub_pix" gewählt, besteht MapMapMapMapMapmap aus einem Vektorfeld, welches für jedes Pixel des Ergebnisbildes die subpixelgenauen Koordinaten im Eingabebild enthält.

Sollen mehrere Bilder unter Verwendung derselben Parameter transformiert werden, so ist die Kombination aus gen_image_to_world_plane_mapgen_image_to_world_plane_mapGenImageToWorldPlaneMapgen_image_to_world_plane_mapGenImageToWorldPlaneMapGenImageToWorldPlaneMap und map_imagemap_imageMapImagemap_imageMapImageMapImage wesentlich effizienter als der Operator image_to_world_planeimage_to_world_planeImageToWorldPlaneimage_to_world_planeImageToWorldPlaneImageToWorldPlane, da die Abbildungsvorschrift nur einmal berechnet werden muss.

Wenn die erzeugte Abbildung in einem anderen Programm wiederverwendet werden soll, kann man sie mit dem Operator write_imagewrite_imageWriteImagewrite_imageWriteImageWriteImage als Mehrkanalbild abspeichern (Format: 'tiff'"tiff""tiff""tiff""tiff""tiff").

Parallelisierung

Parameter

MapMapMapMapMapmap (output_object)  (multichannel-)image objectHImageHImageHImageHImageXHobject * (int4 / int8 / uint2 / vector_field)

Bild mit den Abbildungsdaten.

CameraParamCameraParamCameraParamCameraParamCameraParamcameraParam (input_control)  number-array HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Interne Kameraparameter.

Parameteranzahl: CameraParam == 8 || CameraParam == 11 || CameraParam == 12

WorldPoseWorldPoseWorldPoseWorldPoseWorldPoseworldPose (input_control)  pose HPose, HTupleHTupleHTupleHPoseX, VARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

3D-Lage des Weltkoordinatensystems in Kamerakoordinaten.

Parameteranzahl: 7

WidthInWidthInWidthInWidthInWidthInwidthIn (input_control)  extent.x HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Breite der zu transformierenden Bilder.

Restriktion: WidthIn >= 1

HeightInHeightInHeightInHeightInHeightInheightIn (input_control)  extent.y HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Höhe der zu transformierenden Bilder.

Restriktion: HeightIn >= 1

WidthMappedWidthMappedWidthMappedWidthMappedWidthMappedwidthMapped (input_control)  extent.x HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Breite der Ergebnisbilder in Pixel.

Restriktion: WidthMapped >= 1

HeightMappedHeightMappedHeightMappedHeightMappedHeightMappedheightMapped (input_control)  extent.y HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Höhe der Ergebnisbilder in Pixel.

Restriktion: HeightMapped >= 1

ScaleScaleScaleScaleScalescale (input_control)  number HTupleHTupleHTupleVARIANTHtuple (string / integer / real) (string / int / long / double) (HString / Hlong / double) (char* / Hlong / double) (BSTR / Hlong / double) (char* / Hlong / double)

Maßstab oder Dimension.

Defaultwert: 'm' "m" "m" "m" "m" "m"

Wertevorschläge: 'm'"m""m""m""m""m", 'cm'"cm""cm""cm""cm""cm", 'mm'"mm""mm""mm""mm""mm", 'microns'"microns""microns""microns""microns""microns", 'um'"um""um""um""um""um", 1.0, 0.01, 0.001, 1.0e-6, 0.0254, 0.3048, 0.9144

MapTypeMapTypeMapTypeMapTypeMapTypemapType (input_control)  string HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

Typ der Abbildungsdaten.

Defaultwert: 'bilinear' "bilinear" "bilinear" "bilinear" "bilinear" "bilinear"

Werteliste: 'bilinear'"bilinear""bilinear""bilinear""bilinear""bilinear", 'coord_map_sub_pix'"coord_map_sub_pix""coord_map_sub_pix""coord_map_sub_pix""coord_map_sub_pix""coord_map_sub_pix", 'nearest_neighbor'"nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor"

Beispiel (HDevelop)

*  perform camera calibration (with standard calibration plate)
camera_calibration(NX, NY, NZ, NRow, NCol, StartCamParam, NStartPose, \
                   'all', FinalCamParam, NFinalPose, Errors)
*  world coordinate system is defined by calibration plate in first image
FinalPose1 := NFinalPose[0:6]
*  compensate thickness of plate
set_origin_pose(FinalPose1, 0, 0, 0.000073, WorldPose)
*  goal: rectify images
*  first determine parameters such that the entire image content is visible
*  -> transform image boundary into world plane, determine smallest
*     rectangle around it
get_image_pointer1(Image, Pointer, Type, Width, Height)
gen_rectangle1 (ImageRect, 0, 0, Height-1, Width-1)
gen_contour_region_xld (ImageRect, ImageBorder, 'border')
contour_to_world_plane_xld(ImageBorder, ImageBorderWCS, FinalCamParam, \
                           WorldPose, 1)
smallest_rectangle1_xld (ImageBorderWCS, MinY, MinX, MaxY, MaxX)
*  -> move the pose to the upper left corner of the surrounding rectangle
set_origin_pose(WorldPose, MinX, MinY, 0, PoseForEntireImage)
*  -> determine the scaling factor such that the center pixel has the same
*     size in the original and in the rectified image
*     method: transform corner points of the pixel into the world
*             coordinate system, compute their distances, and use their
*             mean as the scaling factor
image_points_to_world_plane(FinalCamParam, PoseForEntireImage, \
                            [Height/2, Height/2, Height/2+1], \
                            [Width/2, Width/2+1, Width/2], \
                            1, WorldPixelX, WorldPixelY)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[1], WorldPixelX[1], \
            WorldLength1)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[2], WorldPixelX[2], \
            WorldLength2)
ScaleForSimilarPixelSize := (WorldLength1+WorldLength2)/2
*  -> determine output image size such that entire input image fits into it
ExtentX := MaxX-MinX
ExtentY := MaxY-MinY
WidthRectifiedImage := ExtentX/ScaleForSimilarPixelSize
HeightRectifiedImage := ExtentY/ScaleForSimilarPixelSize
*  create mapping with the determined parameters
gen_image_to_world_plane_map(Map, FinalCamParam, PoseForEntireImage, \
                             Width, Height, \
                             WidthRectifiedImage, HeightRectifiedImage, \
                             ScaleForSimilarPixelSize, 'bilinear')
*  transform grabbed images with the created map
while(1)
  grab_image_async(Image, AcqHandle, -1)
  map_image(Image, Map, RectifiedImage)
endwhile

Beispiel (HDevelop)

*  perform camera calibration (with standard calibration plate)
camera_calibration(NX, NY, NZ, NRow, NCol, StartCamParam, NStartPose, \
                   'all', FinalCamParam, NFinalPose, Errors)
*  world coordinate system is defined by calibration plate in first image
FinalPose1 := NFinalPose[0:6]
*  compensate thickness of plate
set_origin_pose(FinalPose1, 0, 0, 0.000073, WorldPose)
*  goal: rectify images
*  first determine parameters such that the entire image content is visible
*  -> transform image boundary into world plane, determine smallest
*     rectangle around it
get_image_pointer1(Image, Pointer, Type, Width, Height)
gen_rectangle1 (ImageRect, 0, 0, Height-1, Width-1)
gen_contour_region_xld (ImageRect, ImageBorder, 'border')
contour_to_world_plane_xld(ImageBorder, ImageBorderWCS, FinalCamParam, \
                           WorldPose, 1)
smallest_rectangle1_xld (ImageBorderWCS, MinY, MinX, MaxY, MaxX)
*  -> move the pose to the upper left corner of the surrounding rectangle
set_origin_pose(WorldPose, MinX, MinY, 0, PoseForEntireImage)
*  -> determine the scaling factor such that the center pixel has the same
*     size in the original and in the rectified image
*     method: transform corner points of the pixel into the world
*             coordinate system, compute their distances, and use their
*             mean as the scaling factor
image_points_to_world_plane(FinalCamParam, PoseForEntireImage, \
                            [Height/2, Height/2, Height/2+1], \
                            [Width/2, Width/2+1, Width/2], \
                            1, WorldPixelX, WorldPixelY)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[1], WorldPixelX[1], \
            WorldLength1)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[2], WorldPixelX[2], \
            WorldLength2)
ScaleForSimilarPixelSize := (WorldLength1+WorldLength2)/2
*  -> determine output image size such that entire input image fits into it
ExtentX := MaxX-MinX
ExtentY := MaxY-MinY
WidthRectifiedImage := ExtentX/ScaleForSimilarPixelSize
HeightRectifiedImage := ExtentY/ScaleForSimilarPixelSize
*  create mapping with the determined parameters
gen_image_to_world_plane_map(Map, FinalCamParam, PoseForEntireImage, \
                             Width, Height, \
                             WidthRectifiedImage, HeightRectifiedImage, \
                             ScaleForSimilarPixelSize, 'bilinear')
*  transform grabbed images with the created map
while(1)
  grab_image_async(Image, AcqHandle, -1)
  map_image(Image, Map, RectifiedImage)
endwhile

Beispiel (HDevelop)

*  perform camera calibration (with standard calibration plate)
camera_calibration(NX, NY, NZ, NRow, NCol, StartCamParam, NStartPose, \
                   'all', FinalCamParam, NFinalPose, Errors)
*  world coordinate system is defined by calibration plate in first image
FinalPose1 := NFinalPose[0:6]
*  compensate thickness of plate
set_origin_pose(FinalPose1, 0, 0, 0.000073, WorldPose)
*  goal: rectify images
*  first determine parameters such that the entire image content is visible
*  -> transform image boundary into world plane, determine smallest
*     rectangle around it
get_image_pointer1(Image, Pointer, Type, Width, Height)
gen_rectangle1 (ImageRect, 0, 0, Height-1, Width-1)
gen_contour_region_xld (ImageRect, ImageBorder, 'border')
contour_to_world_plane_xld(ImageBorder, ImageBorderWCS, FinalCamParam, \
                           WorldPose, 1)
smallest_rectangle1_xld (ImageBorderWCS, MinY, MinX, MaxY, MaxX)
*  -> move the pose to the upper left corner of the surrounding rectangle
set_origin_pose(WorldPose, MinX, MinY, 0, PoseForEntireImage)
*  -> determine the scaling factor such that the center pixel has the same
*     size in the original and in the rectified image
*     method: transform corner points of the pixel into the world
*             coordinate system, compute their distances, and use their
*             mean as the scaling factor
image_points_to_world_plane(FinalCamParam, PoseForEntireImage, \
                            [Height/2, Height/2, Height/2+1], \
                            [Width/2, Width/2+1, Width/2], \
                            1, WorldPixelX, WorldPixelY)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[1], WorldPixelX[1], \
            WorldLength1)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[2], WorldPixelX[2], \
            WorldLength2)
ScaleForSimilarPixelSize := (WorldLength1+WorldLength2)/2
*  -> determine output image size such that entire input image fits into it
ExtentX := MaxX-MinX
ExtentY := MaxY-MinY
WidthRectifiedImage := ExtentX/ScaleForSimilarPixelSize
HeightRectifiedImage := ExtentY/ScaleForSimilarPixelSize
*  create mapping with the determined parameters
gen_image_to_world_plane_map(Map, FinalCamParam, PoseForEntireImage, \
                             Width, Height, \
                             WidthRectifiedImage, HeightRectifiedImage, \
                             ScaleForSimilarPixelSize, 'bilinear')
*  transform grabbed images with the created map
while(1)
  grab_image_async(Image, AcqHandle, -1)
  map_image(Image, Map, RectifiedImage)
endwhile

Beispiel (C++ (HALCON 5.0-10.0))

HImage  Image, Map, RectifiedImage;
HFramegrabber  AcqHandle;
HTuple  NX, NY, NZ, NRow, NCol;
HTuple  StartCamParam, NStartPose, FinalCamParam, NFinalPose, Errors;
HTuple  FinalPose1, WorldPose, PoseForEntireImage;
HTuple  Width, Height, Type, MinX, MinY, MaxX, MaxY;
HTuple  UpperLeftX, UpperLeftY, UpperRightX, UpperRightY;
HTuple  LowerLeftX, LowerLeftY, WorldLength1, WorldLength2;
HTuple  ScaleForSimilarPixelSize, ExtentX, ExtentY;
HTuple  WidthRectifiedImage, HeightRectifiedImage;

// perform camera calibration (with standard calibration plate)
camera_calibration(NX, NY, NZ, NRow, NCol, StartCamParam, NStartPose, 'all',
                   &FinalCamParam, &NFinalPose, &Errors);
// world coordinate system is defined by calibration plate in first image
FinalPose1 = NFinalPose(0,6);
// compensate thickness of plate
set_origin_pose(FinalPose1, 0, 0, 0.000073, &WorldPose);
// goal: rectify image
// first determine parameters such that the entire image content is visible
//   and that objects have a similar size before and after the rectification
// -> transform image boundary into world plane, determine smallest
//    rectangle around it
Image.GetImagePointer1(&Type, &Width, &Height);
HRegion  ImageRect = HRegion::GenRectangle1(0, 0, Height-1, Width-1);
HXLDCont ImageBorder = ImageRect.GenContourRegionXld("border");
Hobject  ImageBorderWCSObj;
contour_to_world_plane_xld(ImageBorder.Id(), &ImageBorderWCSObj,
                           FinalCamParam, WorldPose, 1);
HXLDArray ImageBorderWCS(ImageBorderWCSObj);
MinY = ImageBorderWCS.SmallestRectangle1Xld(&MinX, &MaxY, &MaxX);
// -> move the pose to the upper left corner of the surrounding rectangle
set_origin_pose(WorldPose, MinX, MinY, 0, &PoseForEntireImage);
// -> determine the scaling factor such that the center pixel has the same
//    size in the original and in the rectified image
//    method: transform corner points of the pixel into the world
//            coordinate system, compute their distances, and use their
//            mean as the scaling factor
image_points_to_world_plane(FinalCamParam, PoseForEntireImage,
                            Height/2, Width/2, 1,
                            &UpperLeftX, &UpperLeftY);
image_points_to_world_plane(FinalCamParam, PoseForEntireImage,
                            Height/2, Width/2+1,
                            1, &UpperRightX, &UpperRightY);
image_points_to_world_plane(FinalCamParam, PoseForEntireImage,
                            Height/2+1, Width/2,
                            1, &LowerLeftX, &LowerLeftY);
distance_pp(UpperLeftY, UpperLeftX, UpperRightY, UpperRightX,
            &WorldLength1);
distance_pp(UpperLeftY, UpperLeftX, LowerLeftY, LowerLeftX,
            &WorldLength2);
ScaleForSimilarPixelSize = (WorldLength1+WorldLength2)/2;
// -> determine output image size such that entire input image fits into it
ExtentX = MaxX-MinX;
ExtentY = MaxY-MinY;
WidthRectifiedImage = ExtentX/ScaleForSimilarPixelSize;
HeightRectifiedImage = ExtentY/ScaleForSimilarPixelSize;
// create mapping with the determined parameters
Map =
  HImage::GenImageToWorldPlaneMap(FinalCamParam, PoseForEntireImage,
                                  Width, Height, WidthRectifiedImage,
                                  HeightRectifiedImage,
                                  ScaleForSimilarPixelSize, "bilinear");
// transform grabbed images with the created map
while(1)
{
  Image = AcqHandle.GrabImageAsync(-1);
  RectifiedImage = Image.MapImage(Map);
}

Beispiel (HDevelop)

*  perform camera calibration (with standard calibration plate)
camera_calibration(NX, NY, NZ, NRow, NCol, StartCamParam, NStartPose, \
                   'all', FinalCamParam, NFinalPose, Errors)
*  world coordinate system is defined by calibration plate in first image
FinalPose1 := NFinalPose[0:6]
*  compensate thickness of plate
set_origin_pose(FinalPose1, 0, 0, 0.000073, WorldPose)
*  goal: rectify images
*  first determine parameters such that the entire image content is visible
*  -> transform image boundary into world plane, determine smallest
*     rectangle around it
get_image_pointer1(Image, Pointer, Type, Width, Height)
gen_rectangle1 (ImageRect, 0, 0, Height-1, Width-1)
gen_contour_region_xld (ImageRect, ImageBorder, 'border')
contour_to_world_plane_xld(ImageBorder, ImageBorderWCS, FinalCamParam, \
                           WorldPose, 1)
smallest_rectangle1_xld (ImageBorderWCS, MinY, MinX, MaxY, MaxX)
*  -> move the pose to the upper left corner of the surrounding rectangle
set_origin_pose(WorldPose, MinX, MinY, 0, PoseForEntireImage)
*  -> determine the scaling factor such that the center pixel has the same
*     size in the original and in the rectified image
*     method: transform corner points of the pixel into the world
*             coordinate system, compute their distances, and use their
*             mean as the scaling factor
image_points_to_world_plane(FinalCamParam, PoseForEntireImage, \
                            [Height/2, Height/2, Height/2+1], \
                            [Width/2, Width/2+1, Width/2], \
                            1, WorldPixelX, WorldPixelY)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[1], WorldPixelX[1], \
            WorldLength1)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[2], WorldPixelX[2], \
            WorldLength2)
ScaleForSimilarPixelSize := (WorldLength1+WorldLength2)/2
*  -> determine output image size such that entire input image fits into it
ExtentX := MaxX-MinX
ExtentY := MaxY-MinY
WidthRectifiedImage := ExtentX/ScaleForSimilarPixelSize
HeightRectifiedImage := ExtentY/ScaleForSimilarPixelSize
*  create mapping with the determined parameters
gen_image_to_world_plane_map(Map, FinalCamParam, PoseForEntireImage, \
                             Width, Height, \
                             WidthRectifiedImage, HeightRectifiedImage, \
                             ScaleForSimilarPixelSize, 'bilinear')
*  transform grabbed images with the created map
while(1)
  grab_image_async(Image, AcqHandle, -1)
  map_image(Image, Map, RectifiedImage)
endwhile

Beispiel (HDevelop)

*  perform camera calibration (with standard calibration plate)
camera_calibration(NX, NY, NZ, NRow, NCol, StartCamParam, NStartPose, \
                   'all', FinalCamParam, NFinalPose, Errors)
*  world coordinate system is defined by calibration plate in first image
FinalPose1 := NFinalPose[0:6]
*  compensate thickness of plate
set_origin_pose(FinalPose1, 0, 0, 0.000073, WorldPose)
*  goal: rectify images
*  first determine parameters such that the entire image content is visible
*  -> transform image boundary into world plane, determine smallest
*     rectangle around it
get_image_pointer1(Image, Pointer, Type, Width, Height)
gen_rectangle1 (ImageRect, 0, 0, Height-1, Width-1)
gen_contour_region_xld (ImageRect, ImageBorder, 'border')
contour_to_world_plane_xld(ImageBorder, ImageBorderWCS, FinalCamParam, \
                           WorldPose, 1)
smallest_rectangle1_xld (ImageBorderWCS, MinY, MinX, MaxY, MaxX)
*  -> move the pose to the upper left corner of the surrounding rectangle
set_origin_pose(WorldPose, MinX, MinY, 0, PoseForEntireImage)
*  -> determine the scaling factor such that the center pixel has the same
*     size in the original and in the rectified image
*     method: transform corner points of the pixel into the world
*             coordinate system, compute their distances, and use their
*             mean as the scaling factor
image_points_to_world_plane(FinalCamParam, PoseForEntireImage, \
                            [Height/2, Height/2, Height/2+1], \
                            [Width/2, Width/2+1, Width/2], \
                            1, WorldPixelX, WorldPixelY)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[1], WorldPixelX[1], \
            WorldLength1)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[2], WorldPixelX[2], \
            WorldLength2)
ScaleForSimilarPixelSize := (WorldLength1+WorldLength2)/2
*  -> determine output image size such that entire input image fits into it
ExtentX := MaxX-MinX
ExtentY := MaxY-MinY
WidthRectifiedImage := ExtentX/ScaleForSimilarPixelSize
HeightRectifiedImage := ExtentY/ScaleForSimilarPixelSize
*  create mapping with the determined parameters
gen_image_to_world_plane_map(Map, FinalCamParam, PoseForEntireImage, \
                             Width, Height, \
                             WidthRectifiedImage, HeightRectifiedImage, \
                             ScaleForSimilarPixelSize, 'bilinear')
*  transform grabbed images with the created map
while(1)
  grab_image_async(Image, AcqHandle, -1)
  map_image(Image, Map, RectifiedImage)
endwhile

Ergebnis

Sind die Parameterwerte korrekt, dann liefert gen_image_to_world_plane_mapgen_image_to_world_plane_mapGenImageToWorldPlaneMapgen_image_to_world_plane_mapGenImageToWorldPlaneMapGenImageToWorldPlaneMap den Wert 2 (H_MSG_TRUE).

Vorgänger

create_posecreate_poseCreatePosecreate_poseCreatePoseCreatePose, hom_mat3d_to_posehom_mat3d_to_poseHomMat3dToPosehom_mat3d_to_poseHomMat3dToPoseHomMat3dToPose, camera_calibrationcamera_calibrationCameraCalibrationcamera_calibrationCameraCalibrationCameraCalibration, hand_eye_calibrationhand_eye_calibrationHandEyeCalibrationhand_eye_calibrationHandEyeCalibrationHandEyeCalibration, set_origin_poseset_origin_poseSetOriginPoseset_origin_poseSetOriginPoseSetOriginPose

Nachfolger

map_imagemap_imageMapImagemap_imageMapImageMapImage

Alternativen

image_to_world_planeimage_to_world_planeImageToWorldPlaneimage_to_world_planeImageToWorldPlaneImageToWorldPlane

Siehe auch

map_imagemap_imageMapImagemap_imageMapImageMapImage, contour_to_world_plane_xldcontour_to_world_plane_xldContourToWorldPlaneXldcontour_to_world_plane_xldContourToWorldPlaneXldContourToWorldPlaneXld, image_points_to_world_planeimage_points_to_world_planeImagePointsToWorldPlaneimage_points_to_world_planeImagePointsToWorldPlaneImagePointsToWorldPlane

Modul

Calibration


KlassenKlassenKlassenKlassen | | | | Operatoren