PICTools Programmer's Reference
OP_PERSADJUST

OP_PERSADJUST: Perspective adjustment of an object in an image.

See the PERSADJUST:OP_PERSADJUST section for additional information. 

The OP_PERSADJUST opcode is used for perspective adjustment of an object in an image. The actual object is rectangular, but may appear non-rectangular in the image because of the perspective distortion due to capturing the image at an angle. In fully automatic mode, OP_PERSADJUST finds in the image a single convex quadrilateral (the object), computes and applies a perspective transformation to convert that quadrilateral into a rectangle, and then returns just that rectangle as the output image of suitable dimensions. If less than fully automatic operation is desired or needed, the app can itself set the corners of the object and/or the dimensions of the output image to be used by OP_PERSADJUST. It is also possible for the app to override the corners found by OP_PERSADJUST and/or the determined output image dimensions just prior to transformation of the object.

Input to OP_PERSADJUST is a DIB, either 8-bit gray or 24-bit RGB. Output is a DIB of the same type as the input, but may have different dimensions. The app sets fields describing the input DIB in PicParm.Head prior to REQ_INIT. The app can supply an appropriate value for InStride or it can let the opcode compute and return it. The Get and Put queues are not used during the REQ_INIT request. The Get queue must be configured before the REQ_EXEC request. The Put queue can be configured before the REQ_EXEC request or can be delayed until the first RES_PUT_NEED_SPACE request.

Prior to REQ_EXEC, the app sets values for the coordinates of the object corners (specified clockwise in ULCornerX, ULCornerY, URCornerX, URCornerY, LRCornerX, LRCornerY, LLCornerX, LLCornerY) and values for OutWidth, OutHeight, and OutStride for the output image. To enable automatic object detection by OP_PERSADJUST, set the values of all four corner coordinates to 0. The four corners found by OP_PERSADJUST will be available to the opcode at the first RES_PUT_NEED_SPACE request, if needed, and when REQ_EXEC returns. In some cases, the four corners returned will be the same as the four corners of the full input image because nothing better could be found. If the app wishes to control the locations of the corners, it can set or change them prior to REQ_EXEC or when returning from the first RES_PUT_NEED_SPACE request. It is okay for any of the four corners to lie outside the input image boundaries.

To enable automatic determination of output image dimensions by OP_PERSADJUST, set the values of OutWidth, OutHeight, and OutStride to 0 and don’t configure the Put queue. The dimensions determined by OP_PERSADJUST will be available to the opcode at the first RES_PUT_NEED_SPACE request made by REQ_EXEC, and the Put queue must be configured at that time. If the app wishes to control the output image size, it can set or change these values prior to REQ_EXEC or when returning from the first RES_PUT_NEED_SPACE request.

 

 


©2022. Accusoft Corporation. All Rights Reserved.

Send Feedback