Dynamic image playing method and device, computer equipment and readable storage medium
1. A dynamic image playing method is applied to a server, and the method comprises the following steps:
acquiring an image sequence of a dynamic image to be played, wherein the image sequence comprises at least two single-frame images;
splicing the single-frame images in the image sequence to obtain corresponding spliced images;
and sending the spliced images to a terminal, so that the terminal cuts out each single-frame image from the received spliced images, draws the single-frame images in a canvas according to a time sequence and plays dynamic images.
2. The method according to claim 1, wherein the stitching the single-frame images in the image sequence to obtain corresponding stitched images comprises:
acquiring the number of image lines of a spliced image to be generated and the number of images of single-frame images in the image sequence, wherein the number of image lines is the number of arrangement lines of the single-frame images in the spliced image to be generated;
determining the number of image columns of the spliced image to be generated based on the number of image lines and the number of images;
and splicing the at least two single-frame images according to the image line number and the image column number and the acquisition time sequence of the single-frame images in the image sequence to generate a corresponding spliced image.
3. The method according to claim 2, wherein the stitching the at least two single-frame images according to the number of image rows and the number of image columns and the acquisition time sequence of single-frame images in the image sequence to generate a corresponding stitched image comprises:
acquiring a preset line spacing and a preset column spacing of a spliced image to be generated;
and splicing the at least two single-frame images according to the line spacing, the column spacing, the image line number and the image column number and the acquisition time sequence of the single-frame images in the image sequence to obtain corresponding spliced images.
4. A dynamic image playing method is applied to a terminal, and the method comprises the following steps:
receiving a spliced image sent by a server, wherein the spliced image is generated by splicing at least two single-frame images in an image sequence;
initializing a canvas for playing the dynamic image;
and sequentially cutting out each single-frame image from the spliced images, drawing the single-frame images in the canvas according to a time sequence, and playing the dynamic images.
5. The method according to claim 4, wherein the sequentially cropping the single-frame images from the stitched image, and drawing the single-frame images in the canvas in time sequence for playing the dynamic image comprises:
acquiring each single-frame image from the spliced images according to the acquisition time sequence of each single-frame image in the spliced images;
acquiring the size of the canvas;
adjusting the size of the acquired image of each single frame image to the size of the canvas to obtain each single frame image after the image size is adjusted;
and drawing each single-frame image after the image size is adjusted in the canvas, and playing the dynamic image.
6. The method according to claim 4, wherein the sequentially cropping the single-frame images from the stitched image, and drawing the single-frame images in the canvas in time sequence for playing the dynamic image comprises:
initializing a counter, wherein the count value of the counter is equal to the current frame number of the played dynamic image;
acquiring a first frame image from the spliced image, and drawing the first frame image in the canvas;
adding one to the count value of the counter;
judging whether the count value of the counter is equal to a preset threshold value or not;
and when the count value of the counter is not equal to the preset threshold value, acquiring the next single-frame image from the spliced image according to the acquisition time sequence of each single-frame image in the spliced image, and continuously drawing the next single-frame image in the canvas for playing the dynamic image.
7. The method according to claim 6, wherein the obtaining a next single frame image from the stitched image according to the collection time sequence of each single frame image in the stitched image, and drawing the next single frame image in the canvas for playing the dynamic image further comprises:
initializing a timer, and judging whether the timing duration of the timer reaches a preset duration or not;
and when the timing duration reaches the preset duration, acquiring the next single-frame image from the spliced image according to the acquisition time sequence of each single-frame image in the spliced image, and continuously drawing the next single-frame image in the canvas for playing the dynamic image.
8. A moving picture playback apparatus, applied to a server, the apparatus comprising:
the image sequence acquisition module is used for acquiring an image sequence of a dynamic image to be played, wherein the image sequence comprises at least two single-frame images;
the splicing module is used for splicing the single-frame images in the image sequence to obtain corresponding spliced images;
and the sending module is used for sending the spliced images to a terminal, so that the terminal cuts out each single-frame image from the received spliced images, draws the single-frame images in canvas according to a time sequence and plays dynamic images.
9. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the steps of the method of any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
Background
With the development of science and technology, the performance and network speed of mobile terminal equipment are greatly improved. Therefore, the company developing the business based on the internet pays more and more attention to the user experience besides the basic business function, and the good user experience can improve the customer conversion rate and assist the business development of the company. The user experience is improved in various aspects, such as good layout, beautiful interface design, quick response, smooth interactive animation and the like. The application of animation effects is manifold, such as slight transition, cool special effects, fluency of interactive combination, and the like. The cool special effect can particularly attract the eyeball, and the application grade is improved, so that the reliability of the user on the platform is improved.
In the conventional method, basic methods for realizing animation include Cascading Style Sheets (CSS) animation, canvas animation, sequence frame animation, Graphics Interchange Format (gif) diagram animation, and the like. However, the CSS animation does not satisfy the complex special effect, the gif animation special effect performance is low, the canvas animation increases the development difficulty by times with the increase of the special effect, the sequence frame animation triggers the update of the browser Document Object Model (DOM) every time the playback is switched, and the extensibility is low.
Therefore, the problem that needs to be solved in the prior stage of animation display at the time when the expansibility needs to be achieved is met.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a moving image playing method, a moving image playing apparatus, a computer device, and a readable storage medium, which can improve the scalability of moving image playing.
A dynamic image playing method is applied to a server, and comprises the following steps:
acquiring an image sequence of a dynamic image to be played, wherein the image sequence comprises at least two single-frame images;
splicing single-frame images in the image sequence to obtain corresponding spliced images;
and sending the spliced images to the terminal, so that the terminal cuts out each single-frame image from the received spliced images, draws the single-frame images in the canvas according to the time sequence and plays the dynamic images.
In one embodiment, stitching single-frame images in an image sequence to obtain a corresponding stitched image includes:
acquiring the number of image lines of a spliced image to be generated and the number of images of single-frame images in an image sequence, wherein the number of the image lines is the number of arrangement lines of the single-frame images in the spliced image to be generated;
determining the number of image columns of the spliced image to be generated based on the number of image lines and the number of images;
and splicing at least two single-frame images according to the number of image lines and the number of image columns and the acquisition time sequence of the single-frame images in the image sequence to generate a corresponding spliced image.
In one embodiment, stitching at least two single-frame images according to the acquisition time sequence of the single-frame images in the image sequence according to the number of image rows and the number of image columns to generate a corresponding stitched image includes:
acquiring a preset line spacing and a preset column spacing of a spliced image to be generated;
and splicing at least two single-frame images according to the line spacing, the column spacing, the image line number and the image column number and the acquisition time sequence of the single-frame images in the image sequence to obtain corresponding spliced images.
A dynamic image playing method is applied to a terminal, and comprises the following steps:
receiving a spliced image sent by a server, wherein the spliced image is generated by splicing at least two single-frame images in an image sequence;
initializing a canvas for playing the dynamic image;
and sequentially cutting out each single-frame image from the spliced images, drawing the single-frame images in the canvas according to the time sequence, and playing the dynamic images.
In one embodiment, sequentially cutting out single-frame images from the stitched image, and drawing the single-frame images in a canvas according to a time sequence to play a dynamic image, includes:
acquiring each single-frame image from the spliced images according to the acquisition time sequence of each single-frame image in the spliced images;
obtaining the size of a canvas;
adjusting the size of the acquired image of each single frame image to the size of the canvas to obtain each single frame image after the image size is adjusted;
and drawing each single-frame image after the image size is adjusted in a canvas, and playing the dynamic image.
In one embodiment, sequentially cutting out single-frame images from the stitched image, and drawing the single-frame images in a canvas according to a time sequence to play a dynamic image, includes:
initializing a counter, wherein the count value of the counter is equal to the current frame number of the played dynamic image;
acquiring a first frame image from the spliced image and drawing the first frame image in a canvas;
adding one to the count value of the counter;
judging whether the count value of the counter is equal to a preset threshold value or not;
and when the count value of the counter is not equal to the preset threshold value, acquiring the next single-frame image from the spliced image according to the acquisition time sequence of each single-frame image in the spliced image, continuously drawing in the canvas, and playing the dynamic image.
In one embodiment, the method for obtaining a next frame of single-frame image from a stitched image according to an acquisition time sequence of each single-frame image in the stitched image, and drawing the next frame of single-frame image in a canvas, before playing a dynamic image, further includes:
initializing a timer, and judging whether the timing duration of the timer reaches a preset duration or not;
and when the timing duration reaches the preset duration, acquiring the next single-frame image from the spliced image according to the acquisition time sequence of each single-frame image in the spliced image, continuously drawing in the canvas, and playing the dynamic image.
A dynamic image playing device applied to a server, the device comprising:
the image sequence acquisition module is used for acquiring an image sequence of a dynamic image to be played, and the image sequence comprises at least two single-frame images;
the splicing module is used for splicing the single-frame images in the image sequence to obtain corresponding spliced images;
and the sending module is used for sending the spliced images to the terminal, so that the terminal cuts out each single-frame image from the received spliced images, draws the single-frame images in the canvas according to the time sequence and plays the dynamic images.
A computer device comprising a memory storing a computer program and a processor implementing the steps of the method of any of the above embodiments when the processor executes the computer program.
A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method of any of the above embodiments.
According to the dynamic image playing method, the dynamic image playing device, the computer equipment and the readable storage medium, the image sequence of the dynamic image to be played is obtained, the image sequence comprises at least two single-frame images, then the single-frame images in the image sequence are spliced to obtain the corresponding spliced image, the spliced image is further sent to the terminal, the terminal cuts out each single-frame image from the received spliced image, the single-frame image is drawn in the canvas according to the time sequence, and the dynamic image playing is carried out. Therefore, the single-frame images can be synthesized into the spliced image according to the actual special effect requirement, when the terminal plays, the single-frame images can be captured from the obtained spliced image and played, and the special effect requirement of animation playing is met. In addition, by cutting the single-frame image from the spliced image and playing the single-frame image, for the terminal, the dynamic image can be played only by drawing the cut single-frame image into the canvas, the update of the DOM number of the browser cannot be triggered, and the expansibility of playing the dynamic image is improved.
Drawings
FIG. 1 is a diagram illustrating an exemplary scenario for playing a dynamic image;
FIG. 2 is a flowchart illustrating a method for playing a dynamic image according to an embodiment;
FIG. 3 is a diagram of a single frame image in one embodiment;
FIG. 4 is a schematic illustration of stitching images in one embodiment;
FIG. 5 is a diagram illustrating the steps in drawing an image into a canvas in one embodiment;
FIG. 6 is a flowchart illustrating a method for playing a moving image according to another embodiment;
FIG. 7 is a flowchart illustrating a step of playing a moving picture according to an embodiment;
FIG. 8 is a block diagram showing the construction of a moving picture playback apparatus according to an embodiment;
FIG. 9 is a block diagram showing the construction of a moving picture reproducing apparatus according to another embodiment;
FIG. 10 is a diagram showing an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and 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.
The dynamic image playing method provided by the application can be applied to the application environment shown in fig. 1. Wherein the terminal 102 communicates with the server 104 via a network. The server 104 may obtain an image sequence of a dynamic image to be played, where the image sequence may include at least two single-frame images, and then the server 104 may stitch the single-frame images in the image sequence to obtain a corresponding stitched image, and further, the server 104 may send the stitched image to the terminal 102, so that the terminal 102 cuts out each single-frame image from the received stitched image, and draws the single-frame image in a canvas according to a time sequence to play the dynamic image. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices, and the server 104 may be implemented by an independent server or a server cluster formed by a plurality of servers.
In one embodiment, as shown in fig. 2, a method for playing a dynamic image is provided, which is described by taking the method as an example applied to the server in fig. 1, and includes the following steps:
step S202, obtaining an image sequence of a dynamic image to be played, wherein the image sequence comprises at least two single-frame images.
When the dynamic image is played, the multi-frame image is switched, and the image seen by human eyes is continuously dynamic by controlling the switching time or frequency.
In this embodiment, the image sequence is a sequence of moving images, and the image sequence may include at least two single-frame images, and each single-frame image represents an image state.
In this embodiment, the server may draw an image sequence of the dynamic image based on a special effect requirement of a specific service, and the number of single-frame images in the image sequence and the image effect of each single-frame image may be different according to a difference of the specific special effect.
And step S204, splicing the single-frame images in the image sequence to obtain corresponding spliced images.
Wherein, the image is spliced by splicing a plurality of images.
In this embodiment, after acquiring the image sequence, the server may determine the number of images in the acquired image sequence, and based on the image data, splice the single-frame images to obtain a corresponding spliced image.
Specifically, each single frame image in the image sequence may be as shown in (a) or (b) in fig. 3 below, and the stitched image may be as shown in fig. 4.
It can be understood by those skilled in the art that when the stitching is performed, only the multiple frames of images are stitched into one large image, and the image pixels of the single frames of the stitched image are not changed.
And step S206, sending the spliced images to the terminal, so that the terminal cuts out each single-frame image from the received spliced images, draws the single-frame images in the canvas according to the time sequence and plays the dynamic images.
In this embodiment, after acquiring the stitched image, the server may send the stitched image to the terminal, so that the terminal performs subsequent processing.
In this embodiment, the server may send the stitched image to the terminal after receiving the request from the terminal, for example, when the terminal starts an application to trigger playing of the dynamic image, the server may obtain the stitched image from the server and perform subsequent processing. Or, the terminal may obtain the stitched image when starting the application, and perform subsequent processing directly based on the dynamic stitched image when the dynamic image needs to be played subsequently.
In this embodiment, after the terminal acquires the stitched image, each single-frame image may be cut from the stitched image, and the single-frame images are drawn in the canvas according to the time sequence to play the dynamic image.
Specifically, the server cuts down each single frame image from the stitched images according to the time sequence, then draws the single frame image into the canvas, and plays the dynamic images. The specific playing process of the dynamic image can be rendered and drawn by combining the playing frequency, the size of the canvas and the like.
For example, referring to fig. 5, after creating the canvas, a brush object may be obtained by a method "var ctx ═ canvas. getcontext ('2 d')", and then each single frame image in the stitched image is clipped by "ctx. drawimage (image, sx, sy, sfidth, sfight, dx, dy, dfidth, dfight)" and drawn in the canvas. Wherein, the parameter "image" represents the stitched image, and the parameters "sx, sy, sfidth, sfight" represent the slice position and size of the defined source image, i.e. the position and size of the cropped image in the stitched image. The parameter "dx, dy, dWidth, dHeight" indicates the position and size of the clipped single-frame image in the target display position and size, i.e., the position and size displayed into the canvas.
According to the dynamic image playing method, the image sequence of the dynamic image to be played is obtained, the image sequence comprises at least two single-frame images, then the single-frame images in the image sequence are spliced to obtain the corresponding spliced image, the spliced image is further sent to the terminal, the terminal cuts out each single-frame image from the received spliced image, the single-frame image is drawn in a canvas according to the time sequence, and the dynamic image is played. Therefore, the single-frame images can be synthesized into the spliced image according to the actual special effect requirement, when the terminal plays, the single-frame images can be captured from the obtained spliced image and played, and the special effect requirement of animation playing is met. In addition, by cutting the single-frame image from the spliced image and playing the single-frame image, for the terminal, the dynamic image can be played only by drawing the cut single-frame image into the canvas, the update of the DOM number of the browser cannot be triggered, and the expansibility of playing the dynamic image is improved.
In one embodiment, stitching single-frame images in an image sequence to obtain a corresponding stitched image may include: acquiring the number of image lines of a spliced image to be generated and the number of images of single-frame images in an image sequence, wherein the number of the image lines is the number of arrangement lines of the single-frame images in the spliced image to be generated; determining the number of image columns of the spliced image to be generated based on the number of image lines and the number of images; and splicing at least two single-frame images according to the number of image lines and the number of image columns and the acquisition time sequence of the single-frame images in the image sequence to generate a corresponding spliced image.
The image line number refers to the arrangement line number of a single frame image in the stitched image to be generated, and may be a preset value, as shown in fig. 4.
In this embodiment, after acquiring the image sequence, the server may acquire the number of single-frame images in the image sequence and acquire the preset number of image lines of the stitched image to be generated.
In this embodiment, the server may determine the number of columns of the stitched image to be generated according to the number of acquired lines and the number of image lines, for example, the number of image columns may be determined by a division method.
Further, the server can obtain single-frame images from the image sequence according to the number of image lines and the number of image columns and perform splicing to obtain a spliced image.
In this embodiment, when the server performs the splicing, the single-frame images may be sequentially spliced from left to right and from top to bottom according to the acquisition time sequence of the single-frame images acquired by the images in the image sequence, so as to obtain the corresponding spliced images.
In one embodiment, after the server acquires the image sequence, the server may determine the number of single-frame images in the image sequence, and determine whether the number is greater than a preset number value.
In this embodiment, when the server determines that the number of the single-frame images is greater than the preset number value, the images are spliced according to the number of the image lines and the number of the image columns to obtain a spliced image. When the number of the single frame images is less than or equal to the preset number value, a frame image list can be generated based on the acquired image sequence and sent to the terminal, so that the terminal plays the dynamic images based on the frame image list.
In one embodiment, the number of image rows and the number of image columns of the stitched image may also be determined based on the number of single-frame images in the image sequence, for example, the number of image rows and the number of image columns are set to be equal or different to a minimum, so that the length and width dimensions of the generated stitched image do not differ too much.
In the above embodiment, the single-frame images are spliced according to the number of the image lines and the number of the image columns and the acquisition time sequence to obtain the spliced image, so that the accuracy and the integrity of image splicing can be ensured, the possibility of errors is avoided, and the accuracy of playing the subsequent dynamic images is improved.
In one embodiment, stitching at least two single-frame images according to the acquisition time sequence of the single-frame images in the image sequence according to the number of image rows and the number of image columns to generate a corresponding stitched image may include: acquiring a preset line spacing and a preset column spacing of a spliced image to be generated; and splicing at least two single-frame images according to the line spacing, the column spacing, the image line number and the image column number and the acquisition time sequence of the single-frame images in the image sequence to obtain corresponding spliced images.
In this embodiment, when the server performs image stitching, the server may obtain a preset row-to-row distance and a preset column-to-column distance between rows and columns of a stitched image to be generated, and then perform subsequent stitching processing.
Specifically, the server may perform stitching according to the acquisition time sequence of the single-frame images in the image sequence according to the line spacing and the column spacing to obtain the corresponding stitched image.
In the above embodiment, by setting the line spacing and the column spacing and performing the splicing, the subsequent cutting can be performed based on the line spacing and the column spacing when the single-frame image is cut, thereby avoiding the possibility of error in cutting.
In one embodiment, as shown in fig. 6, a method for playing a moving image is provided, which is described by taking the method as an example applied to the terminal in fig. 1, and includes the following steps:
and step S602, receiving a spliced image sent by the server, wherein the spliced image is generated by splicing at least two single-frame images in the image sequence.
The stitched image is as described above, and is not described here again.
In this embodiment, the terminal may acquire the stitched image when the playing of the dynamic image is triggered, and perform subsequent processing operations.
In step S604, a canvas for playing the dynamic image is initialized.
Specifically, the terminal may initialize a canvas of the dynamic image, for example, the terminal may initialize a canvas, cut out single-frame images from the stitched image, and play the dynamic image.
And step S606, cutting out each single frame image from the spliced images in sequence, drawing the single frame images in a canvas according to a time sequence, and playing the dynamic images.
In this embodiment, the terminal may sequentially draw the single frame image obtained by cutting into the initialized canvas, and continuously switch the single frame image drawn into the canvas, so as to implement playing of the dynamic image. For example, referring to fig. 7, when performing image stitching, the server performs stitching in the order from left to right and from top to bottom according to the time sequence 1 to n, and when performing clipping, the server may sequentially clip the single-frame images in the order from left to right and from top to bottom in the stitched image, and sequentially draw the single-frame images in the canvas according to the time sequence to play the moving image.
In one embodiment, sequentially cutting out the single-frame images from the stitched image, and drawing the single-frame images in a canvas according to a time sequence to play a dynamic image may include: acquiring each single-frame image from the spliced images according to the acquisition time sequence of each single-frame image in the spliced images; obtaining the size of a canvas; adjusting the size of the acquired image of each single frame image to the size of the canvas to obtain each single frame image after the image size is adjusted; and drawing each single-frame image after the image size is adjusted in a canvas, and playing the dynamic image.
As previously described, the stitched images are stitched in accordance with the acquisition time sequence of the single frame images.
In this embodiment, when the terminal plays the dynamic image, the terminal may cut and acquire each single frame image from the stitched image according to the acquisition time sequence, and then play the dynamic image.
In this embodiment, the terminal may first obtain the size of the initialized canvas, and then determine whether the image size of the obtained single frame image is consistent with the size of the canvas.
In this embodiment, when the image size of the single frame image is consistent with the size of the canvas, the single frame image obtained by cutting is directly drawn in the canvas for playing the dynamic image, and when the image size of the single frame image is inconsistent with the size of the canvas, the terminal may adjust the image size of the single frame image according to the size of the canvas, so that the image size of the adjusted single frame image is consistent with the size of the canvas.
Further, the terminal can draw the single-frame image with the adjusted image size into a canvas for dynamic image playing.
In one embodiment, sequentially cutting out the single-frame images from the stitched image, and drawing the single-frame images in a canvas according to a time sequence to play a dynamic image may include: initializing a counter, wherein the count value of the counter is equal to the current frame number of the played dynamic image; acquiring a first frame image from the spliced image and drawing the first frame image in a canvas; adding one to the count value of the counter; judging whether the count value of the counter is equal to a preset threshold value or not; and when the count value of the counter is not equal to the preset threshold value, acquiring the next single-frame image from the spliced image according to the acquisition time sequence of each single-frame image in the spliced image, continuously drawing in the canvas, and playing the dynamic image.
In this embodiment, the terminal may initialize a counter and then set the count value to 0.
Further, the terminal may obtain a first frame image, i.e., a first frame image, from the stitched image, and then draw the first frame image in the canvas.
In this embodiment, the terminal may set the count value of the counter to be increased by one, where the count value of the counter is equal to the current frame number of the played dynamic image.
Further, the terminal may determine whether the count value of the counter is equal to a preset threshold value. And the preset threshold value is equal to the number of the single-frame images forming the spliced image.
In this embodiment, when the terminal determines that the count value is smaller than the preset threshold, the terminal may obtain a next single-frame image from the stitched image according to the acquisition time sequence of each single-frame image in the stitched image, and continuously draw the next single-frame image in the canvas for playing the dynamic image.
In this embodiment, when the terminal determines that the count value is equal to the preset threshold, the terminal may determine that the playing of the single frame image in the stitched image is completed, and the terminal may initialize the counter again and restart the playing from the first frame image.
In the above embodiment, the number of the played images is counted by setting the counter, so that the number of the played single-frame images can be accurately tracked, the probability of playing errors is avoided, and the accuracy of playing dynamic images is improved.
In one embodiment, acquiring a next single-frame image from the stitched image according to the acquisition time sequence of each single-frame image in the stitched image, and drawing the next single-frame image in the canvas before playing the dynamic image, may further include: initializing a timer, and judging whether the timing duration of the timer reaches a preset duration or not; and when the timing duration reaches the preset duration, acquiring the next single-frame image from the spliced image according to the acquisition time sequence of each single-frame image in the spliced image, continuously drawing in the canvas, and playing the dynamic image.
In this embodiment, the terminal may further initialize a timer to time the staying time between the frame and the frame single image.
Specifically, the terminal may set a preset duration of the timer, where the preset duration may be determined according to a playing effect of the dynamic tone image.
In this embodiment, after the terminal cuts out the single frame image and draws the single frame image into the canvas, the timer starts to time, and when the timing duration reaches the preset duration, the next single frame image is drawn into the canvas, so as to play the dynamic image.
In this embodiment, after the timer reaches the preset time, the timer may be automatically cleared, and the timing is restarted and the cycle is repeated.
In the above embodiment, by setting the timer and timing the playing time of the single-frame image, it can be ensured that the playing time between the single-frame image and the single-frame image is maintained within the same time, the playing effect of playing the dynamic image is improved, and further the user experience can be improved.
In one embodiment, the method may further include: and uploading at least one of the image sequence and the spliced image to a block chain node for storage.
The blockchain refers to a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A Block chain (Block chain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data Block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next Block.
Specifically, the blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
In this embodiment, the server may upload and store one or more data in the image sequence and the stitched image in the node of the blockchain, so as to ensure the privacy and security of the data.
In the embodiment, at least one of the image sequence and the spliced image is uploaded to the block chain and stored in the node of the block chain, so that the privacy of data stored in the node of the block chain can be guaranteed, and the security of the data can be improved.
It should be understood that although the steps in the flowcharts of fig. 2 and 6 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 described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2 and 6 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performing the sub-steps or stages is not necessarily sequential, but may be performed alternately or alternately with other steps or at least some of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 8, a moving picture playing apparatus applied to a server may include: an image sequence acquisition module 802, a stitching module 804, and a sending module 806, wherein:
an image sequence acquiring module 802, configured to acquire an image sequence of a dynamic image to be played, where the image sequence includes at least two single-frame images.
The splicing module 804 is configured to splice the single-frame images in the image sequence to obtain a corresponding spliced image.
And a sending module 806, configured to send the stitched image to the terminal, so that the terminal cuts out each single frame image from the received stitched image, and draws the single frame image in the canvas according to the time sequence to play the dynamic image.
In one embodiment, the splicing module 804 may include:
and the obtaining submodule is used for obtaining the image line number of the spliced image to be generated and the image number of the single-frame images in the image sequence, wherein the image line number is the arrangement line number of the single-frame images in the spliced image to be generated.
And the image line number determining submodule is used for determining the image column number of the spliced image to be generated based on the image line number and the image number.
And the spliced image generation submodule is used for splicing at least two single-frame images according to the image line number and the image column number and the acquisition time sequence of the single-frame images in the image sequence to generate a corresponding spliced image.
In one embodiment, the stitched image generation sub-module may include:
and the acquisition unit is used for acquiring the preset line spacing and the preset column spacing of the spliced image to be generated.
And the splicing unit is used for splicing at least two single-frame images according to the line spacing, the column spacing, the image line number and the image column number and the acquisition time sequence of the single-frame images in the image sequence to obtain the corresponding spliced images.
In one embodiment, as shown in fig. 9, another moving image playing apparatus is provided, which is applied to a terminal and may include: a receiving module 902, an initializing module 904, and a clipping playing module 906, wherein:
the receiving module 902 is configured to receive a stitched image sent by a server, where the stitched image is generated by stitching at least two single-frame images in an image sequence.
An initialization module 904 for initializing a canvas on which the dynamic image is played.
And a cutting playing module 906, configured to cut out each single frame image from the stitched images in sequence, and draw the single frame image in the canvas according to the time sequence, so as to play the dynamic image.
In one embodiment, the clipping playing module 906 may include:
and the single-frame image acquisition sub-module is used for acquiring each single-frame image from the spliced images according to the acquisition time sequence of each single-frame image in the spliced images.
And the canvas size obtaining submodule is used for obtaining the size of the canvas.
The adjusting submodule is used for adjusting the size of the acquired image of each single-frame image to the size of the canvas to obtain each single-frame image after the image size is adjusted;
and the playing sub-module is used for drawing each single-frame image after the image size is adjusted in the canvas for playing the dynamic image.
In one embodiment, the clipping playing module 906 may include:
and the initialization submodule is used for initializing a counter, and the count value of the counter is equal to the current frame number of the played dynamic image.
And the drawing submodule is used for acquiring the first frame of image from the spliced image and drawing the first frame of image in the canvas.
And the counting submodule is used for adding one to the counting value of the counter.
And the judgment submodule is used for judging whether the count value of the counter is equal to a preset threshold value or not.
And the circulation sub-module is used for acquiring the next single-frame image from the spliced image according to the acquisition time sequence of each single-frame image in the spliced image when the count value of the counter is not equal to the preset threshold value, and continuously drawing the next single-frame image in the canvas for playing the dynamic image.
In one embodiment, the apparatus may further include:
the timer module is used for acquiring a next frame of single-frame image from the spliced image according to the acquisition time sequence of each single-frame image in the spliced image, continuously drawing the single-frame image in the canvas, initializing the timer before playing the dynamic image, and judging whether the timing duration of the timer reaches the preset duration or not;
and the circulation sub-module is used for acquiring the next single-frame image from the spliced image according to the acquisition time sequence of each single-frame image in the spliced image when the timing duration reaches the preset duration, and continuously drawing the next single-frame image in the canvas for playing the dynamic image.
For the specific definition of the moving image playing device, reference may be made to the above definition of the moving image playing method, which is not described herein again. The modules in the moving image playing device can be wholly or partially realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 10. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing data such as image sequences and stitched images. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a dynamic image playback method.
Those skilled in the art will appreciate that the architecture shown in fig. 10 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, there is provided a computer device comprising a memory storing a computer program and a processor implementing the following steps when the processor executes the computer program: acquiring an image sequence of a dynamic image to be played, wherein the image sequence comprises at least two single-frame images; splicing single-frame images in the image sequence to obtain corresponding spliced images; and sending the spliced images to the terminal, so that the terminal cuts out each single-frame image from the received spliced images, draws the single-frame images in the canvas according to the time sequence and plays the dynamic images.
In one embodiment, when the processor executes the computer program, the implementation of stitching a single frame image in an image sequence to obtain a corresponding stitched image may include: acquiring the number of image lines of a spliced image to be generated and the number of images of single-frame images in an image sequence, wherein the number of the image lines is the number of arrangement lines of the single-frame images in the spliced image to be generated; determining the number of image columns of the spliced image to be generated based on the number of image lines and the number of images; and splicing at least two single-frame images according to the number of image lines and the number of image columns and the acquisition time sequence of the single-frame images in the image sequence to generate a corresponding spliced image.
In one embodiment, when the processor executes the computer program, the method for generating a mosaic image by mosaicing at least two single-frame images according to the number of image lines and the number of image columns and the acquisition time sequence of the single-frame images in the image sequence may include: acquiring a preset line spacing and a preset column spacing of a spliced image to be generated; and splicing at least two single-frame images according to the line spacing, the column spacing, the image line number and the image column number and the acquisition time sequence of the single-frame images in the image sequence to obtain corresponding spliced images.
In one embodiment, another computer device is provided, comprising a memory storing a computer program and a processor implementing the following steps when the processor executes the computer program: receiving a spliced image sent by a server, wherein the spliced image is generated by splicing at least two single-frame images in an image sequence; initializing a canvas for playing the dynamic image; and sequentially cutting out each single-frame image from the spliced images, drawing the single-frame images in the canvas according to the time sequence, and playing the dynamic images.
In one embodiment, when executing the computer program, the processor sequentially cuts out the single-frame images from the stitched image, and draws the single-frame images in a canvas according to a time sequence for playing a dynamic image, which may include: acquiring each single-frame image from the spliced images according to the acquisition time sequence of each single-frame image in the spliced images; obtaining the size of a canvas; adjusting the size of the acquired image of each single frame image to the size of the canvas to obtain each single frame image after the image size is adjusted; and drawing each single-frame image after the image size is adjusted in a canvas, and playing the dynamic image.
In one embodiment, when executing the computer program, the processor sequentially cuts out the single-frame images from the stitched image, and draws the single-frame images in a canvas according to a time sequence for playing a dynamic image, which may include: initializing a counter, wherein the count value of the counter is equal to the current frame number of the played dynamic image; acquiring a first frame image from the spliced image and drawing the first frame image in a canvas; adding one to the count value of the counter; judging whether the count value of the counter is equal to a preset threshold value or not; and when the count value of the counter is not equal to the preset threshold value, acquiring the next single-frame image from the spliced image according to the acquisition time sequence of each single-frame image in the spliced image, continuously drawing in the canvas, and playing the dynamic image.
In one embodiment, when the processor executes the computer program, the following steps may be further implemented before acquiring a next single-frame image from the stitched image according to the acquisition time sequence of each single-frame image in the stitched image, and continuously drawing the next single-frame image in the canvas for playing the dynamic image: initializing a timer, and judging whether the timing duration of the timer reaches a preset duration or not; and when the timing duration reaches the preset duration, acquiring the next single-frame image from the spliced image according to the acquisition time sequence of each single-frame image in the spliced image, continuously drawing in the canvas, and playing the dynamic image.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of: acquiring an image sequence of a dynamic image to be played, wherein the image sequence comprises at least two single-frame images; splicing single-frame images in the image sequence to obtain corresponding spliced images; and sending the spliced images to the terminal, so that the terminal cuts out each single-frame image from the received spliced images, draws the single-frame images in the canvas according to the time sequence and plays the dynamic images.
In one embodiment, when executed by a processor, the computer program implements stitching of single-frame images in an image sequence to obtain a corresponding stitched image, and may include: acquiring the number of image lines of a spliced image to be generated and the number of images of single-frame images in an image sequence, wherein the number of the image lines is the number of arrangement lines of the single-frame images in the spliced image to be generated; determining the number of image columns of the spliced image to be generated based on the number of image lines and the number of images; and splicing at least two single-frame images according to the number of image lines and the number of image columns and the acquisition time sequence of the single-frame images in the image sequence to generate a corresponding spliced image.
In one embodiment, when executed by the processor, the implementation of the computer program to perform stitching on at least two single-frame images according to the acquisition time sequence of the single-frame images in the image sequence according to the number of image lines and the number of image columns to generate a corresponding stitched image may include: acquiring a preset line spacing and a preset column spacing of a spliced image to be generated; and splicing at least two single-frame images according to the line spacing, the column spacing, the image line number and the image column number and the acquisition time sequence of the single-frame images in the image sequence to obtain corresponding spliced images.
In one embodiment, another computer-readable storage medium is provided, having a computer program stored thereon, the computer program, when executed by a processor, implementing the steps of: receiving a spliced image sent by a server, wherein the spliced image is generated by splicing at least two single-frame images in an image sequence; initializing a canvas for playing the dynamic image; and sequentially cutting out each single-frame image from the spliced images, drawing the single-frame images in the canvas according to the time sequence, and playing the dynamic images.
In one embodiment, the computer program, when executed by the processor, implements sequentially cropping the single-frame images from the stitched image, and draws the single-frame images in a canvas according to a time sequence for playing a dynamic image, and may include: acquiring each single-frame image from the spliced images according to the acquisition time sequence of each single-frame image in the spliced images; obtaining the size of a canvas; adjusting the size of the acquired image of each single frame image to the size of the canvas to obtain each single frame image after the image size is adjusted; and drawing each single-frame image after the image size is adjusted in a canvas, and playing the dynamic image.
In one embodiment, the computer program, when executed by the processor, implements sequentially cropping the single-frame images from the stitched image, and draws the single-frame images in a canvas according to a time sequence for playing a dynamic image, and may include: initializing a counter, wherein the count value of the counter is equal to the current frame number of the played dynamic image; acquiring a first frame image from the spliced image and drawing the first frame image in a canvas; adding one to the count value of the counter; judging whether the count value of the counter is equal to a preset threshold value or not; and when the count value of the counter is not equal to the preset threshold value, acquiring the next single-frame image from the spliced image according to the acquisition time sequence of each single-frame image in the spliced image, continuously drawing in the canvas, and playing the dynamic image.
In one embodiment, when the computer program is executed by the processor, the following steps may be further implemented before the computer program acquires a next single-frame image from the stitched image according to the acquisition time sequence of each single-frame image in the stitched image, and continues to draw in the canvas for playing the dynamic image: initializing a timer, and judging whether the timing duration of the timer reaches a preset duration or not; and when the timing duration reaches the preset duration, acquiring the next single-frame image from the spliced image according to the acquisition time sequence of each single-frame image in the spliced image, continuously drawing in the canvas, and playing the dynamic image.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. 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 patent shall be subject to the appended claims.