Image assertion method and apparatus, electronic device, and storage medium

By identifying and capturing images of changing regions during UI automation testing, and then using a template matching algorithm model for image assertion, the inefficiency problem in existing technologies is solved, achieving more efficient image assertion.

CN116524214BActive Publication Date: 2025-11-11CHONGQING CHANGAN TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310163740.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-24
Publication Date
2025-11-11
Estimated Expiration
2043-02-24

AI Technical Summary

Technical Problem

Existing UI automation testing is inefficient when performing image assertions, mainly because the current frame image contains many unchanged areas when compared with the preset feature image, resulting in low efficiency.

Method used

By acquiring the previous frame image and the current frame image, the changing region is determined and the region image is cropped. The template matching algorithm model is then used for image assertion, which improves efficiency.

Benefits of technology

Performing image assertions after identifying the change region improves the efficiency of image assertions, reduces the processing time for invalid contrast regions, and enhances testing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116524214B_ABST
    Figure CN116524214B_ABST
Patent Text Reader

Abstract

This application provides an image assertion method, apparatus, electronic device, and storage medium, relating to the field of software testing technology. The method involves acquiring a previous frame image, a current frame image, and at least one preset feature image corresponding to the previous frame image. Based on the previous and current frame images, a changing region is determined in the current frame image. Then, an image of the changing region is cropped to obtain a region image. Finally, image assertion is performed based on the region image, at least one preset feature image, and a template matching algorithm model. This can improve the efficiency of image assertion methods.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software testing technology, specifically to an image assertion method, apparatus, electronic device, and storage medium. Background Technology

[0002] User interface (UI) testing refers to testing whether the layout of each functional module in the user interface is reasonable, whether the overall style is consistent, and whether the placement of each control conforms to user habits. The goal is to ensure that the user interface provides users with the corresponding access and browsing functions through the tested object, and to ensure that the user interface conforms to company or industry standards. Therefore, UI testing is crucial for various human-computer interaction scenarios. Furthermore, because manual testing of user interfaces is costly and time-consuming, automated UI testing plays a vital role in user interface testing.

[0003] Current UI automation testing typically performs image assertions by directly comparing the current frame image (which shows changes compared to the previous frame) with a preset feature image to determine if the current frame image matches the preset feature image. However, since the current frame image may contain many unchanged areas, directly comparing the current frame image with the preset feature image is inefficient. Summary of the Invention

[0004] In view of the shortcomings of the prior art described above, this application provides an image assertion method, apparatus, electronic device, and storage medium to solve the above-mentioned technical problems.

[0005] This application provides an image assertion method, including:

[0006] Acquire the previous frame image, the current frame image, and at least one preset feature image corresponding to the previous frame image;

[0007] Based on the previous frame image and the current frame image, a changing region is determined in the current frame image, and an image of the changing region is cropped to obtain a region image;

[0008] Image assertion is performed based on the region image, at least one of the preset feature images, and the template matching algorithm model.

[0009] In one embodiment of the present invention, determining the changing region in the current frame image based on the previous frame image and the current frame image includes:

[0010] Determine the color value corresponding to each color channel of each pixel in the previous frame image and the current frame image;

[0011] Determine the color difference between the color values ​​of two corresponding pixels in the previous frame image and the current frame image;

[0012] The rate of change is determined based on the color difference and the preset color value;

[0013] The pixels in the current frame image whose rate of change is greater than a preset rate of change are identified as initial changed pixels.

[0014] When the rate of change of any pixel around the initial changed pixel is greater than a preset rate of change, the initial changed pixel is determined as the target pixel.

[0015] The changing region is determined based on multiple target pixels.

[0016] In one embodiment of the present invention, determining the changing region based on the plurality of target pixels includes:

[0017] Among the multiple target pixels, determine the first x-coordinate with the largest x-coordinate, the second x-coordinate with the smallest x-coordinate, the first y-coordinate with the largest y-coordinate, and the second y-coordinate with the smallest y-coordinate;

[0018] The first horizontal coordinate, the second horizontal coordinate, the first vertical coordinate, and the second vertical coordinate are combined to obtain four target coordinates;

[0019] The change region is determined based on the four target coordinates.

[0020] In one embodiment of the present invention, before determining the changing region in the current frame image based on the previous frame image and the current frame image, and extracting the image of the changing region to obtain a region image, the method further includes:

[0021] Based on the color values ​​of each pixel in the previous frame image and the current frame image, determine the number of different pixels in the current frame image. The different pixels are pixels in the current frame image that are in the same position as those in the previous frame image but have different color values.

[0022] When the number of differing pixels is greater than a preset number, it is determined that there is a changed region in the current frame image.

[0023] To achieve the above and other related objectives, this application provides an image assertion apparatus, comprising:

[0024] The data acquisition module is used to acquire the previous frame image, the current frame image, and at least one preset feature image corresponding to the previous frame image;

[0025] The change region determination module is used to determine the change region in the current frame image based on the previous frame image and the current frame image, and to extract the image of the change region to obtain a region image;

[0026] The image assertion module is used to perform image assertions based on the region image, at least one of the preset feature images, and the template matching algorithm model.

[0027] In one embodiment of the present invention, the change region determination module includes:

[0028] The first determining unit is used to determine the color value corresponding to each color channel of each pixel in the previous frame image and the current frame image.

[0029] The second determining unit is used to determine the color difference between the color values ​​of two corresponding pixels in the previous frame image and the current frame image.

[0030] The third determining unit is used to determine the rate of change based on the color difference and the preset color value;

[0031] The fourth determining unit is used to determine the pixels in the current frame image whose rate of change is greater than a preset rate of change as initial changed pixels;

[0032] The fifth determining unit is used to determine the initial changed pixel as the target pixel when the rate of change of any pixel around the initial changed pixel is greater than a preset rate of change.

[0033] The sixth determining unit is used to determine the changing region based on the multiple target pixels.

[0034] In one embodiment of the present invention, the sixth determining unit is further configured to:

[0035] Among the multiple target pixels, determine the first x-coordinate with the largest x-coordinate, the second x-coordinate with the smallest x-coordinate, the first y-coordinate with the largest y-coordinate, and the second y-coordinate with the smallest y-coordinate;

[0036] The first horizontal coordinate, the second horizontal coordinate, the first vertical coordinate, and the second vertical coordinate are combined to obtain four target coordinates;

[0037] The change region is determined based on the four target coordinates.

[0038] In one embodiment of the present invention, the image assertion device further includes:

[0039] The quantity determination module is used to determine the number of different pixels in the current frame image based on the color values ​​of each pixel in the previous frame image and the current frame image. The different pixels are pixels in the current frame image that are in the same position as those in the previous frame image but have different color values.

[0040] The judgment module is used to determine that there is a changed region in the current frame image when the number of the difference pixels is greater than a preset number.

[0041] To achieve the above and other related objectives, this application also provides an electronic device, the electronic device comprising:

[0042] One or more processors;

[0043] A storage device for storing one or more programs that, when executed by one or more processors, cause the electronic device to implement the image assertion method described in any of the foregoing embodiments.

[0044] To achieve the above and other related objectives, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a computer's processor, causes the computer to perform the image assertion method described in any of the foregoing embodiments.

[0045] As described above, the image assertion method, apparatus, electronic device, and storage medium provided in this application have the following beneficial effects:

[0046] This application discloses an image assertion method. The method acquires a previous frame image, a current frame image, and at least one preset feature image corresponding to the previous frame image. Based on the previous and current frame images, it determines a changing region in the current frame image, then extracts an image of the changing region to obtain a region image. Finally, it performs image assertion based on the region image, at least one preset feature image, and a template matching algorithm model. This method can determine the changing region in the current frame image and obtain the region image, and then perform image assertion based on the extracted region image. It can also perform image assertion within a relatively small region image, thus improving the efficiency of the image assertion method.

[0047] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0048] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort. In the drawings:

[0049] Figure 1 This is a flowchart illustrating an exemplary embodiment of the image assertion method of this application;

[0050] Figure 2 This is a block diagram illustrating an image assertion device according to an exemplary embodiment of this application;

[0051] Figure 3 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application is shown. Detailed Implementation

[0052] The embodiments of this application will be described below with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of this application from the content disclosed in this specification. This application can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this application. It should be understood that the preferred embodiments are only for illustrating this application and are not intended to limit the scope of protection of this application.

[0053] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of this application. Therefore, the drawings only show the components related to this application and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.

[0054] In the following description, numerous details are explored to provide a more thorough explanation of embodiments of the present application. However, it will be apparent to those skilled in the art that embodiments of the present application may be practiced without these specific details. In other embodiments, well-known structures and devices are shown in block diagram form rather than in detail to avoid obscuring embodiments of the present application.

[0055] Please see Figure 1 , Figure 1 This is a flowchart illustrating an exemplary embodiment of the image assertion method of this application. (Reference) Figure 1 As can be seen, this image assertion method can include:

[0056] Step S110: Obtain the previous frame image, the current frame image, and at least one preset feature image corresponding to the previous frame image.

[0057] In one embodiment of this application, a previous frame image, a current frame image, and at least one preset feature image corresponding to the previous frame image can be acquired. In UI automated testing, the execution of the automated test script can be monitored in real time. During monitoring, video of the UI automated test is acquired, and the previous frame image and the current frame image can be identified from the video. The at least one preset feature image corresponding to the previous frame image can be prepared by the operator before the UI automated test.

[0058] Step S120: Based on the previous frame image and the current frame image, determine the changing region in the current frame image, and extract the image of the changing region to obtain the region image.

[0059] In one embodiment of this application, a changing region can be extracted from the current frame image based on the previous frame image and the current frame image, and the extracted changing region can be defined as a region image. Extracting a region image from the current frame image and applying the region image to subsequent steps can improve the efficiency of image assertion.

[0060] In an exemplary embodiment, the process of determining the change region in the current frame image based on the previous frame image and the current frame image in step S120 may include steps S121 to S128.

[0061] Step S121: Determine the color values ​​corresponding to each color channel of each pixel in the previous frame image and the current frame image.

[0062] In one embodiment of this application, the color values ​​corresponding to each color channel of each pixel in the previous frame image and the current frame image can be determined. The color channels of a pixel can be three channels: R (Red), G (Green), and B (Blue). That is, any pixel has one color value corresponding to its R channel, one color value corresponding to its G channel, and one color value corresponding to its B channel.

[0063] For example, OpenCV (a cross-platform computer vision and machine learning software library) can be used to extract the color values ​​corresponding to the RGB three channels of the previous frame image and the current frame image.

[0064] Step S122: Determine the color difference between the color values ​​of each color channel of the corresponding pixel points in the previous frame image and the current frame image.

[0065] In one embodiment of this application, the color difference values ​​of each color channel corresponding to a pixel in the previous frame image and the current frame image can be determined. The previous frame image and the current frame image have the same pixels, therefore there is a one-to-one correspondence between the pixels in the previous frame image and the pixels in the current frame image. That is, for any pixel in both the previous and current frame images, three color differences can be obtained, corresponding to the R channel, G channel, and B channel, respectively.

[0066] Step S123: Determine the rate of change based on the color difference and the preset color value.

[0067] In one embodiment of this application, the rate of change can be determined based on the color difference and a preset color value. That is, each pixel in the current frame image can be determined with three rates of change.

[0068] For example, the preset color value can be 255, and the quotient of the color value and 255 can be used as the rate of change.

[0069] Step S124: Pixels in the current frame image with a change rate greater than a preset change rate are determined as initial changed pixels.

[0070] In one embodiment of this application, any pixel in the current frame image whose rate of change is greater than a preset rate of change can be determined as an initial changed pixel. Since any pixel in the current frame image corresponds to three rates of change, if any rate of change is greater than the preset rate of change, that pixel can be determined as the initial changed pixel. If any rate of change of a pixel in the current frame image is less than or equal to the preset rate of change, then that pixel has not changed or has changed only slightly compared to the corresponding pixel in the previous frame image.

[0071] For example, the preset rate of change can be 10%.

[0072] Step S125: When the rate of change of any pixel around the initial changed pixel is greater than the preset rate of change, the initial changed pixel is determined as the target pixel.

[0073] In one embodiment of this application, when the rate of change of any one of the eight pixels surrounding the initial changed pixel is greater than a preset rate of change, the initial changed pixel can be determined as a target pixel. Each pixel in the current frame image can be judged to determine whether each pixel is a target pixel. The number of pixels surrounding the initial changed pixel located at the four corners of the current frame image is 3, and the number of pixels surrounding the initial changed pixel located on the four sides of the current frame image (excluding the four corners) is 5.

[0074] Step S126: Determine the first x-coordinate with the largest x-coordinate, the second x-coordinate with the smallest x-coordinate, the first y-coordinate with the largest y-coordinate, and the second y-coordinate with the smallest y-coordinate among multiple target pixels.

[0075] In one embodiment of this application, a first x-coordinate with the largest x-coordinate, a second x-coordinate with the smallest x-coordinate, a first y-coordinate with the largest y-coordinate, and a second y-coordinate with the smallest y-coordinate can be determined among multiple target pixels. The first x-coordinate, the second x-coordinate, the first y-coordinate, and the second y-coordinate are all numerical values.

[0076] For example, a Cartesian coordinate system can be established with the lower left corner of the current frame image as the origin and the extension directions on both sides of the current frame image passing through the origin as the coordinate axes. Then, the first x-coordinate with the largest x-coordinate, the second x-coordinate with the smallest x-coordinate, the first y-coordinate with the largest y-coordinate, and the second y-coordinate with the smallest y-coordinate can be determined.

[0077] Step S127: Combine the first horizontal coordinate, the second horizontal coordinate, the first vertical coordinate, and the second vertical coordinate to obtain four target coordinates.

[0078] In one embodiment of this application, the first horizontal coordinate, the second horizontal coordinate, the first vertical coordinate, and the second vertical coordinate can be combined to obtain four target coordinates. That is, four target coordinates can be determined: (first horizontal coordinate, first vertical coordinate), (first horizontal coordinate, second vertical coordinate), (second horizontal coordinate, first vertical coordinate), and (second horizontal coordinate, second vertical coordinate).

[0079] Step S128: Determine the change area based on the four target coordinates.

[0080] In one embodiment of this application, the change region can be determined based on four target coordinates. Determining the change region based on four target coordinates can maximize the inclusion of the calculated initial change pixels in the change region, thereby improving the accuracy and efficiency of image assertion.

[0081] Step S130: Perform image assertion based on the region image, at least one preset feature image, and template matching algorithm model.

[0082] In one embodiment of this application, image assertion can be performed based on a region image, at least one preset feature image, and a template matching algorithm model. Template matching is a representative method in image recognition. It extracts several feature vectors from the region image (the image to be recognized) and compares them with the corresponding feature vectors of the preset feature image (template), calculates the distance between the feature vectors of the region image and the preset feature image, and uses the minimum distance method to determine whether the region image includes the resulting features from the preset feature image.

[0083] In one embodiment of this application, when the number of preset feature images is one and the feature result in the preset feature image is one, the template matching algorithm model can be used to determine whether the region image includes the result feature in the preset feature image. When the region image includes the result feature in the preset feature image, it can be determined that the UI automated test case was executed successfully.

[0084] In one embodiment of this application, when there is one preset feature image and multiple feature results in the preset feature image, the template matching algorithm model can be used to determine whether the region image includes multiple result features in the preset feature image. When the region image includes multiple result features in the preset feature image, it can be determined that the UI automated test case was executed successfully.

[0085] In one embodiment of this application, when there are multiple preset feature images that appear sequentially, multiple images can be captured during UI automated testing. When the result features in the preset feature images are found in the region image of each image, and the order of appearance of the result features in the region image is consistent with the order of the preset feature images, it can be determined that the UI automated test case was executed successfully.

[0086] In one embodiment of this application, if a 404 error, a 503 error, or a 502 error occurs during the execution of a UI automated test case, a preset feature image can be a feature image of the relevant error. Then, the current frame image of the UI automated test case is read in real time to see if an image related to the saved error feature image appears. If it is found, it can be determined that the UI automated test case has failed to execute.

[0087] In an exemplary embodiment, the image assertion method may further include steps S210 and S220.

[0088] Step S210: Determine the number of different pixels in the current frame image based on the color values ​​of each pixel in the previous frame image and the current frame image.

[0089] Among them, the difference pixels are pixels in the current frame that are in the same position as those in the previous frame but have different color values.

[0090] In one embodiment of this application, the number of differing pixels in the current frame image can be determined based on the color values ​​of each pixel in the previous frame image and the current frame image. The proportion of differing pixels in the current frame image relative to all pixels in the current frame image can also be determined.

[0091] Step S220: When the number of different pixels is greater than a preset number, it is determined that there is a changed area in the current frame image.

[0092] In one embodiment of this application, when the number of differing pixels exceeds a preset number, it can be determined that a changed region exists in the current frame image. The preset number can be set by the operator based on the actual processing situation and the number of pixels in the current frame image.

[0093] For example, when determining the proportion of the difference pixels in the current frame image out of all pixels in the current frame image, if the proportion of the difference pixels in the current frame image out of all pixels in the current frame image is greater than 0.5%, it can be determined that there is a change area in the current frame image.

[0094] In summary, the method of this application embodiment acquires a previous frame image, a current frame image, and at least one preset feature image corresponding to the previous frame image. Based on the previous and current frame images, it determines the changing region in the current frame image, then extracts the image of the changing region to obtain a region image. Finally, it performs image assertion based on the region image, at least one preset feature image, and a template matching algorithm model. This method can determine the changing region in the current frame image and obtain the region image, and then perform image assertion based on the extracted region image. It can also perform image assertion within a relatively small region image, thus improving the efficiency of the image assertion method.

[0095] Figure 2 This is a block diagram illustrating an image assertion device according to an exemplary embodiment of this application. Figure 2 As shown, the exemplary image assertion device 200 includes:

[0096] The data acquisition module 210 is used to acquire the previous frame image, the current frame image, and at least one preset feature image corresponding to the previous frame image.

[0097] The variable region determination module 220 is used to determine the variable region in the current frame image based on the previous frame image and the current frame image, and to extract the image of the variable region to obtain the region image.

[0098] The image assertion module 230 is used to perform image assertions based on the region image, at least one preset feature image, and a template matching algorithm model.

[0099] In another exemplary embodiment, the change region determination module may include:

[0100] The first determining unit is used to determine the color value corresponding to each color channel of each pixel in the previous frame image and the current frame image.

[0101] The second determining unit is used to determine the color difference between the color values ​​of two corresponding pixels in the previous frame image and the current frame image.

[0102] The third determining unit is used to determine the rate of change based on the color difference and the preset color value.

[0103] The fourth determining unit is used to determine the pixels in the current frame image whose rate of change is greater than a preset rate of change as the initial changed pixels.

[0104] The fifth determining unit is used to determine the initial changed pixel as the target pixel when the rate of change of any pixel around the initial changed pixel is greater than a preset rate of change.

[0105] The sixth determining unit is used to determine the changing region based on multiple target pixels.

[0106] In another exemplary embodiment, the sixth determining unit may also be used to:

[0107] Among multiple target pixels, determine the first x-coordinate with the largest x-coordinate, the second x-coordinate with the smallest x-coordinate, the first y-coordinate with the largest y-coordinate, and the second y-coordinate with the smallest y-coordinate.

[0108] The first horizontal coordinate, the second horizontal coordinate, the first vertical coordinate, and the second vertical coordinate are combined to obtain four target coordinates.

[0109] The area of ​​change is determined based on the coordinates of the four targets.

[0110] In another exemplary embodiment, the image assertion device further includes:

[0111] The quantity determination module is used to determine the number of different pixels in the current frame image based on the color values ​​of each pixel in the previous frame image and the current frame image. Different pixels are pixels in the current frame image that are in the same position as those in the previous frame image but have different color values.

[0112] The judgment module is used to determine that there is a changed area in the current frame image when the number of different pixels is greater than a preset number.

[0113] It should be noted that the image assertion device and the image assertion method provided in the above embodiments belong to the same concept. The specific ways in which each module and unit performs operations have been described in detail in the method embodiments, and will not be repeated here. In practical applications, the image assertion device provided in the above embodiments can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above, and this is not a limitation here.

[0114] Embodiments of this application also provide an electronic device, including: one or more processors; and a storage device for storing one or more programs, which, when executed by one or more processors, cause the electronic device to implement the image assertion methods provided in the above embodiments.

[0115] Figure 3 A schematic diagram of a computer system suitable for implementing the embodiments of this application is shown. It should be noted that... Figure 3 The computer system 300 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0116] like Figure 3 As shown, the computer system 300 includes a Central Processing Unit (CPU) 301, which can perform various appropriate actions and processes, such as executing the methods described in the above embodiments, based on programs stored in Read-Only Memory (ROM) 302 or programs loaded from storage portion 308 into Random Access Memory (RAM) 303. The RAM 303 also stores various programs and data required for system operation. The CPU 301, ROM 302, and RAM 303 are interconnected via a bus 304. An Input / Output (I / O) interface 305 is also connected to the bus 304.

[0117] The following components are connected to I / O interface 305: an input section 306 including a keyboard, mouse, etc.; an output section 307 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 308 including a hard disk, etc.; and a communication section 309 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 309 performs communication processing via a network such as the Internet. A drive 310 is also connected to I / O interface 305 as needed. Removable media 311, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 310 as needed so that computer programs read from them can be installed into storage section 308 as needed.

[0118] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program including a computer program for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 309, and / or installed from removable medium 311. When the computer program is executed by central processing unit (CPU) 301, it performs various functions defined in the system of this application.

[0119] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a computer-readable computer program. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.

[0120] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. Each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0121] The units described in the embodiments of this application can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the specific unit itself.

[0122] Another aspect of this application provides a computer-readable storage medium storing a computer program thereon, which, when executed by a computer's processor, causes the computer to perform the image assertion methods provided in the various embodiments described above. This computer-readable storage medium may be included in the electronic device described in the above embodiments, or it may exist independently and not assembled into the electronic device.

[0123] Another aspect of this application provides a computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the image assertion methods provided in the various embodiments described above.

[0124] The above embodiments are merely illustrative of the principles and effects of this application and are not intended to limit this application. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in this application should still be covered by the claims of this application.

Claims

1. An image assertion method, characterized in that, The image assertion method includes: Acquire the previous frame image, the current frame image, and at least one preset feature image corresponding to the previous frame image; Based on the previous frame image and the current frame image, a changing region is determined in the current frame image, and an image of the changing region is cropped to obtain a region image; Image assertion is performed based on the region image, at least one of the preset feature images, and the template matching algorithm model; The step of determining the changed region in the current frame image based on the previous frame image and the current frame image includes: Determine the color value corresponding to each color channel of each pixel in the previous frame image and the current frame image; Determine the color difference between the color values ​​of two corresponding pixels in the previous frame image and the current frame image; The rate of change is determined based on the color difference and the preset color value; The pixels in the current frame image whose rate of change is greater than a preset rate of change are identified as initial changed pixels. When the rate of change of any pixel around the initial changed pixel is greater than a preset rate of change, the initial changed pixel is determined as the target pixel. The changing region is determined based on multiple target pixels.

2. The image assertion method according to claim 1, characterized in that, The step of determining the changing region based on multiple target pixels includes: Among the multiple target pixels, determine the first x-coordinate with the largest x-coordinate, the second x-coordinate with the smallest x-coordinate, the first y-coordinate with the largest y-coordinate, and the second y-coordinate with the smallest y-coordinate; The first horizontal coordinate, the second horizontal coordinate, the first vertical coordinate, and the second vertical coordinate are combined to obtain four target coordinates; The change region is determined based on the four target coordinates.

3. The image assertion method according to claim 1 or 2, characterized in that, Before determining the changed region in the current frame image based on the previous frame image and the current frame image, and extracting the image of the changed region to obtain a region image, the method further includes: Based on the color values ​​of each pixel in the previous frame image and the current frame image, determine the number of different pixels in the current frame image. The different pixels are pixels in the current frame image that are in the same position as those in the previous frame image but have different color values. When the number of differing pixels is greater than a preset number, it is determined that there is a changed region in the current frame image.

4. An image assertion device, characterized in that, The image assertion device includes: The data acquisition module is used to acquire the previous frame image, the current frame image, and at least one preset feature image corresponding to the previous frame image; The change region determination module is used to determine the change region in the current frame image based on the previous frame image and the current frame image, and to extract the image of the change region to obtain a region image; The image assertion module is used to perform image assertions based on the region image, at least one of the preset feature images, and the template matching algorithm model. The change region determination module includes: The first determining unit is used to determine the color value corresponding to each color channel of each pixel in the previous frame image and the current frame image. The second determining unit is used to determine the color difference between the color values ​​of two corresponding pixels in the previous frame image and the current frame image. The third determining unit is used to determine the rate of change based on the color difference and the preset color value; The fourth determining unit is used to determine the pixels in the current frame image whose rate of change is greater than a preset rate of change as initial changed pixels; The fifth determining unit is used to determine the initial changed pixel as the target pixel when the rate of change of any pixel around the initial changed pixel is greater than a preset rate of change. The sixth determining unit is used to determine the changing region based on the multiple target pixels.

5. The image assertion apparatus according to claim 4, characterized in that, The sixth determining unit is also used for: Among the multiple target pixels, determine the first x-coordinate with the largest x-coordinate, the second x-coordinate with the smallest x-coordinate, the first y-coordinate with the largest y-coordinate, and the second y-coordinate with the smallest y-coordinate; The first horizontal coordinate, the second horizontal coordinate, the first vertical coordinate, and the second vertical coordinate are combined to obtain four target coordinates; The change region is determined based on the four target coordinates.

6. The image assertion apparatus according to claim 4 or 5, characterized in that, The image assertion device further includes: The quantity determination module is used to determine the number of different pixels in the current frame image based on the color values ​​of each pixel in the previous frame image and the current frame image. The different pixels are pixels in the current frame image that are in the same position as those in the previous frame image but have different color values. The judgment module is used to determine that there is a changed region in the current frame image when the number of the difference pixels is greater than a preset number.

7. An electronic device, characterized in that, The electronic device includes: One or more processors; A storage device for storing one or more programs that, when executed by one or more processors, cause the electronic device to implement the image assertion method as described in any one of claims 1 to 3.

8. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by the computer's processor, causes the computer to perform the image assertion method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • UI test method, apparatus and device, and storage medium

    CN112711526A