Image generation method and device

By automatically determining and placing object line resources in computer images, the problem of manual placement of models in the prior art is solved, which consumes a lot of manpower and time, improves image generation efficiency and reduces costs.

CN114299134BActive Publication Date: 2025-04-15ZHUHAI KINGSOFT ONLINE GAME TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111643954.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-29
Publication Date
2025-04-15
Estimated Expiration
2041-12-29

AI Technical Summary

Technical Problem

In the prior art, the creation of objects required to increase the details of computer scenes, especially line-type objects, such as cliff walls, lake shorelines, coastlines, etc., requires manual placement of models, resulting in huge workloads and a lot of labor and time costs.

Method used

By obtaining the object lines in the initial image, determining the line type and line component style, automatically determining the object resources and calculating their position information based on this information, and then updating the initial image to generate the target image.

Benefits of technology

The automatic placement of object resources corresponding to object lines is realized, the efficiency of target images is improved, and labor and time costs are reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114299134B_ABST
    Figure CN114299134B_ABST
Patent Text Reader

Abstract

The present application provides an image generation method and device, wherein the image generation method comprises: obtaining object lines in an initial image; determining line types and line component styles based on the object lines; determining object resources corresponding to the object lines according to the line component styles, and determining location information of the object resources according to the object lines and the line types; updating the initial image based on the object resources and the location information to obtain a target image containing a target object corresponding to the object lines.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an image generation method and apparatus, a computing device, and a computer-readable storage medium. Background Art

[0002] With the development of computer technology, people have an increasing demand for the vividness and richness of scenes displayed in computers. In practical applications, in order to increase some scene details, it may be necessary to add some line-type objects such as cliffs, lakeshores, coastlines, cliffs, and viaducts to the scene. The creation of these objects can be summarized as placing models on a broken line. At present, it is usually necessary to manually place a circle of models on the edge of the object. The workload of placing this type of model is huge, and it requires a lot of manpower and time costs. Therefore, it is urgent to provide a solution to the above problems. Summary of the invention

[0003] In view of this, the embodiments of the present application provide an image generation method and apparatus, a computing device, and a computer-readable storage medium to solve the technical defects existing in the prior art.

[0004] According to a first aspect of an embodiment of the present application, there is provided an image generating method, comprising:

[0005] Get the object lines in the initial image;

[0006] Determine a line type and a line component style based on the object line;

[0007] Determine the object resource corresponding to the object line according to the line component style, and determine the location information of the object resource according to the object line and the line type;

[0008] The initial image is updated based on the object resource and the position information to obtain a target image including the target object corresponding to the object line.

[0009] Optionally, the line type is determined in the following manner:

[0010] Determine whether there is a target line point without adjacent points on both sides among the line points of the object line;

[0011] If not, determining that the line type is a closed line type;

[0012] If so, determine that the line type is a non-closed line type.

[0013] Optionally, the line component style is determined in the following manner:

[0014] Segment the object line according to a preset segmentation rule to obtain at least one line segment; match the line segment with a preset line component style to determine the line component style corresponding to the object line; or

[0015] Calculate preset line points of the object line to determine the type of target line points contained in the object line; and determine a line component style based on the type and the object line.

[0016] Optionally, determining the object resource corresponding to the object line according to the line component style includes:

[0017] Determine a resource library corresponding to the object line;

[0018] An object resource matching the line component style is determined in the resource library according to the attribute information of the line component style.

[0019] Optionally, when the line type is a non-closed line type, determining the location information of the object resource according to the object line and the line type includes:

[0020] Determine a placement reference point of the object resource in a line segment corresponding to the object line according to a preset reference point rule;

[0021] Determining a reference baseline of the object resource on the line segment according to a preset baseline of the object resource;

[0022] Calculating the offset information between the object resource and the line segment based on the placement reference point, the preset reference line and the reference reference line;

[0023] The placement reference point and the offset information are used as the position information of the object resource.

[0024] Optionally, the calculating the offset information between the object resource and the line segment based on the placement reference point and the line segment corresponding to the object resource in the object line includes:

[0025] Determining a reference baseline of the object resource on the line segment according to a preset baseline of the object resource;

[0026] Based on the placement reference point, the preset reference line and the reference reference line, the offset information between the object resource and the line segment is calculated.

[0027] Optionally, when the line type is a closed line type, determining the location information of the object resource according to the object line and the line type includes:

[0028] Determine a placement reference point of the object resource in a line segment corresponding to the object line according to a preset reference point rule;

[0029] Calculating the center point of the object line;

[0030] Determine rotation information of the object resource according to the center point and a line segment corresponding to the object resource in the object line;

[0031] The rotation information and the placement reference point are used as the position information.

[0032] Optionally, before determining the line type and the line component style based on the object line, the method further includes:

[0033] In the case where there is a curve in the object line, converting the curve into a polyline according to a preset conversion rule;

[0034] In the case where there is an angle in the object line, the angle of the angle is adjusted to a preset angle.

[0035] Optionally, the initial image is created in the following manner:

[0036] Receive creation instructions submitted based on the configuration list;

[0037] An initial image is created according to the region information and object marking information corresponding to the creation instruction.

[0038] According to a second aspect of an embodiment of the present application, there is provided an image generating device, including:

[0039] An acquisition module, configured to acquire object lines in an initial image;

[0040] A determination module, configured to determine a line type and a line component style based on the object line;

[0041] a resource determination module, configured to determine the object resource corresponding to the object line according to the line component style, and determine the location information of the object resource according to the object line and the line type;

[0042] The updating module is configured to update the initial image based on the object resource and the position information to obtain a target image containing the target object corresponding to the object line.

[0043] According to a third aspect of an embodiment of the present application, a computing device is provided, comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor implements the steps of the image generation method when executing the computer instructions.

[0044] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores computer instructions, and when the computer instructions are executed by a processor, the steps of the image generating method are implemented.

[0045] The image generation method provided by the embodiment of the present application obtains object lines in an initial image; determines line types and line component styles based on the object lines; determines object resources corresponding to the object lines according to the line component styles, and determines location information of the object resources according to the object lines and the line types; updates the initial image based on the object resources and the location information to obtain a target image containing a target object corresponding to the object lines, thereby realizing automatic placement of object resources corresponding to the object lines, improving target image generation efficiency, and reducing labor costs and time costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 is a structural block diagram of a computing device provided by an embodiment of the present application;

[0047] Figure 2 is a flow chart of an image generation method provided by an embodiment of the present application;

[0048] Figure 3 is a schematic diagram of line processing in an image generation method provided in an embodiment of the present application;

[0049] Figure 4 This is a processing flow chart of an image generation method for a lake shoreline object provided in an embodiment of the present application.

[0050] Figure 5 It is a structural schematic diagram of an image generating device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0051] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.

[0052] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.

[0053] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0054] In the present application, an image generation method and apparatus, a computing device, and a computer-readable storage medium are provided, which are described in detail one by one in the following embodiments.

[0055] Figure 1 The structure block diagram of a computing device 100 according to an embodiment of the present application is shown. The components of the computing device 100 include but are not limited to a memory 110 and a processor 120. The processor 120 is connected to the memory 110 via a bus 130, and the database 150 is used to store data.

[0056] The computing device 100 also includes an access device 140 that enables the computing device 100 to communicate via one or more networks 160. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 140 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.

[0057] In one embodiment of the present application, the above components of the computing device 100 and Figure 1 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 1The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of the present application. Those skilled in the art may add or replace other components as needed.

[0058] The computing device 100 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 100 may also be a mobile or stationary server.

[0059] The processor 120 may execute Figure 2 The steps in the image generation method shown. Figure 2 A flowchart of an image generation method provided according to an embodiment of the present application is shown, which specifically includes the following steps:

[0060] Step 202: Obtain object lines in the initial image.

[0061] The initial image refers to an image containing object information. In practical applications, the initial image can be understood as a planning image of a scene. The initial image is used as a basic image to automatically generate a target image containing an object based on the marking information (planning information) therein. Correspondingly, the object line refers to a line used to mark the object.

[0062] In practical applications, in order to increase some image details, it may be necessary to add some line-type objects such as railings, cliffs, lakeshores, coastlines, cliffs and viaducts to the image. The creation of these objects can be summarized as placing resources on a broken line. Therefore, in order to improve the generation efficiency of such objects, the present application provides an image generation method that can automatically place line-type resources.

[0063] Considering that the initial image, as a basic image, may need to be modified from time to time, in order to improve the modification efficiency and creation efficiency of the initial image, the initial image can be created by visual configuration. In the embodiment of the present application, the initial image is created in the following manner:

[0064] Receive creation instructions submitted based on the configuration list;

[0065] An initial image is created according to the region information and object marking information corresponding to the creation instruction.

[0066] The configuration list refers to a list for configuring information related to regions and objects in the initial image. Correspondingly, the creation instruction refers to an instruction for creating the initial image.

[0067] Specifically, the configuration list may include multiple configurable items, among which the configuration items of the area information may be configured such as the size information such as the image length and width, the cell information (the number of cells, the number of cell rows, the number of cell columns, the size information of the cell), etc. The configuration items of the object marking information may be configured such as: grid merging information, object location information, object function information, object identification information, object style information, object style information, object material information, object priority information, etc., without limitation here.

[0068] In practical applications, the region information is usually used to create the image size and cells in the initial image. The object marking information is used to mark the object to be created in the initial image. Specifically, the marking process can be marked in the image by text, color, wireframe, line, surface, etc., which are not limited here.

[0069] In addition, in order to further improve the configurability of the initial image and the convenience of subsequently generating the target object, the initial image can also be an image containing a grid (i.e., a cell). Such an image containing a grid can also be called an object grid image.

[0070] In summary, by creating the initial image according to the region information and object marking information corresponding to the creation instruction, the initial image is created in a visual configuration manner, thereby improving the efficiency of creating the initial image.

[0071] Step 204: Determine the line type and line component style based on the object line.

[0072] Specifically, based on the object lines in the initial image, considering that different types of lines require different object resources, and these object resources may be placed in different ways, it is necessary to first determine the line type and line component style based on the object lines.

[0073] Among them, the line type can be divided into a closed line type and an open line type according to whether the object line is closed. The line component style refers to the component style matching various line segments in the object line.

[0074] In practical applications, if the object line is a curve or an angle, it is difficult to pre-prepare all possible matching object resources for such object lines. Therefore, in order to simplify the creation of line type objects, the obtained object lines can be pre-processed. In the embodiment of the present application, it is specifically determined in the following manner:

[0075] In the case where there is a curve in the object line, converting the curve into a polyline according to a preset conversion rule;

[0076] In the case where there is an angle in the object line, the angle of the angle is adjusted to a preset angle.

[0077] The preset conversion rule may be to draw a tangent to the curved part of the object line and convert the curved part into a polyline. In addition, the preset conversion rule may be to straighten the curve in the object line and convert the object line into a polyline. When straightening, the straightening may be performed according to a preset reference line, such as according to the grid edge line in the initial image, or according to the center line of the grid in the initial image, etc., without limitation.

[0078] In practical applications, after the object lines are converted from curves to polylines, there are usually angles between the polyline lines. Specifically, the angle may be 24 degrees, 156 degrees, etc. Due to the uncertainty of the angle in the object lines, it is difficult to pre-produce object resources containing all angles. Therefore, the angle can be adjusted to a pre-set angle (i.e., a preset angle) such as 90 degrees or 60 degrees. In specific implementation, the angle can be adjusted to the preset angle by enlarging or reducing the angle.

[0079] For example, the lake shore lines in the initial image are as follows Figure 3 As shown in (a), the lakeshore line is straightened according to the center line of the cell within the cell range to which it belongs in the initial image, so that a convex-shaped broken-line lakeshore line can be obtained. Figure 3 (b) as shown.

[0080] In summary, by converting the curves in the object lines into straight lines and converting the angles in the object lines into preset angles, the standardization of the object lines is ensured and the efficiency of object creation is further improved.

[0081] In specific implementation, the line type is determined in the following manner:

[0082] Determine whether there is a target line point without adjacent points on both sides among the line points of the object line;

[0083] If not, it indicates that the object line does not have an endpoint, and the line type is determined to be a closed line type;

[0084] If so, it indicates that the object line has endpoints, and the line type is determined to be a non-closed line type.

[0085] Among them, the line point refers to the point in the object line. Correspondingly, the adjacent points on both sides refer to the adjacent points arranged before and after the line point in the object line. Among them, the adjacent points refer to the points adjacent to the line point in the line object. In practical applications, if any line point has only one adjacent point on one side, then the line point is the target line point, which also indicates that the line point is the endpoint of the object line. If the object line has an endpoint, it can be determined that the line type of the object line is a non-closed line type.

[0086] If all line points in the object line have adjacent points on both sides, that is, the line points of the object line do not have the target line point, it means that the object line does not have an endpoint. If the object line does not have an endpoint, it can be determined that the line type of the object line is a closed line type.

[0087] Using the above example, Figure 3 The line points in the broken-line lakeshore line in (b) are detected one by one to determine that each line point has adjacent points on both sides. There is no target line point in the line points of the lakeshore line, which also indicates that the lakeshore line has no endpoints. Therefore, it can also be determined that the line type of the lakeshore line is a closed line type.

[0088] In summary, by determining whether there is a target line point without adjacent points on both sides among the line points of the object line, the line type of the object line is determined, thereby ensuring the accuracy of determining the line type.

[0089] Furthermore, the line component style is determined in the following two ways:

[0090] Method 1: segmenting the object line according to a preset segmentation rule to obtain at least one line segment;

[0091] The line segment is matched with a preset line component style to determine the line component style corresponding to the object line.

[0092] The preset segmentation rule may be to segment the object line into sub-segments according to the cells in the initial image, that is, to segment the object line that belongs to one or more cells as line segments. In addition, the object line may be segmented into line segments according to preset line segment lengths (such as 5 meters, 1 meter, etc.), which is not limited here.

[0093] The preset line component style refers to a component style pre-set for the object line. In specific implementation, the line segment is matched with the preset line component style, which can be matched by calculating the similarity between the two using a pre-trained similarity model. In the case of multiple line segments, each line segment is matched with the preset line component style in turn. Furthermore, the preset line components with the same or similar matching results are determined as the line component style corresponding to the line segment. And the line component styles corresponding to all line segments in the object line are used as the line component style corresponding to the object line.

[0094] Using the above example, Figure 3 The lakeshore lines in (b) are segmented according to the cells in the initial image to obtain 10 line segments. Each line segment is matched with a preset line component style to obtain the preset line component style corresponding to each line segment, i.e., the line component style.

[0095] Method 2: Calculate preset line points on the object line to determine the type of target line points included in the object line;

[0096] A line component style is determined based on the type and the object line.

[0097] Specifically, the calculation of preset line points (such as intersections, corner points, and endpoints) of the object line can be understood as calculating the line points of intersections, corner points, and endpoints formed in the object line, and taking the preset line points in the object line as target line points. Then, according to the type of the target line point, the special positions in the object line (such as cross intersections, T-intersections, corners, and ends) are determined, and the styles formed by these special positions are used as line component styles. In addition, the straight line positions in the object line other than these special positions can correspond to the straight line component style, and the straight line component style is also used as the line component style.

[0098] In specific implementation, the object line can be divided into at least one straight line segment, and then calculate whether the endpoints of these straight line segments overlap; if the endpoints of four straight line segments overlap, the overlapped endpoints are determined to be cross intersections; if the endpoints of three straight line segments overlap, the overlapped endpoints are determined to be T-intersections; if the endpoints of two straight line segments overlap, the overlapped endpoints are determined to be corner points; if a straight line segment has endpoints that do not overlap, the endpoint is determined to be the endpoint of the object line. Then, according to the types (such as cross intersections, T-intersections, corner points, endpoints, etc.) of these target line points (such as cross intersections, T-intersections, corner points, endpoints, etc.), the corresponding line style components (such as cross intersection component style, T-intersection component style, corner component style, endpoint component style, etc.) are determined.

[0099] In addition, for the non-endpoint part of the object line, the corresponding line style component is determined to be a straight line component style. The endpoint part can be understood as a line segment including the endpoint, and the length of the line segment can be determined according to the preset component size (for example, the endpoint is a cross type, and the preset length corresponding to the cross type is 5 meters. The endpoint is used as the center point, and the four line segments belonging to the center point are cut by 5 meters respectively as the endpoint part). In addition, it is also determined according to the size of the cell in the initial image (for example, the endpoint and line segment belonging to the same cell are regarded as the endpoint part), which is not limited here.

[0100] Using the above example, Figure 3 The lakeshore line in (b) is divided into 8 straight line segments, and it is determined that the endpoints of the 8 straight line segments overlap, and the number of overlaps of the overlapped endpoints is 2. According to the number of overlaps 2, it can be determined that the type of the target line point is a corner type. According to the corner type, it can be determined that the line component style corresponding to the corner type is a corner component style. Then, according to the cell to which the target line point belongs in the initial image, the line segment part (i.e., the endpoint part) corresponding to the corner component style is separated from the object line. The line component style corresponding to the straight line part of the object line except the endpoint part is determined as the straight line component style.

[0101] In summary, by determining the line component style corresponding to the object line in the above two ways, the diversity and flexibility of determining the line component style are increased.

[0102] Step 206: Determine the object resource corresponding to the object line according to the line component style, and determine the location information of the object resource according to the object line and the line type.

[0103] Specifically, based on the above determination of the object type and line component style of the object line, it is necessary to determine the object resource and position information corresponding to the object line based on this information, so as to place the object resource according to the position information.

[0104] Among them, object resources refer to resources such as models, prefabricated parts, and maps corresponding to object lines. The object resources can be two-dimensional or three-dimensional, without limitation. Correspondingly, position information refers to information about the location where the object resource is placed in the initial image. Specifically, the position information can be coordinate information, position reference (such as cell) information, direction information, etc., without limitation.

[0105] In a specific implementation, the determining of the object resource corresponding to the object line according to the line component style is specifically implemented in the following manner:

[0106] Determine a resource library corresponding to the object line;

[0107] An object resource matching the line component style is determined in the resource library according to the attribute information of the line component style.

[0108] A resource library refers to a storage space for storing resources corresponding to object lines. The resource library can be a database, a storage server, or a specific disk, folder, etc., which is not limited here. In practical applications, there are various ways to determine the resource library corresponding to an object line. Specifically, object lines of different object types usually correspond to different resource libraries. For example, lakeshore lines correspond to lakeshore resource libraries, viaduct lines correspond to viaduct resource libraries, and river lines correspond to river resource libraries. During specific implementation, the correspondence between object type and resource library information (such as resource library path, resource library identification, etc.) can be pre-set, and the corresponding resource library can be determined based on the object line. In addition, the object type of the object line can also be used as part of the identification information of the line component style. In this case, the resource library matching the object type information can also be determined based on the object type information in the identification information of the line component style.

[0109] Furthermore, based on the attribute information of the line component style (such as style information, name information, inner and outer angle information and / or size information), etc., a resource search is performed in the resource library to determine the object resource matching the line component style.

[0110] In specific implementation, the attribute information of the line component style can be compared with the attribute information of the resources in the resource library, so as to select the object resources with matching attribute information in the resource library as the object resources matching the line component style. In addition, the resources in the resource library can be named according to the resource attributes using a unified naming rule, such as the naming rule: type_style_size. Then, the object type, style, size and other information of the line component style are compared one by one with the resource attributes in the resource naming, filtered layer by layer, and finally the resources that meet the requirements are selected as the object resources matching the line component style.

[0111] It should be noted that for closed object lines, the corresponding angles of the line component style in the object line may be divided into inner angles and outer angles. Among them, the outer angle refers to the angle whose angle facing the center point of the object line is greater than 180 degrees; the inner angle refers to the angle whose angle facing the center point of the object line is less than 180 degrees. Since the appearance of the inner and outer sides of object resources such as lakeshores and coastlines may be different (for example, seaweed and other decorations may be added to the inside of the resource when making object resources). Therefore, when describing object resources, it is usually necessary to make different object resources according to the difference between inner angles and outer angles. And add marks for inner and outer angles to distinguish them.

[0112] Therefore, when the line type of the object line is a closed line type, it is necessary to determine the object resource of the inner angle or outer angle that matches the line component style according to the label of the inner angle or outer angle of the line component style. In specific implementation, an inscribed circle and an circumscribed circle can be drawn for the object line. If the angle corresponding to the line component style in the object line is an angle toward the circumscribed circle, then the angle is an outer angle. Figure 3 The two angles shown in (c) are both external angles; if the corresponding angle of the line component style in the object line is an angle toward the inscribed circle, then the angle is an internal angle. Figure 3 The six angles shown in (c) are all inner angles. After distinguishing the inner and outer angles, add an inner angle or outer angle label to the line component style. The label information is also used as the attribute information of the line component style. Based on the attribute information, the object resource of the corresponding inner angle or outer angle is matched.

[0113] For example, on the basis of determining that the line component style corresponding to the lakeshore line is the corner component style and the straight line component style, according to the mapping relationship between the pre-set line type and the resource library path, it can be known that the line type of the lakeshore line: the resource library path corresponding to the lakeshore type is P1. The storage space pointed to by the resource library path P1 is determined as the lakeshore resource library corresponding to the lakeshore line. And according to the style name of the corner component style corresponding to the lakeshore line: corner, and the inner and outer angle labels: inner angle, the lakeshore corner model with the inner angle label is screened out from the lakeshore resource library as the lakeshore model corresponding to the corner component style. In addition, according to the style name of the straight line component style corresponding to the lakeshore line: straight line, the lakeshore straight line model is screened out from the lakeshore resource library as the lakeshore model corresponding to the straight line component style.

[0114] In the specific implementation, since the object resource needs to be placed in the correct position on the basis of determining the object resource, the target object can be finally generated. Different types of object lines may have different placement methods. In order to further improve the accuracy and efficiency of resource placement, different placement methods can be adopted for object lines of different line types. Therefore, in the embodiment of the present application, when the line type is a non-closed line type, the position information of the object resource is determined according to the object line and the line type, which is specifically implemented in the following manner:

[0115] Determine a placement reference point of the object resource in a line segment corresponding to the object line according to a preset reference point rule;

[0116] Calculate the offset information between the object resource and the line segment based on the placement reference point and the line segment corresponding to the object resource in the object line;

[0117] The placement reference point and the offset information are used as the position information of the object resource.

[0118] The preset reference point rule refers to a preset rule for selecting a placement reference point. Specifically, the preset reference point rule may be to select the center point of the line segment corresponding to the object resource in the object line as the object reference point. In addition, the preset reference point rule may also be to select the endpoint of the line segment as the placement reference point, etc., which is not limited here.

[0119] It should be noted that there may be multiple line segments in an object line that correspond to the same line component style, so these line segments also correspond to the same object resource. In this case, the placement reference point of the object resource in each line segment corresponding to the object line needs to be determined, so that the object resource can be placed multiple times in the object line based on the placement reference point.

[0120] On the basis of determining the placement reference point, since the placement position of a two-dimensional or three-dimensional object resource in the initial image cannot be determined by placing the reference point, it is also necessary to determine the placement angle of the object resource in order to accurately place the object resource. In specific implementation, based on the placement reference point and the line segment corresponding to the object resource in the object line, the offset information between the object resource and the line segment is calculated, which can be achieved in the following way:

[0121] Determining a reference baseline of the object resource on the line segment according to a preset baseline of the object resource;

[0122] Based on the placement reference point, the preset reference line and the reference reference line, the offset information between the object resource and the line segment is calculated.

[0123] The preset baseline refers to a baseline pre-set for an object resource (i.e., a preset baseline). Specifically, the preset baseline can be the positive axis of the object resource (for example, if the front of the pre-made object resource is vertically downward, the vertically downward coordinate axis can be used as the positive axis of the object resource), the center line of the object resource, the left sideline, or the right sideline; in addition, the preset baseline can also be a line segment between the center point of the object resource and the placement reference point, etc., which is not limited here. Correspondingly, the reference baseline can be understood as the baseline of the object area formed by the line segment corresponding to the object resource. In specific implementation, if the preset baseline is the positive axis of the object resource, the reference baseline is also the positive axis of the object area formed by the line segment; if the preset baseline is the center line of the object resource, the reference baseline is also the center line of the object area formed by the line segment. In short, when the object resource and the object area formed by its corresponding line segment are aligned, the preset reference line should also be completely aligned with the reference baseline.

[0124] Furthermore, after determining the reference baseline of the line segment corresponding to the object resource in the object line, the offset information between the reference baseline and the preset baseline can be determined. In specific implementation, the offset information can be determined by calculating based on the position information of the preset baseline (the position information can be understood as the position information corresponding to the preset baseline in the initial image when the object resource is placed at the placement reference point, that is, when the resource point corresponding to the placement reference point in the object resource is aligned with the placement reference point) and the position information of the reference baseline.

[0125] Specifically, the offset information includes the offset angle between the preset baseline and the reference baseline (such as 90 degrees, 180 degrees, etc.) and the offset direction corresponding to the offset angle (such as left, right, etc.). In actual applications, the pre-created object resources are usually placed in a unified direction. For example, the positive axes of these object resources are placed perpendicular to the screen. This direction may have an offset angle with its actual placement direction. Therefore, it is necessary to determine the offset angle and offset direction of the object resource (such as 180 degrees to the left, or 90 degrees to the right, etc.). So that on the basis of the placement reference point, the placement position of the object resource can be adjusted according to the offset information so that the placement position of the object resource coincides with the actual object position.

[0126] In summary, on the basis of determining the placement reference point and the offset information, the placement reference point and the offset information are used as the position information of the object resource, thereby ensuring the correctness of the placement of the object resource.

[0127] In the case where the line type is a closed line type, determining the location information of the object resource according to the object line and the line type is specifically implemented in the following manner:

[0128] Determine a placement reference point of the object resource in a line segment corresponding to the object line according to a preset reference point rule;

[0129] Calculating the center point of the object line;

[0130] Determine rotation information of the object resource according to the center point and a line segment corresponding to the object resource in the object line;

[0131] The rotation information and the placement reference point are used as the position information.

[0132] Specifically, the method of determining the placement reference point of the object resource in the line segment corresponding to the object line according to the preset reference point rule is similar to the implementation method of determining the placement reference point in the above method embodiment, which is not repeated here.

[0133] Furthermore, since the object line is a closed line type, the center point of the object line can be understood as the center point of the closed area formed by the object line. In specific implementation, the center point of the object line can be calculated by calculating the circumscribed circle corresponding to the object line, and the center point of the circumscribed circle is used as the center point of the object line. In addition, the inscribed circle corresponding to the object line can also be calculated, and the center point of the inscribed circle is used as the center point of the object line, etc., which is not limited here.

[0134] Furthermore, the rotation information of the object resource is determined according to the center point and the line segment corresponding to the object resource in the object line. In specific implementation, the center point of the line segment corresponding to the object resource in the object line can be determined first. And the line segment vector between the center point of the line segment and the center point of the object line is calculated. Then the resource vector between the center point of the object resource and the center point of the object line is calculated. Finally, the rotation direction and rotation angle between the resource vector and the line segment vector are calculated, and the rotation direction and rotation angle are used as the rotation information of the object resource.

[0135] In addition, if the direction of the connection line of the object resource is not fixed, the connection between the object resources may be discontinuous or impossible to connect. For example, object resource 1 and object resource 2 are adjacent, and the direction of the connection line of object resource 1 relative to object resource 2 is 45 degrees upward, while the direction of the connection line of object resource 2 relative to object resource 1 is 0 degrees, then the connection lines of the two cannot overlap. Therefore, in order to simplify the connection between object resources, the rotation angle determined above can also be corrected. Correct the rotation angle to a rotation angle of straight up, straight down, straight left or straight right. Figure 3 As shown in (d), the rotation angle is corrected to a straight-up rotation angle. In this case, the connecting lines between the object resources can also be reduced to two directions: parallel or vertical. The corrected rotation angle and rotation direction are then used as the rotation information of the object resource. The placement reference point and rotation information are used as position information.

[0136] In summary, for closed object lines, the rotation information is determined based on the center point of the object line and the line segment corresponding to the object resource, and the placement reference point and the rotation information are used as the position information of the object resource. This ensures that all object resources are placed toward the inner center point.

[0137] Step 208: updating the initial image based on the object resource and the position information to obtain a target image including the target object corresponding to the object line.

[0138] Specifically, based on the object resource and the location information of the object resource obtained above, the object resource can be automatically placed in the initial image according to the location information, thereby generating a target image containing the target object.

[0139] The image generation method provided by the embodiment of the present application obtains object lines in an initial image; determines line types and line component styles based on the object lines; determines object resources corresponding to the object lines according to the line component styles, and determines location information of the object resources according to the object lines and the line types; updates the initial image based on the object resources and the location information to obtain a target image containing a target object corresponding to the object lines, thereby realizing automatic placement of object resources corresponding to the object lines, improving target image generation efficiency, and reducing labor costs and time costs.

[0140] The following combination Figure 3 , taking the application of the image generation method provided by the present application to the lake shoreline object as an example, the image generation method is further described. Figure 4 A processing flow chart of an image generation method for a lake shoreline object provided in an embodiment of the present application is shown, which specifically includes the following steps:

[0141] Step 402: Obtain the lake shore line in the initial image.

[0142] Step 404: When there are curves in the lakeshore line, convert the curves in the lakeshore line into polylines according to a preset conversion rule.

[0143] Step 406: When there is an angle between the lakeshore lines, adjust the angle to a preset angle.

[0144] Step 408: Calculate the lakeshore line to determine the line component style corresponding to the lakeshore line.

[0145] Step 410: Determine the lakeshore resource library corresponding to the lakeshore line.

[0146] Step 412: Determine the lakeshore resource matching the line component style in the lakeshore resource library according to the attribute information of the line component style.

[0147] Step 414: Determine the placement reference point of the lakeshore resource in the corresponding line segment in the lakeshore line according to the preset reference point rule.

[0148] Step 416: Calculate the center point of the lake shore line.

[0149] Step 418: Determine the rotation information of the lakeshore resource according to the center point and the line segment corresponding to the lakeshore resource in the lakeshore line.

[0150] Step 420: Use the rotation information and the placement reference point as the location information of the lakeshore resource.

[0151] Step 422: Update the initial image based on the lakeshore resources and placement information to obtain a target image of the lakeshore object corresponding to the lakeshore line.

[0152] The image generation method provided by the embodiment of the present application obtains the lakeshore lines in the initial image; determines the line component style based on the lakeshore lines; determines the lakeshore resources corresponding to the lakeshore lines according to the line component style, and determines the location information of the lakeshore resources according to the lakeshore lines; updates the initial image based on the lakeshore resources and the location information to obtain a target image including the lakeshore objects corresponding to the lakeshore lines, thereby realizing the automatic placement of the lakeshore resources corresponding to the lakeshore lines, improving the generation efficiency of the target image, and reducing the consumption of manpower and time costs.

[0153] Corresponding to the above method embodiment, the present application also provides an image generating device embodiment, Figure 5 FIG. 1 is a schematic diagram showing the structure of an image generating device provided by an embodiment of the present application. Figure 5 As shown, the device comprises:

[0154] An acquisition module 502 is configured to acquire object lines in an initial image;

[0155] A determination module 504 is configured to determine a line type and a line component style based on the object line;

[0156] The resource determination module 506 is configured to determine the object resource corresponding to the object line according to the line component style, and determine the location information of the object resource according to the object line and the line type;

[0157] The updating module 508 is configured to update the initial image based on the object resource and the position information to obtain a target image including the target object corresponding to the object line.

[0158] Optionally, the determining module 504 is further configured to:

[0159] Determine whether there is a target line point without adjacent points on both sides among the line points of the object line;

[0160] If not, determining that the line type is a closed line type;

[0161] If so, determine that the line type is a non-closed line type.

[0162] Optionally, the determining module 504 is further configured to:

[0163] Segmenting the object line according to a preset segmentation rule to obtain at least one line segment;

[0164] Matching the line segment with a preset line component style to determine the line component style corresponding to the object line; or

[0165] Calculate preset line points of the object line to determine the type of target line points contained in the object line; and determine a line component style based on the type and the object line.

[0166] Optionally, the resource determination module 506 is further configured to:

[0167] Determine a resource library corresponding to the object line;

[0168] An object resource matching the line component style is determined in the resource library according to the attribute information of the line component style.

[0169] Optionally, when the line type is a non-closed line type, the resource determination module 506 is further configured to:

[0170] Determine a placement reference point of the object resource in a line segment corresponding to the object line according to a preset reference point rule;

[0171] Determining a reference baseline of the object resource on the line segment according to a preset baseline of the object resource;

[0172] Calculating the offset information between the object resource and the line segment based on the placement reference point, the preset reference line and the reference reference line;

[0173] The placement reference point and the offset information are used as the position information of the object resource.

[0174] Optionally, when the line type is a closed line type, the resource determination module 506 is further configured to:

[0175] Determine a placement reference point of the object resource in a line segment corresponding to the object line according to a preset reference point rule;

[0176] Calculating the center point of the object line;

[0177] Determine rotation information of the object resource according to the center point and a line segment corresponding to the object resource in the object line;

[0178] The rotation information and the placement reference point are used as the position information.

[0179] Optionally, the image generating device further includes:

[0180] A conversion module, configured to, when there is a curve in the object line, convert the curve into a polyline according to a preset conversion rule;

[0181] The adjustment module is configured to adjust the angle of the included angle to a preset angle when there is an included angle in the object line.

[0182] Optionally, the initial image is created by running the following modules:

[0183] A receiving module, configured to receive a creation instruction submitted based on a configuration list;

[0184] The creation module is configured to create an initial image according to the area information and object marking information corresponding to the creation instruction.

[0185] The image generation device provided by the embodiment of the present application obtains object lines in an initial image; determines line types and line component styles based on the object lines; determines object resources corresponding to the object lines according to the line component styles, and determines location information of the object resources according to the object lines and the line types; updates the initial image based on the object resources and the location information to obtain a target image containing a target object corresponding to the object lines, thereby achieving automatic placement of object resources corresponding to the object lines, improving target image generation efficiency, and reducing labor costs and time costs.

[0186] The above is a schematic scheme of an image generating device of this embodiment. It should be noted that the technical scheme of the image generating device and the technical scheme of the above image generating method belong to the same concept, and the details not described in detail in the technical scheme of the image generating device can be referred to the description of the technical scheme of the above image generating method.

[0187] In one embodiment of the present application, a computing device is also provided, including a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor implements the steps of the image generation method when executing the computer instructions.

[0188] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above-mentioned image generation method belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above-mentioned image generation method.

[0189] An embodiment of the present application further provides a computer-readable storage medium storing computer instructions, which implement the steps of the image generation method as described above when executed by a processor.

[0190] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above-mentioned image generation method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above-mentioned image generation method.

[0191] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0192] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.

[0193] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0194] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0195] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the present application. The present application selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can understand and use the present application well. The present application is only limited by the claims and their full scope and equivalents.

Claims

1. An image generation method, characterized in that: include: Get the object lines in the initial image; Determine a line type and a line component style based on the object line, wherein the line type includes a closed line type and a non-closed line type; Determine the object resource corresponding to the object line according to the line component style, and determine the position information of the object resource according to the object line and the line type, wherein, when the line type is a non-closed line type, the position information of the object resource is determined based on the line segment corresponding to the object resource in the object line, and when the line type is a closed line type, the position information of the object resource is determined based on the center point of the object line; The initial image is updated based on the object resource and the position information to obtain a target image including the target object corresponding to the object line.

2. The image generation method according to claim 1, characterized in that: The line type is determined as follows: Determine whether there is a target line point without adjacent points on both sides among the line points of the object line; If not, determining that the line type is a closed line type; If so, determine that the line type is a non-closed line type.

3. The image generation method according to claim 1, characterized in that: The line component style is determined in the following way: Segment the object line according to a preset segmentation rule to obtain at least one line segment; match the line segment with a preset line component style to determine the line component style corresponding to the object line; or Calculating preset line points on the object line to determine the type of target line points included in the object line; A line component style is determined based on the type and the object line.

4. The image generation method according to claim 1, characterized in that: The determining the object resource corresponding to the object line according to the line component style includes: Determine a resource library corresponding to the object line; An object resource matching the line component style is determined in the resource library according to the attribute information of the line component style.

5. The image generation method according to claim 2, characterized in that: In the case where the line type is a non-closed line type, determining the location information of the object resource according to the object line and the line type includes: Determine a placement reference point of the object resource in a line segment corresponding to the object line according to a preset reference point rule; Calculate the offset information between the object resource and the line segment based on the placement reference point and the line segment corresponding to the object resource in the object line; The placement reference point and the offset information are used as the position information of the object resource.

6. The image generation method according to claim 5, characterized in that: The calculating, based on the placement reference point and the line segment corresponding to the object resource in the object line, the offset information between the object resource and the line segment comprises: Determining a reference baseline of the object resource on the line segment according to a preset baseline of the object resource; Based on the placement reference point, the preset reference line and the reference reference line, the offset information between the object resource and the line segment is calculated.

7. The image generation method according to claim 2, characterized in that: In the case where the line type is a closed line type, determining the location information of the object resource according to the object line and the line type includes: Determine a placement reference point of the object resource in a line segment corresponding to the object line according to a preset reference point rule; Calculating the center point of the object line; Determine rotation information of the object resource according to the center point and a line segment corresponding to the object resource in the object line; The rotation information and the placement reference point are used as the position information.

8. The image generation method according to claim 1, characterized in that: Before determining the line type and the line component style based on the object line, the method further includes: In the case where there is a curve in the object line, converting the curve into a polyline according to a preset conversion rule; In the case where there is an angle in the object line, the angle of the angle is adjusted to a preset angle.

9. The image generation method according to claim 1, characterized in that: The initial image is created in the following way: Receive creation instructions submitted based on the configuration list; An initial image is created according to the region information and object marking information corresponding to the creation instruction.

10. An image generating device, characterized in that: include: An acquisition module, configured to acquire object lines in an initial image; A determination module, configured to determine a line type and a line component style based on the object line, wherein the line type includes a closed line type and a non-closed line type; a resource determination module, configured to determine the object resource corresponding to the object line according to the line component style, and determine the position information of the object resource according to the object line and the line type, wherein, when the line type is a non-closed line type, the position information of the object resource is determined based on the line segment corresponding to the object resource in the object line, and when the line type is a closed line type, the position information of the object resource is determined based on the center point of the object line; The updating module is configured to update the initial image based on the object resource and the position information to obtain a target image containing the target object corresponding to the object line.

11. A computing device comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, characterized in that: When the processor executes the computer instructions, the steps of the method according to any one of claims 1 to 9 are implemented.

12. A computer-readable storage medium storing computer instructions, characterized in that: When the computer instructions are executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.

Citation Information

Patent Citations

  • Pavement texture generation method and apparatus

    CN105894564A