This application is based upon and claims priority to Chinese Patent Application No. 201810265497.8, filed on Mar. 28, 2018, the entire contents thereof are incorporated herein by reference.
The present disclosure relates to display control technologies, and in particular, to an image rectification method and device, and a display device.
At present, display interfaces of many display device screens are rectangular, and images obtained by cameras are all rectangular images as shown in
The present disclosure provides an image rectification method and device and a non-transitory computer-readable storage medium.
According to a first aspect of the arrangements of the present disclosure, there is provided an image rectification method. The method includes obtaining an image to be displayed and a display region of a display screen. The method includes determining a to-be-rectified region of the image to be displayed according to the image to be displayed and the display region. The method includes rectifying the to-be-rectified region of the image to be displayed to make the rectified image to be displayed match the display region.
According to an exemplary arrangement, determining the to-be-rectified region of the image to be displayed according to the image to be displayed and the display region includes: obtaining a shape parameter of the display region and a shape parameter of the image to be displayed; and obtaining the to-be-rectified region by using an image rectification algorithm based on the shape parameter of the display region and the shape parameter of the image to be displayed.
According to an exemplary arrangement, determining the to-be-rectified region of the image to be displayed according to the image to be displayed and the display region includes obtaining a shape parameter of the display region and a shape parameter of the image to be displayed. Further, such a block includes determining an overlap region of the display region and the image to be displayed according to the shape parameters, and determining the to-be-rectified region of the image to be displayed according to a positional relationship of the overlap region, the image to be displayed, and the display region.
According to an exemplary arrangement, determining the to-be-rectified region of the image to be displayed according to a positional relationship of the overlap region, the image to be displayed, and the display region includes if the overlap region overlaps the image to be displayed, determining that a region corresponding to the image to be displayed is the to-be-rectified region. If the overlap region overlaps the display region, such a block include determining a region of the image to be displayed that is outside the overlap region as the to-be-rectified region. If the overlap region is a part of both the display region and the image to be displayed, the block includes determining that a region corresponding to the image to be displayed is the to-be-rectified region.
According to an exemplary arrangement, rectifying the to-be-rectified region of the image to be displayed to make the rectified image to be displayed match the display region includes determining an image rectification algorithm according to the display region. Such a block includes obtaining a source shape parameter and a target shape parameter of the to-be-rectified region. The block includes based on the source shape parameter and the target shape parameter, rectifying the to-be-rectified region by using the image rectification algorithm to make the rectified image to be displayed match the display region.
According to an exemplary arrangement, determining the to-be-rectified region of the image to be displayed includes obtaining a trigger operation of a user, and determining the to-be-rectified region according to the trigger operation.
According to a second aspect of arrangements of the present disclosure, there is provided an image rectification device. The image rectification device includes a display region obtaining module configured to obtain an image to be displayed and a display region of a display screen. The image rectification device includes a to-be-rectified region determining module configured to determine a to-be-rectified region of the image to be displayed according to the image to be displayed and the display region. The image rectification device includes a to-be-rectified region rectifying module configured to rectify the to-be-rectified region of the image to be displayed to make the rectified image to be displayed match the display region.
According to an exemplary arrangement, the to-be-rectified region determining module further includes a first shape parameter obtaining unit configured to obtain a shape parameter of the display region and a shape parameter of the image to be displayed. The to-be-rectified region determining module further includes a to-be-rectified region obtaining unit configured to obtain the to-be-rectified region by using an image rectification algorithm based on the shape parameter of the display region and the shape parameter of the image to be displayed.
According to an exemplary arrangement, the to-be-rectified region determining module further includes a second shape parameter obtaining unit configured to obtain a shape parameter of the display region and a shape parameter of the image to be displayed. The to-be-rectified region determining module further includes an overlap region determining unit configured to determine an overlap region of the display region and the image to be displayed according to the shape parameters. The to-be-rectified region determining module further includes a second to-be-rectified region obtaining unit configured to determine the to-be-rectified region of the image to be displayed according to a positional relationship of the overlap region, the image to be displayed, and the display region.
According to an exemplary arrangement, the second to-be-rectified region obtaining unit further includes a first determining unit configured to, if the overlap region overlaps the image to be displayed, determine that a region corresponding to the image to be displayed is the to-be-rectified region. The second to-be-rectified region obtaining unit further includes a second determining unit configured to, if the overlap region overlaps the display region, determine a region of the image to be displayed that is outside the overlap region as the to-be-rectified region. The second to-be-rectified region obtaining unit further includes a third determining unit configured to, if the overlap region is a part of both the display region and the image to be displayed, determine that a region corresponding to the image to be displayed is the to-be-rectified region.
According to an exemplary arrangement, the to-be-rectified region rectifying module further includes a rectification algorithm determining unit configured to determine an image rectification algorithm according to the display region. The to-be-rectified region rectifying module further includes a third shape parameter obtaining unit configured to obtain a source shape parameter and a target shape parameter of the to-be-rectified region. The to-be-rectified region rectifying module further includes a to-be-rectified region rectifying unit configured to, based on the source shape parameter and the target shape parameter, rectify the to-be-rectified region by using the image rectification algorithm to make the rectified image to be displayed match the display region.
According to an exemplary arrangement, the display region obtaining module further includes a trigger operation obtaining unit configured to obtain a trigger operation of a user. The display region obtaining module further includes a to-be-rectified region determining unit configured to determine the to-be-rectified region according to the trigger operation.
According to a third aspect of arrangements of the present disclosure, there is provided an image rectification device. The image rectification device includes a processor, and a memory configured to store instructions and files which are executable by the processor. The processor is configured to execute executable instructions in the memory to implement the operations of the method according to the first aspect.
According to another aspect of arrangements of the present disclosure, there is provided a non-transitory computer-readable storage medium having stored therein instructions that, when executed by a processor of a display device, causes the display device to perform the above image rectification method.
According to the above arrangements, in the present disclosure, by adjusting or rectifying the image to be displayed to make the rectified image meet the requirements of the display region in the display screen, the present disclosure can avoid the situation in related arts that the display screen only displays a part of the image content to be displayed, and thus the viewing experience of users can be improved by completely displaying images.
It should be understood that the above general description and the following detailed description are merely exemplary and explanatory and are not limiting of the present disclosure.
The drawings herein are incorporated into the description and form a part of the specification, showing the arrangements of the present disclosure and explaining the principle together with the description.
Exemplary arrangements will be described in detail herein, examples of which are illustrated in the drawings. When the following description refers to the drawings, the same numbers in different drawings indicate the same or similar elements, unless otherwise indicated. The arrangements described in the following exemplary arrangements do not represent all arrangements consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with aspects of the present disclosure as detailed in the appended claims.
At present, display interfaces of many display device screens are rectangular, and images obtained by cameras are all rectangular images as shown in
In 201, an image to be displayed and a display region of a display screen are obtained.
In an arrangement, the image to be displayed may be obtained from an image capture device, such as a camera or a webcam, and the camera may send the image to be displayed directly to the processor. In another arrangement, the image to be displayed may also be read from a storage device. For example, a camera collects images (which may be video frames) and the collected images are stored in the storage device. The processor reads the image(s) from the storage device as the image(s) to be displayed. In still another arrangement, the image to be displayed may be input by a user.
In an arrangement, the processor and a display screen are connected through a communication interface, and the processor can request a display region of the display screen through the communication interface of the display screen, for example, a width and a height of the display region, a parameter of a irregularly shaped region. The whole or a part of the display region displays images. In another arrangement, the display region data of the display screen can be saved in the storage device in advance, and this can reduce the number of the communications between the processor and other external devices and increase the process speed.
It can be understood that the order of obtaining the image to be displayed and obtaining the display region of the display screen is not limited, and those skilled in this art can set the order according to actual application scenarios.
In 202, a to-be-rectified region of the image to be displayed is determined according to the image to be displayed and the display region.
In the present arrangement, the determining of the to-be-rectified region according to the image to be displayed and the display region may include the following scheme:
In a first scheme, the to-be-rectified region is determined by using the big data method. First, a large number of display region samples of the display screens (the number can be set according to actual scenarios) are obtained, a large number of samples of the image to be displayed are obtained, and then a rectification region model is trained by using the sample data to train to obtain the trained rectification region model. After obtaining the image to be displayed and the display region, the image to be displayed and the display region are input to the trained rectification region model so as to obtain the to-be-rectified region. The rectification model may be a circular region, an elliptical region, or a polygonal region. For example, the polygonal region may be a trapezoidal region or an inverted trapezoidal region, a diamond shaped region, or the like.
In a second scheme, the image to be displayed and the display region are compared to determine the to-be-rectified region. In the same coordinate system, the image to be displayed and the display region are compared, and then the to-be-rectified region is determined according to the relationship between the positions or areas of the image to be displayed and the display region, which will be described in detail in subsequent arrangements.
In a third scheme, a user may select the to-be-rectified region. In the present arrangement, the processor obtains a trigger operation of the user, and then the to-be-rectified region is determined according to the position coordinates corresponding to the trigger operation. For example, in an edit mode, the user selects a plurality of positions from the image to be displayed, and the region surrounded by the plurality of positions forms the to-be-rectified region. As another example, in the edit mode, the user selects at least one diagonal line of the to-be-rectified region by using a gesture, and the to-be-rectified region is determined according to at least one diagonal line.
In the present arrangement, several ways of determining the to-be-rectified region are introduced. Those skilled in this art can select a proper way to determine the to-be-rectified region, depending on actual application scenarios. Corresponding solutions also fall within the protection scope of the present disclosure.
In 203, the to-be-rectified region of the image to be displayed is rectified to make the rectified image to be displayed match the display region.
In the present arrangement, after obtaining the to-be-rectified region, the processor determines an image rectification algorithm according to the display region, and then obtains a source shape parameter and a target shape parameter of the to-be-rectified region. By inputting the source shape parameter and the target shape parameter into the image rectification algorithm, the rectified image to be displayed can be obtained. In this way, the image to be displayed matches the display region of the display.
It can be understood that the image rectification algorithm may be implemented by an image rectification algorithm in related arts, such as a contour-based image rectification algorithm, an image geometric distortion rectification algorithm, an image segmentation transformation rectification algorithm, or an artificial neural network image recognition rectification algorithm or the like. Taking the contour-based image rectification algorithm as an example, a processor performs graying and threshold-binarization on the image to be rectified, and then detects the contour of the image. Next, the processor searches the enclosing matrix and the angle of the contour, and performs rotation rectification according to the angle. Finally, the processor extracts the contour and cuts out an image from the image to be rectified after the rotation, and then rectifies the image. The skilled person can select an appropriate image rectification algorithm according to a specific scenario, and all such selection of image rectification algorithm also falls within the protection scope of the present disclosure.
In an arrangement, the pixels of the image to be displayed are stretched and shifted according to a setting rule, so that all the pixels of the image to be displayed are located within the overlap region, so that the display region completely displays all the pixels, that is, completely displays the image to be displayed.
In another arrangement, the image to be displayed includes a plurality of application APPs, at least one APP is located outside the overlap region, and the processor may adjust the position coordinates of the at least one APP to a range corresponding to the overlap regions, thus the display region completely displays the APP.
In still another arrangement, a processor may further divide the image to be displayed into a plurality of parts, and then adjust each part according to an adjustment manner of the APP or the pixel point, so that the display screen can display a part of the image to be displayed one time. When a user triggers the display, such as sliding upward, sliding downward, pulling left or pulling right, the processor adjusts the next part of the image to be displayed. Or, the processor processes all parts of the image to be displayed, and then the display screen displays individual parts in turn.
It can be seen that, in the present arrangement, the image to be displayed is rectified based on the display region of the display screen to make the rectified image meet the requirement of the display region. The arrangement can avoid the situation in related arts that the display screen only displays a part of the image to be displayed. In the present arrangement, the display screen can completely display the image to be displayed, which can improve the viewing experience of users.
An arrangement of the present disclosure further provides an image rectification method, and
In 301, an image to be displayed and a display region of a display screen are obtained.
The specific implementations and principles of blocks 301 and 201 are the same. Details regarding block 301 can be found in the above descriptions regarding block 201, and repeated descriptions are omitted here.
In 302, a shape parameter of the display region and a shape parameter of the image to be displayed are obtained.
In the present arrangement, the processor selects the shape parameters from the image to be displayed. The shape parameters may include height, width, resolution of the image to be displayed and coordinate data of each pixel. Of course, coordinate data of each pixel may also be obtained, and then the height and width of the image to be displayed are calculated. Those skilled in this art can select the shape parameters of the image to be displayed according to actual application scenarios.
In the present arrangement, the processor selects the shape parameters from the display region data of the display screen. The shape parameters may include the height, width, and resolution of the display region and coordinate data of each pixel. Of course, the coordinate data of each pixel may also be obtained, and then the height and width of the display region are calculated.
In 303, an overlap region of the display region and the image to be displayed is determined according to the shape parameters.
In the present arrangement, the processor places the shape parameter of the display region and the shape parameter of the image to be displayed in the same coordinate system, and then compares the image to be displayed with the display region to obtain an overlap region of the image to be displayed and the display region. Exemplary operations are described as follows:
In Scene 1, referring to
In Scene 2, referring to
In Scene 3, referring to
In 304, the to-be-rectified region of the image to be displayed is determined according to a positional relationship of the overlap region, the image to be displayed, and the display region.
In the present arrangement, the processor determines the to-be-rectified region of the image to be displayed according to the positional relationship among the overlap region, the image to be displayed, and the display region.
In an arrangement, if the overlap region overlaps the image to be displayed, it is indicated that the area of the image to be displayed is smaller than or equal to the area of the display region, and the entire image to be displayed may be taken as the to-be-rectified region. Since the area of the image to be displayed is smaller than or equal to the area of the display region, the display region can completely display the entire image to be displayed, and the processor may not process the image to be displayed, that is, there is no to-be-rectified region in the scene.
In another arrangement, if the overlap region overlaps the display region, a region outside the overlap region in the image to be displayed is determined as the to-be-rectified region.
In still another arrangement, if the overlap region is a part of both the display region and the image to be displayed, it is determined that the region of the image to be displayed outside the overlap region is the to-be-rectified region. In this scenario, the processor appropriately adjusts the image to be displayed, so that the region outside the overlap region is integrated into the overlap region, and the display region completely displays the entire image to be displayed.
In 305, the to-be-rectified region of the image to be displayed is rectified to make the rectified image match the display region.
The specific implementations and principles of blocks 305 and 203 are the same. Details of block 305 can be found in the above descriptions regarding block 203, and repeated descriptions are omitted here.
It can be seen that, in the arrangement, the display region and the image to be displayed are compared, the to-be-rectified region of the image to be displayed is determined according to the overlap image, and the to-be-rectified region is rectified. In this way, the image to be displayed matches the display region. Thus, the present disclosure can avoid the situation in related arts that the display screen only displays a part of the image to be displayed. In the present arrangement, the display screen can completely display the image to be displayed, which can improve the viewing experience of users.
Referring to
Referring still to
In the present arrangement, a multi-buffer mechanism is used to buffer the image to be displayed and the application interface region of the shaped screen (512), referring to the buffer result shown in
For example, if the to-be-rectified region includes a to-be-rectified unit 0 and a to-be-rectified unit 1, the extraction manner may include the following operations.
The to-be-rectified unit 0 can be obtained by:
For(i=0;i<h;i++)
For(j=0;j<w;j++){
Char*GetRchar=Framebuffer->base+(800*(y+i)+x+j)*4;
Char*GetGchar=Framebuffer->base+(800*(y+i)+x+j)*4+1;
Char*GetBchar=Framebuffer->base+(800*(y+i)+x+j)*4+2;
Char*GetAchar=Framebuffer->base+(800*(y+i)+x+j)*4+3; }
The to-be-rectified unit 1 can be obtained by:
For(i=0;i<h;i++)
For(j=0;j<w;j++){
Char*GetRchar=Framebuffer->base+offset1+(800*(y+i)+x+j)*4;
Char*GetGchar=Framebuffer->base+offset1+(800*(y+i)+x+j)*4+1;
Char*GetBchar=Framebuffer->base+offset1+(800*(y+i)+x+j)*4+2;
Char*GetAchar=Framebuffer->base+offset1+(800*(y+i)+x+j)*4+3; }.
It should be noted that, in the present arrangement, the shape parameters (that is, source shape parameters) of the to-be-rectified region may include an abscissa x, an ordinate y, a width w, and a height h, where 0=<x<=800, 0=<y<=480, 0<w<800, and 0<h<480.
Thereafter, whether or not the image rectification algorithm can be determined is judged based on the to-be-rectified region. In the present arrangement, an image rectification algorithm is provided in the form of a C/C++ library. The C/C++ library may include a plurality of image rectification function implementations required for the to-be-rectified region. In an arrangement, the delay of each image rectification algorithm needs to be less than 10 ms to ensure that the display system does not run very slowly or becomes choppy. It can be understood that the image rectification algorithm in the present arrangement is closely related to the display region of the irregularly shaped screen, that is, the shape parameters of the display region (the target shape parameters of the to-be-rectified region) can be obtained after the image rectification algorithm is determined.
Referring again to
In order to facilitate the transplantation of the image rectification method provided by the present disclosure, in an arrangement, the program corresponding to the image rectification method is packaged to form image rectification algorithm libraries and rectification modules in the Android system.
The display region obtaining module 901 is configured to obtain an image to be displayed and a display region of a display screen.
The to-be-rectified region determining module 902 is configured to determine a to-be-rectified region of the image to be displayed according to the image to be displayed and the display region.
The to-be-rectified region rectifying module 903 is configured to rectify the to-be-rectified region of the image to be displayed to make the rectified image to be displayed match the display region.
In an arrangement of the present disclosure, referring to
The first shape parameter obtaining unit 1001 is configured to obtain a shape parameter of the display region and a shape parameter of the image to be displayed.
The to-be-rectified region obtaining unit 1002 is configured to obtain the to-be-rectified region by using an image rectification algorithm based on the shape parameter of the display region and the shape parameter of the image to be displayed.
In an arrangement of the present disclosure, referring to
The second shape parameter obtaining unit 1101 is configured to obtain a shape parameter of the display region and a shape parameter of the image to be displayed.
The overlap region determining unit 1102 is configured to determine an overlap region of the display region and the image to be displayed according to the shape parameters.
The second to-be-rectified region obtaining unit 1103 is configured to determine the to-be-rectified region of the image to be displayed according to a positional relationship of the overlap region, the image to be displayed, and the display region.
In an arrangement of the present disclosure, the second to-be-rectified region obtaining unit 1103 includes a first determining unit, a second determining unit or a third determining unit.
The first determining unit is configured to, if the overlap region overlaps the image to be displayed, determine that a region corresponding to the image to be displayed is the to-be-rectified region.
The second determining unit is configured to, if the overlap region overlaps the display region, determine a region of the image to be displayed that is outside the overlap region as the to-be-rectified region.
The third determining unit is configured to, if the overlap region is a part of both the display region and the image to be displayed, determine that a region corresponding to the image to be displayed is the to-be-rectified region.
In an arrangement of the present disclosure, referring to
The rectification algorithm determining unit 1201 is configured to determine an image rectification algorithm according to the display region.
The third shape parameter obtaining unit 1202 is configured to obtain a source shape parameter and a target shape parameter of the to-be-rectified region.
The to-be-rectified region rectifying unit 1203 is configured to, based on the source shape parameter and the target shape parameter, rectify the to-be-rectified region by using the image rectification algorithm to make the rectified image to be displayed match the display region.
In an arrangement of the present disclosure, referring to
The trigger operation obtaining unit 1301 is configured to obtain a trigger operation of a user.
The to-be-rectified region determining unit 1302 is configured to determine the to-be-rectified region according to the trigger operation.
It is to be understood that the image rectification device provided by the arrangement of the present disclosure corresponds to the image rectification method, and details regarding the device can be found in the description regarding the method arrangements and repeated descriptions are omitted here.
The memory 1402 is configured to store instructions and files which are executable by the processor 1401.
The processor 1401 is configured to execute executable instructions in the memory 1402 to implement the blocks of the image rectification method shown in
In an exemplary arrangement, there is also provided a display device which includes the image rectification device as described.
In exemplary arrangements, there is also provided a non-transitory computer-readable storage medium including instructions, such as included in the memory 1402, executable by the processor 1401 in the device 1400, for performing the above-described methods. For example, the non-transitory computer-readable storage medium may be a ROM, a RAM, a CD-ROM, a magnetic tape, a floppy disc, an optical data storage device, and the like.
In the present disclosure, the terms “first” and “second” are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. The term “plurality” refers to two or more, unless specifically defined otherwise.
Other arrangements of the present disclosure will be readily apparent to those skilled in the art upon consideration of the specification and practice of the disclosure herein. The present application is intended to cover any variations, uses, or adaptations of the present disclosure, which are in accordance with the general principles of the present disclosure and include common general knowledge or conventional technical means in the art that are not disclosed in the present disclosure. The specification and arrangements are to be only considered as illustrative, the truth scope and spirit of the present disclosure are defined by appended claims.
It is to be understood that the present disclosure is not limited to the precise structures shown and described in the drawings, and various modifications and changes can be made without departing from the scope of the present disclosure. The scope of the present disclosure is limited only by the appended claims.
Number | Date | Country | Kind |
---|---|---|---|
201810265497.8 | Mar 2018 | CN | national |