Disclosure of Invention
The application aims to provide a new technical scheme for drawing a portrait painting by using a mechanical arm. The following presents a simplified summary in order to provide a basic understanding of some aspects of the disclosed embodiments. This summary is not an extensive overview and is intended to neither identify key/critical elements nor delineate the scope of such embodiments. Its sole purpose is to present some concepts in a simplified form as a prelude to the more detailed description that is presented later.
According to an aspect of an embodiment of the present application, there is provided a method of drawing a portrait painting using a robot arm, including:
dividing a binary image corresponding to a portrait picture to be drawn into a plurality of areas;
the plurality of regions are subjected to drawing priority sequencing to obtain a region drawing priority sequence;
dividing each region into a plurality of communicating regions, wherein each communicating region corresponds to one stroke;
drawing priority ordering is carried out on the plurality of communication areas to obtain a stroke drawing priority order;
and controlling the mechanical arm to finish the drawing of the portrait according to the region drawing priority sequence and the stroke drawing priority sequence.
Further, the dividing each of the regions into a plurality of connected regions, each of the connected regions corresponding to a stroke, includes:
classifying strokes in each region into first-class strokes and second-class strokes; the first type of strokes are strokes formed by one stroke; the second type of stroke is a stroke formed by two or more strokes with a cross point;
dividing the first type of strokes into a communication area;
and cutting the second type of strokes into a plurality of strokes, and then dividing the plurality of strokes into different communication areas respectively.
Further, the dividing each of the regions into a plurality of communication areas includes: comparing the stroke in each region with a preset threshold value, and if the stroke length is not greater than the preset threshold value, directly dividing the stroke into a communication region; if the stroke length is larger than a preset threshold value, dividing the stroke into a plurality of communication areas after segmentation.
Further, the performing drawing priority ordering on the plurality of communication areas to obtain a stroke drawing priority order includes:
calculating the area of each communication area and the corresponding stroke starting point coordinate;
normalizing the area and the stroke starting point coordinate;
carrying out weighted summation on the normalized area and the normalized stroke starting point coordinate;
and sequencing the values obtained by weighted summation, and determining the drawing priority order of each communication area.
Further, the performing drawing priority ordering on the plurality of communication areas to obtain a stroke drawing priority order includes:
and determining the drawing priority order of each communication area according to the priority order from left to right in position, from top to bottom or from large to small in area.
Further, the performing drawing priority ordering on the plurality of communication areas to obtain a stroke drawing priority order includes:
establishing a rectangular coordinate system, acquiring the area of each communication area or the corresponding stroke starting point coordinate according to the rectangular coordinate system, and determining the drawing priority order of each communication area according to the area of each communication area or the corresponding stroke starting point coordinate.
Further, each of the connected regions corresponds to a stroke, and the method includes:
each of the communication areas is a stroke; and/or
Each of the connected regions includes a stroke and a region within a predetermined range around the stroke.
According to another aspect of the embodiments of the present application, there is provided an apparatus for drawing a portrait using a robot arm, including:
the segmentation module is used for segmenting the binary image corresponding to the portrait picture to be drawn into a plurality of areas;
the first sequencing module is used for sequencing the drawing priorities of the plurality of areas to obtain an area drawing priority sequence;
the dividing module is used for dividing each region into a plurality of communicating regions, and each communicating region corresponds to one stroke;
the second sequencing module is used for sequencing drawing priorities of the communication areas to obtain a stroke drawing priority sequence;
and the control module is used for controlling the mechanical arm to finish the portrait drawing according to the region drawing priority sequence and the stroke drawing priority sequence.
According to another aspect of the embodiments of the present application, there is provided a painting robot including a processor, a communication device, and a robot arm, the processor being capable of executing the above-mentioned method of painting a portrait using the robot arm.
According to another aspect of embodiments of the present application, there is provided a computer-readable storage medium having a computer program stored thereon, the program being executed by a processor to implement the above-mentioned method for drawing a portrait using a robot arm.
The technical scheme provided by one aspect of the embodiment of the application can have the following beneficial effects:
the method for drawing the portrait painting by using the mechanical arm can control the mechanical arm to draw according to the region drawing priority sequence and the stroke drawing priority sequence, wherein the region drawing priority sequence and the stroke drawing priority sequence are very close to the drawing sequence of a real painter, so that the pen moving sequence of the mechanical arm drawing is highly close to the pen moving sequence of the real painter drawing.
Additional features and advantages of the application will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the embodiments of the application, or may be learned by the practice of the embodiments. The objectives and other advantages of the application may be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is further described with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It will be understood by those within the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
As shown in fig. 1, one embodiment of the present application provides a method of drawing a portrait using a robotic arm, comprising:
and S1, dividing the binary image corresponding to the portrait to be drawn into a plurality of areas.
For example, the binary image may be an input target person simple stroke portrait; the simple strokes are generally formed by simple lines; dividing the target person simple stroke portrait according to organs and wearing objects, for example, dividing the target person simple stroke portrait into a plurality of areas such as a face, a right eyebrow, a left eyebrow, a right eye, a left eye, glasses, a right ear, a left ear, an earring, a nose, a mouth (oral cavity), an upper lip, a lower lip, a neck, a necklace, clothes, hair, a hat and the like;
and S2, carrying out drawing priority sequencing on the plurality of areas to obtain an area drawing priority sequence.
For example, numbering each region, and prioritizing each region as hat > hair > facial contour > left ear > right ear > left eyebrow > right eyebrow > eye > nose > mouth > other regions, then ranking the numbers of the corresponding regions in the order of priority;
and S3, dividing each area into a plurality of connected areas, wherein each connected area corresponds to a single stroke.
In some embodiments, each of the connected regions is a single stroke, i.e., a stroke is directly used as a connected region.
In some embodiments, each connected region contains a single stroke, and the connected region further includes a region within a predetermined range around the stroke; for example, the connected region may be preset as a region formed by points with a minimum value of 0.5mm from each point on the stroke, and the specific preset range may be adjusted and set according to the needs of practical application; if the connected region is preset as a region constituted by points whose minimum value from each point on the stroke is 0, one stroke is a connected region.
In some embodiments, each of said connected regions corresponds to a stroke, comprising:
each of the communication areas is a stroke; and/or
Each of the connected regions includes a stroke and a region within a predetermined range around the stroke.
In some embodiments, the dividing each of the regions into a plurality of communication areas includes: when the connected regions are divided, comparing the stroke in each region with a preset threshold value, and if the stroke length is not greater than the preset threshold value, directly dividing the stroke into one connected region; if the stroke length is larger than the preset threshold value, the stroke is divided into a plurality of strokes, and the plurality of strokes obtained after division are divided into a plurality of communication areas.
In certain embodiments, step S3 includes:
s31, classifying the strokes in each region into a first type of strokes and a second type of strokes; the first type of strokes are strokes formed by one stroke; the second type of stroke is a stroke formed by two or more strokes with a cross point;
s32, dividing the first type of strokes into a communication area;
s33, cutting the second type of strokes into a plurality of strokes, and then dividing the plurality of strokes into different communication areas respectively.
And S4, carrying out drawing priority sequencing on the plurality of communication areas to obtain a stroke drawing priority sequence.
In certain embodiments, step S4 includes:
s41, calculating the area of each communication area and the corresponding stroke starting point coordinate; in some embodiments, the area of the connected region is the area occupied by the strokes of the connected region;
s42, normalizing the area and the stroke starting point coordinates, and then performing weighted summation on the normalized area and the normalized stroke starting point coordinates;
for example, a rectangular coordinate system is established with the upper left corner of the canvas as the origin; configuring different weights for the normalized area and the normalized stroke starting point coordinate respectively; the formula of weighted summation is Sum ═ α S + β d; wherein alpha and beta are respectively the normalized area and the normalized weight of the stroke starting point coordinate;
and S43, sorting the values obtained by weighted summation, and determining the drawing priority order of each communication area.
In certain embodiments, step S4 includes:
and determining the drawing priority order of each communication area according to the priority order from left to right in position, from top to bottom or from large to small in area. And establishing a rectangular coordinate system by taking the upper left corner or the lower right corner of the canvas or the drawing paper as an origin, acquiring the area of each communication area or the corresponding stroke starting point coordinate according to the rectangular coordinate system, and determining the drawing priority order of each communication area according to the area of each communication area or the corresponding stroke starting point coordinate.
In some embodiments, for more complicated parts such as the left eye, the right eye, the glasses, the mouth, and the like, because the stroke structures are relatively complicated, after the parts are divided into different communication areas, the artificial drawing sequence of each stroke of the complicated parts (the artificial drawing sequence is the drawing sequence of each stroke when the painter draws the complicated parts) is obtained through a deep learning algorithm, and then the communication areas of the complicated parts are made into the drawing priority sequence according to the drawing sequence.
And S5, controlling the mechanical arm to move the painting brush according to the region drawing priority sequence and the stroke drawing priority sequence to finish the drawing of the portrait painting.
As shown in fig. 2, the present embodiment also provides an apparatus for drawing a portrait using a robot arm, including:
the segmentation module 100 is configured to segment a binary image corresponding to a portrait to be drawn into a plurality of regions;
a first ordering module 200, configured to perform drawing priority ordering on the plurality of regions, so as to obtain a region drawing priority order;
a dividing module 300, configured to divide each of the regions into a plurality of connected regions, where each of the connected regions corresponds to one stroke;
a second sorting module 400, configured to sort the rendering priorities of the connected regions to obtain a stroke rendering priority order;
and the control module 500 is used for controlling the mechanical arm to finish the portrait drawing according to the region drawing priority sequence and the stroke drawing priority sequence.
The embodiment also provides a painting robot, which comprises a processor, a communication device and a mechanical arm, wherein the processor can execute the method for drawing the portrait painting by using the mechanical arm.
The present embodiment also provides a computer-readable storage medium having a computer program stored thereon, the program being executed by a processor to implement the method for drawing a portrait using a robot arm as described above.
The method for drawing the portrait painting by using the mechanical arm can simulate the pen-carrying track drawing of a real-person painter, the mechanical arm is controlled to draw according to the region drawing priority sequence and the stroke drawing priority sequence, and the region drawing priority sequence and the stroke drawing priority sequence are extremely close to the drawing sequence of the real-person painter, so that the pen-carrying sequence of the mechanical arm drawing is highly approximate to the pen-carrying sequence of the real-person painter drawing.
As shown in fig. 3, an embodiment of the present application provides a method of drawing a portrait using a robot arm, including:
A1. face analysis and segmentation: and dividing the target character simple stroke portrait painting according to regions of five sense organs and the like.
Specifically, the target person simple stroke portrait painting is divided according to areas such as a face, a right eyebrow, a left eyebrow, a right eye, a left eye, glasses, a right ear, a left ear, earrings, a nose, a mouth (oral cavity), an upper lip, a lower lip, a neck, a necklace, clothes, hair, a hat and the like, and an image of the corresponding area is generated. In a specific implementation, the drawing order of each stroke is determined based on the principle of left-to-right, top-to-bottom and big-to-small as a whole according to the common habit of the painter.
A human face analyzing step: the target face image is divided according to the areas of the face, the right eyebrow, the left eyebrow, the right eye, the left eye, the glasses, the right ear, the left ear, the earrings, the nose, the mouth (oral cavity), the upper lip, the lower lip, the neck, the necklace, clothes, hair, a hat and the like through a deep learning method, and area pictures with labels are respectively obtained.
A2. Human-simulated sequencing of the drawing area: and sequencing the obtained area tracks according to the common artist custom sequence.
A3. Generating a drawing track: and generating a drawing track according to the stroke sequence obtained by A2.
Basic drawing sequence based on face structure: the regions of the face image are divided according to the face analysis (matching) result obtained in a2, and the drawing order of each region is determined according to the common habit of the painter. In a specific implementation case, the priority of each region is to be determined as: hat > hair > facial contour > left ear > right ear > left eyebrow > left eye > right eyebrow > glasses > nose > mouth > other areas.
Aiming at the left eye, the right eye, the glasses and the mouth area, because the structure is relatively complex, the drawing sequence of a painter is learned by a deep learning method, all lines in the area corresponding to a given image are divided into different strokes and the corresponding sequences, and the strokes and the corresponding sequences are drawn in sequence.
For other areas, dividing lines of the corresponding area into different connected areas, wherein each connected area corresponds to one stroke; then, calculating the area and the starting point coordinate of each communication area; normalizing the area and the starting point coordinate, and then weighting; and sequencing according to the weighted numerical values, and determining the drawing priority of each connected region according to the principle of from left to right, from top to bottom and from large to small.
This embodiment can be according to the effective region generation drawing orbit of the arm of input image and reality, can the complete input image that draws to can optimize the process of arm drawing according to the custom drawing order of real person painter.
It should be noted that:
the term "module" is not intended to be limited to a particular physical form. Depending on the particular application, a module may be implemented as hardware, firmware, software, and/or combinations thereof. Furthermore, different modules may share common components or even be implemented by the same component. There may or may not be clear boundaries between the various modules.
The algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose devices may be used with the teachings herein. The required structure for constructing such a device will be apparent from the description above. In addition, this application is not directed to any particular programming language. It will be appreciated that a variety of programming languages may be used to implement the teachings of the present application as described herein, and any descriptions of specific languages are provided above to disclose the best modes of the present application.
In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the application may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the application, various features of the application are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: this application is intended to cover such departures from the present disclosure as come within known or customary practice in the art to which this invention pertains. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this application.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the application and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
The various component embodiments of the present application may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components in the creation apparatus of a virtual machine according to embodiments of the present application. The present application may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present application may be stored on a computer readable medium or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the application, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The application may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
The above-mentioned embodiments only express the embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.