Efficient parallel optical flow algorithm and GPU implementation

By using parallel architecture and OpenCL to accelerate the optical flow algorithm on mobile devices, the problem of large optical flow calculations is solved, and real-time optical flow processing and video frame rate improvement on mobile devices are achieved.

CN112041887BActive Publication Date: 2024-09-03SNAP INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201980027763.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2018-04-24
Filing Date
2019-04-23
Publication Date
2024-09-03
Estimated Expiration
2039-04-23

AI Technical Summary

Technical Problem

Typical optical flow algorithms have a large amount of calculations, making it difficult to achieve real-time processing on mobile devices. Especially on mid- to low-end devices, the frame rate per second is low, making it difficult to perform other processing.

Method used

Adopting the parallel architecture of modern mobile processors, utilizing SLAM instructions on the CPU and using OpenCL on the GPU to accelerate the DIS-OF algorithm, optimizing optical flow calculations by distributing the workload to the CPU and GPU, combining optical flow and segmentation algorithms to reduce calculations quantity.

Benefits of technology

It realizes real-time optical flow calculation on mobile devices, improves processing speed, enables near-real-time video processing on mid- to low-end devices, and improves frame rate and overall image/video processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112041887B_ABST
    Figure CN112041887B_ABST
Patent Text Reader

Abstract

Systems and methods are provided for initiating transmission of image data corresponding to at least one predetermined level of an image pyramid including a higher resolution to a graphics processing unit (GPU) of a computing device, computing, by a central processing unit (CPU) of a computer, an optical flow of at least one predetermined coarse level of the image pyramid, transmitting, by the CPU of the computing device, the computed optical flow of at least one predetermined coarse level of the image pyramid to the GPU, computing, by the GPU of the computing device, the optical flow of at least one predetermined level of the image pyramid including a higher resolution, and outputting, by the GPU of the computing device, the optical flow of the image data.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] priority

[0002] This application claims the benefit of priority to U.S. Provisional Patent Application Serial No. 62 / 661,958, filed on April 24, 2018, the benefit of which is hereby claimed and the entire contents of which are incorporated herein by reference. Background Art

[0003] Optical flow is an important computer vision algorithm used for object detection and tracking, motion estimation, visual odometry, etc. However, typical optical flow algorithms are computationally intensive and require a lot of computing resources and time. This prevents optical flow algorithms from being used and deployed on certain devices (e.g., mobile devices). BRIEF DESCRIPTION OF THE DRAWINGS

[0004] The various figures in the drawings depict only example embodiments of the present disclosure and should not be considered limiting of its scope.

[0005] Figure 1 is a block diagram illustrating a workflow of an image processing system according to some example embodiments.

[0006] Figure 2 An example mobile device is shown in accordance with some example embodiments.

[0007] Figure 3 An image pyramid is shown according to some example embodiments.

[0008] Figure 4 is a flow chart illustrating aspects of a method according to some example embodiments.

[0009] Figure 5 A timing diagram for task separation between a CPU and a GPU is shown according to some example embodiments.

[0010] Figure 6 is a flow chart illustrating aspects of a method according to some example embodiments.

[0011] Figure 7 An example task separation between the CPU and the GPU in an image pyramid is shown according to some example embodiments.

[0012] Figure 8 The workflow of optical flow computation on a CPU according to some example embodiments is shown.

[0013] Fig. 9 A workflow of optical flow computation on a GPU according to some example embodiments is shown.

[0014] Fig.10is a block diagram illustrating an example messaging system for exchanging data (eg, messages and related content) over a network, according to some example embodiments.

[0015] Fig.11 is a block diagram showing more details regarding a messaging system according to some example embodiments.

[0016] Fig.12 is a schematic diagram illustrating data that may be stored in a database of a messaging server system according to some example embodiments.

[0017] Fig.13 is a schematic diagram illustrating the structure of a message generated by a messaging client application for communication according to some embodiments.

[0018] Fig.14 is a block diagram illustrating an example of a software architecture that may be installed on a machine according to some example embodiments.

[0019] Fig.15 A diagrammatic representation of a machine in the form of a computer system according to an example embodiment is shown within which a set of instructions may be executed, causing the machine to perform any one or more of the methodologies discussed herein. DETAILED DESCRIPTION

[0020] The systems and methods described herein use the parallel architecture of modern mobile processors and use SLAM (simultaneous localization and mapping) instructions on a mobile central processing unit (CPU) and OpenCL on a mobile graphics processing unit (GPU) to accelerate the DIS (Dense Inverse Search) based optical flow (DIS-OF) algorithm. By exploiting the parallelism of the algorithm, the example embodiments optimize the DIS-OF algorithm to increase processing speed. By further exploiting the heterogeneous architecture of modern mobile processors, the example embodiments divide the workload and distribute them to both the CPU and GPU. In the example embodiments, the optimization enables real-time optical flow calculations on mobile devices and can be applied to a wide range of mobile use cases such as mobile augmented reality, video segmentation, object tracking, etc.

[0021] Optical flow has many applications in computer vision, from face tracking to SLAM (Simultaneous Localization and Mapping). Asynchronous segmentation is one such application of optical flow. Segmentation systems use DNNs (Deep Neural Networks) to generate segmentation masks. Due to computational complexity, the runtime performance of DNNs on mid-end and low-end mobile devices is very low. Due to the low performance, it is difficult to achieve real-time segmentation on video streams. Asynchronous segmentation systems solve this problem by running DNN segmentation in a background thread and using optical flow to generate interpolated segmentation masks.

[0022] In one example, a mobile device includes at least one camera for capturing images (e.g., photos) and videos via the mobile device. The mobile device may further include a camera-based application to provide functionality for applying creative tools (e.g., special effects, media overlays, etc.) to images or videos. For example, the creative tools may provide functionality for adding special effects, media overlays, etc. to an entire image or video or to a specific object (e.g., a face, a car, a tree, a sky, a body, a cat, etc.) in an image or video stream.

[0023] In one example, a camera-based application may use segmentation to identify objects (e.g., to which a creative tool is to be applied). One problem with segmentation is that it takes a lot of time. Therefore, in camera-based applications, especially on computing devices such as mobile devices, it is difficult to maintain a high frame rate per second if a segmentation algorithm is used. Therefore, some example embodiments apply segmentation on key frames, and apply optical flow between key frames to track previously generated masks, thereby reducing the computation required for segmentation. For example, the key frames can be determined by a frame processing scheduler or by the availability of a segmentation engine (whenever the segmentation engine has completed processing the last key frame, the example embodiments start processing a new frame), and then the optical flow will be applied to the frames between the determined key frames. One reason for using an optical flow algorithm is that it is relatively less computationally intensive than segmentation. In this way, optical flow is used to track the motion of an object in a video by comparing the object with its previous objects (e.g., from one frame to the next) and determining in which direction the object has moved, how much it has moved, etc. By replacing segmentation for each frame, using optical flow can reduce computation and can achieve real-time (or near real-time) processing on most mobile devices (e.g., including low-end or mid-end mobile phones). exist Figure 1 Such a system using optical flow and segmentation is shown in example system 100 of FIG.

[0024] Although optical flow is simpler and less computationally intensive than segmentation, optical flow still takes a relatively long time. For example, on a low- to mid-end mobile device, it may take 15 to 20 milliseconds. Therefore, in order to achieve a frame rate of 30 frames per second, for example, each frame should not take less than 33 milliseconds to complete any other processing. If optical flow takes 20 milliseconds, there is not enough room for other processing, such as post-processing or rendering. Therefore, although optical flow improves computational overhead, there is still a question of how much time it takes in total. Example embodiments also provide for increasing the speed of optical flow by using a combination of the CPU and GPU of a computing device to accelerate the algorithm. As further described herein, this speeds up the overall processing of images / videos.

[0025] Figure 11 is a block diagram illustrating a workflow of a system 100 using segmentation and optical flow according to some example embodiments. The system 100 includes a data store 102 that includes one or more image frames (e.g., image frames of a video stream). For example, the image frames may be part of a video stream captured by a camera in a computing device such as a mobile phone. In one example, the image frames may be stored in the data store 102 as the video is captured. The system 100 also includes a segmentation (DNN) 108 applied to key frames of the image frames 102 as described above. The segmentation 108 may output one or more masks associated with one or more objects (e.g., a mask identifying each object) to a mask storage device 110.

[0026] The system 100 includes an optical flow 104 as described above for interpolation between key frames. The interpolation mask generation performed by the optical flow 104 and the mask generated by the segmentation 108 and stored in the mask storage device 110 are input to the interpolation mask generation 106. Then, in one example, optional post-processing can be applied to the image frame 102, such as, for example, a guided filter 112 (for example, to enhance or improve the quality of the mask) and an effect or rendering 114 (for example, to apply special effects or other creative tools to one or more objects in the video). The final frame can then be output to a display of a computing device. Example embodiments optimize the optical flow 104 of the system 100.

[0027] You can use Figure 2 The computing device of the illustrated example mobile device 200 implements aspects of the system 100. The mobile device is a portable computing device, such as a smartphone, a tablet computer, a personal digital assistant (PDA), etc. The mobile device 200 may include one or more processors 202. The one or more processors 202 may be any of a variety of different types of commercial processors 202 suitable for mobile devices (e.g., an XScale architecture microprocessor, a microprocessor without interlocked pipeline stages (MIPS) architecture processor, or other types of processors). In an example embodiment, the mobile device 200 may include a CPU 220 and a GPU 222. As explained in further detail below, the example embodiments may be implemented using the CPU 220 of the mobile device 200, the GPU 222 of the mobile device 200, or a combination of the CPU 220 and the GPU 222.

[0028] The one or more processors 202 may generally access a memory 204, such as a random access memory (RAM), flash memory, or other type of memory. The memory 204 may be adapted to store an operating system (OS) 206 and applications 208, such as camera-based applications or image processing applications that may provide image effects on images (e.g., photos) or videos. The mobile device 200 may further include and / or may be coupled to one or more camera devices (not shown).

[0029] The one or more processors 202 may be coupled to a display 210 and one or more input / output (I / O) devices 212, such as a keypad, a touch panel sensor, a microphone, etc., either directly or via appropriate intermediate hardware. Similarly, in some embodiments, the one or more processors 202 may be coupled to a transceiver 214 that interfaces with an antenna 216. The transceiver 214 may be configured to both transmit and receive cellular network signals, wireless data signals, or other types of signals via the antenna 216, depending on the nature of the mobile device 200. Additionally, in some configurations, a GPS receiver 218 may also utilize the antenna 216 to receive GPS signals.

[0030] Optical flow assumes that the brightness of a moving object remains constant between two frames. The optical flow equation has two unknowns (e.g., optical flow in the X and Y directions), so it does not have a unique solution from one equation. Patch-based optical flow assumes that the optical flow of all pixels in a patch is the same, so it derives multiple optical flow equations to find the two unknowns. In one example, an image (e.g., a frame of a video) may be divided into multiple blocks, each block including a predetermined number of pixels. An optical flow calculation will be performed on each block to determine the direction of motion and the distance of motion. For example, if the block size is 8×8 pixels, the image may be divided into 8×8 blocks.

[0031] Optical flow calculations are performed on all levels of the image pyramid. For example, an image pyramid can be generated for an image that includes multiple layers of image data that are subsampled at multiple resolutions for each level. The optical flow calculations start at the highest level of the image pyramid (the coarsest level - with the smallest image resolution). At the coarsest level, the optical flow calculations start with some initial optical flow. The initial optical flow can be a zero motion vector or a motion vector from which the optical flow of the previous frame started.

[0032] exist Figure 3 An example image pyramid 300 is shown in FIG. Figure 3The image pyramid 300 in FIG. 3 is shown as including four levels. For example, the first level 302 may be the original image with the largest image resolution, the second level 304 includes a smaller image resolution, the third level 306 includes an even smaller image resolution, and the fourth level 308 includes the smallest or coarsest image resolution. Thus, each level may be a coarser version of the previous level of the image. Although Figure 3 The image pyramid 300 in FIG. 5 is shown as including four levels, but it is understood that the image pyramid may have any number of levels.

[0033] Once the optical flow at the coarsest level is known, this optical flow is upsampled at the next level, which is used to find the optical flow at the next level. This process is repeated until the optical flow at the last level is reached.

[0034] Figure 4 4 is a flow chart illustrating aspects of a method 400 for an optical flow algorithm at each level of an image pyramid according to some example embodiments. In operation 402, a computing device (e.g., Figure 2 The computing device 200 calculates the source image gradient (I) in the X and Y directions for each pixel. x , I y ), where I is an image. In operation 404, the computing device divides a source image (e.g., an image frame of a video) into a grid of blocks based on a predetermined block size and a block stride. For example, the predetermined block size may be 8 pixels, and the predetermined block stride (e.g., the starting point between two blocks) may be 4 pixels. In this example, the image would be divided into 8×8 blocks, and the blocks would start at every 4 pixels in X and Y (e.g., the blocks would overlap).

[0035] In operation 406, the computing device calculates the sum of the gradients of each block. For example, the computing device calculates the sum of the following gradients of each block:

[0036] a.∑Ix 2 : I on the block pixel x 2 sum

[0037] b.∑Iy 2 : I on the block pixel y 2 sum

[0038] c.∑Ixy: I on the block pixel x and I y The sum of the products of

[0039] d.∑Ix: I on the block pixels x sum

[0040] e.∑Iy: I on the block pixel y sum

[0041] In operation 408, the computing device calculates the inverse of the Hessian matrix (H): H = [∑Ix 2 ∑Ixy; ∑Ixy ∑Iy 2 ].

[0042] In operation 410, the computing device sets an initial flow field. For example, depending on the cost of zero motion and the cost of using the optical flow of the previous frame, the computing device sets the initial flow field for the coarsest level of the image pyramid (e.g., Figure 3 The initial flow field is set for level 0 (308) of the image pyramid 300 in FIG. 4. For other levels of the image pyramid, the initial flow is set by the previous level.

[0043] In operation 412, the computing device performs an iterative inverse block search. For example, the computing device performs an iterative inverse block search based on an inverse composition for each block to find incremental optical flow (e.g., incremental motion vectors) in X and Y. The method includes:

[0044] a. Determine the pixel difference between two different frames (e.g., previous (source) frame and current (destination) frame) for any block. Pixel difference = destination image pixel - source image pixel. Calculate the destination image pixel using bilinear interpolation at X and Y.

[0045] i. The target image pixels use X and Y sampling

[0046] b. Use pixel differences to calculate the difference in X and Y motion vectors. [△x; △y] = H -1 *∑([Ix;Iy]*(pixel difference))

[0047] c. Update X and Y. [X, Y]:=[X, Y]-[△x, △y].

[0048] d. If the pixel cost (e.g., ZSSD) is less than a predetermined threshold, the iterative process stops. Otherwise, continue by returning to step a.

[0049] After operation 412, the computing device will know the direction in which the block moved from the previous frame to the current frame (block flow). The block flow can be in the form of motion vectors. In operation 414, the computing device performs densification to use the block flow to calculate the pixel-wise flow field (e.g., find the flow for each pixel). To do this, the computing device uses the following equation to find the dense flow at each pixel if the corresponding block overlaps the pixel and d i (x) is the destination image in (x+u i ) and the pixel at (x) in the source image, then λi,x is 1.

[0050]

[0051]

[0052] The output of operation 412 is a motion vector with X, Y for each pixel.

[0053] Figure 5-7 Methods for efficiently implementing optical flow using both the CPU and GPU of a computing device are shown. A first efficient implementation includes neon SIMD (single instruction multiple data) optimization. As mentioned above, optical flow is a very computationally intensive algorithm. Block-wise optical flow performs many similar calculations for a row of pixels, and therefore, it is an ideal candidate for SIMD. During the block inverse search of optical flow (e.g., Figure 4 Operation 412 in ), the cost of the block matching needs to be calculated for each step of the iteration. This cost function can be SSD (sum of squared differences), ZSSD (zero mean SSD), NCC (normalized cross correlation) or other cost functions. The calculation cost can be efficiently implemented on SIMD. In an example embodiment, ZSSD is implemented on SIMD (e.g., step d of operation 412). For example, for each row of pixels, a chunk of 4 pixels is processed in a set of SIMD instructions. In this way, the calculation of the 4 pixels of the block can occur in parallel, and thus step d of operation 412 is optimized.

[0054] In the dense optical flow calculation based on the block-by-block optical flow (e.g., Figure 4 During operation 414 of FIG. 4 , the pixel difference cost using the adjacent optical flow outputs needs to be evaluated. This calculation requires bilinear interpolation using the fractional portion of the motion vector to generate the interpolated pixels in the next frame. This process can be efficiently implemented in SIMD by generating four bilinear interpolated pixels at a time. Therefore, operation 414 is optimized.

[0055] The second efficient implementation includes GPU implementation. First, for any algorithm to be run on a GPU, it should have a sufficiently parallel workload to effectively utilize GPU hardware resources. Block-based optical flow (e.g., Figure 4Operation 412) has a serial dependency between blocks, and due to this serial dependency, the block inverse search for each block needs to be calculated one by one in raster scan order. Example embodiments break this serial dependency while maintaining similar quality of optical flow (e.g., average endpoint error). For GPU implementations, the block inverse search for each block is performed independently, and then there is a synchronization phase that checks the optical flow output of adjacent blocks. After synchronization, if the adjacent optical flow produces a better quality (ZSSD) optical flow, the adjacent optical flow can be used to update the optical flow result of the block. After synchronization, the block inverse search is performed again for further convergence. In this way, the iterative convergence and synchronization phases are iterated multiple times to achieve better quality optical flow.

[0056] Second, another problem faced during the efficient parallel implementation of optical flow is that the coarsest level of the pyramid has a smaller image resolution, so it does not have enough workload to be processed on the GPU. Computing optical flow for small image resolutions on the GPU side incurs the overhead of scheduling tasks, and therefore does not perform well in terms of computational efficiency. Example embodiments process the coarse levels (such as Figure 8 ), processing large image levels on the GPU side (as shown Fig. 9 shown).

[0057] In one example, the computing device may determine which levels (e.g., coarse levels) will be processed on the CPU side and which levels will be processed on the GPU side based on the computing device capabilities. This may vary between computing devices. For example, the computing device may perform an adjustment step to select the level in the image pyramid that the GPU will start taking over from. This adjustment step may be a one-time cost (e.g., when constructing the object). In another example, the level to be processed on the CPU may be predetermined based on certain parameters (e.g., computing device capabilities) or based on a default predetermined level to be processed on the CPU.

[0058] In addition, memory transfers to the GPU can be done in parallel while performing coarse-level processing. This will hide the memory transfer cost and enable CPU-GPU sharing. Figure 5 The timing diagram 500 shows that Figure 5 In , memory transfers to the GPU starting level occur in parallel with the optical flow computation on the coarse level.

[0059] Third, after completing the optical flow calculation at any level of the image pyramid, the optical flow matrix needs to be upsampled to produce an initial optical flow of a larger resolution for the next level, which provides a starting point for convergence for the next level. This upsampling operation will require reading the optical flow matrix of the small resolution, performing bilinear interpolation, and then storing (writing) it into the larger resolution matrix. This entire operation can be avoided by utilizing the GPU's memory read operation, which supports bilinear interpolation on the fly without affecting performance. Therefore, the example embodiment reads the optical flow of the previous pyramid level by downsampling the position (x, y), and uses dynamic bilinear interpolation to read the optical flow results from the previous level.

[0060] Figure 6 6 is a flow chart illustrating aspects of a method 600 for processing image data using an optical flow algorithm that utilizes both a CPU and a GPU according to some example embodiments. Figure 2 The computing device of the mobile device 200 may include (or be coupled to) one or more cameras that allow for the capture of images (e.g., photos) and / or videos. In one example, the computing device receives image data from the camera, the image data including images or videos captured by the camera. The computing device may store the image data in one or more data stores (e.g., data store 102). The computing device performs image processing on the image data, such as Figure 1 The image processing shown includes Figure 4 As described above, example embodiments provide optimization of the optical flow process by using both the CPU and the GPU of a computing device.

[0061] In one example, for a video captured by a camera of a computing device, the image data may include one or more frames of a video stream. After receiving the image data from one or more cameras, the computing device generates an image pyramid that includes multiple levels of images in the image data (e.g., frames of a video), and for each level, the image data is subsampled at multiple resolutions. An example image pyramid 300 is shown in Figure 3 Another example image pyramid 700 is shown in Figure 7 middle.

[0062] Figure 7 The image pyramid of FIG. 700 shows four levels. The first level 702 may include the original image of the highest resolution (e.g., a frame of a video), the second level 704 may be an image with a smaller resolution, the third level 706 may be an image with a still smaller image resolution, and the fourth level 708 may be an image with the smallest or coarsest image resolution. Thus, each level may be a coarser version of the previous level of the image. Although in Figure 7 The image pyramid 700 in is shown as including four levels, but it should be understood that the image pyramid may have any number of layers. In one example, as previously explained, one or more coarser levels may be designated as being processed by the CPU, while one or more higher resolution levels may be designated as being processed by the GPU. In this example, the first level 702 and the second level 704 may include a higher resolution and are therefore designated as being processed by the GPU, and the third level 706 and the fourth level 708 may include a coarser resolution and are therefore designated as being processed by the CPU. In other examples, different levels may be designated as being processed by the CPU and the GPU.

[0063] return Figure 6 In operation 602, a computing device (e.g., Figure 2 The computing device 200 of the GPU initiates the memory transfer of the GPU-starting level. For example, if the image pyramid includes a first level and a second level of higher resolution that are designated to be processed by the GPU (e.g., Figure 7 The first level 702 and the second level 704 of the image pyramid are transmitted to the GPU. Therefore, the image data corresponding to at least one predetermined level of the image pyramid including a higher resolution is transmitted to the GPU of the computing device.

[0064] As shown in operation 604 , during initialization and transmission of image data to the GPU, the CPU of the computing device calculates optical flow of at least one predetermined coarse level of the image pyramid. Figure 5 shows how CPU processing is done during GPU memory transfers. The CPU can use Figure 4 The process shown and described above is used to compute the optical flow of at least one predetermined coarse level of the image pyramid.

[0065] Figure 8 Optical flow computation at the CPU is shown (e.g., neon (SIMD) optimization for coarse level computation as described above). Figure 4 As further explained in detail, the computing device preprocesses the image gradients 820 in operation 802 (e.g., the sum of the gradients in operation 406 and Figure 4 ), performing block-by-block optical flow in operation 804 (e.g., Figure 4 412), and then in operation 806 (e.g., Figure 4 In operation 414 of ), dense optical flow is performed according to the block-by-block optical flow. In one example, the optical flow calculation for the coarse level is performed serially by the CPU.

[0066] return Figure 6After the CPU calculates the optical flow of at least one predetermined coarse level of the image pyramid, the CPU of the computing device transmits the output (e.g., the calculated optical flow of at least one predetermined coarse level of the image pyramid) to the GPU, as shown in operation 606. For example, the CPU of the computing device transmits the optical flow for the level before the level that the GPU will start using. Figure 5 This process is also shown in the timing diagram 500 of FIG.

[0067] In operation 608, the GPU of the computing device uses the optical flow calculated by the CPU to calculate at least one predetermined level (eg, Figure 7 For example, once the last level of the CPU results are transferred to the GPU, an initial flow field is set for the first level of the GPU. The GPU will upsample this initial flow field using dynamic bilinear interpolation and start optical flow calculations at that level.

[0068] Fig. 9 shows the optical flow calculation at the GPU. Fig. 9 The process in is similar to that in Figure 8 The process for the CPU in 902 (e.g., preprocessing image gradients 922 in operation 902, performing block-wise optical flow in operation 904, and performing dense light based on the block optical flow in operation 908) is described above, except that the GPU is receiving a coarser level of optical flow from the CPU, and because the GPU performs the block-wise optical flow in parallel, it also includes a synchronization stage (e.g., neighbor synchronization 906). For a given block of a plurality of blocks in a layer of an image pyramid, the neighbor synchronization 906 includes determining all neighboring blocks of the given block. Neighboring blocks are blocks that are near the given block or blocks that are immediately adjacent to the given block. For example, blocks above the given block, blocks to the right of the given block, blocks to the left of the given block, and blocks below the given block. Depending on the position of the given block, the given block may not have blocks to the right, left, below, and above, but may only have a subset of these neighboring blocks.

[0069] Next, the computing device determines each neighboring block motion vector value. The motion vector value may include an (X, Y) value, such as (4.5, -5.5). The computing device compares each neighboring block motion vector value with the motion vector value of the given block. If the cost of any neighboring block motion vector (e.g., a value given by a cost function, such as ZSSD) is lower than the cost of using the motion vector of the given block, the motion vector of the given block is updated using the motion vector of the neighboring block. The lower the cost, the higher the probability that two blocks from two frames are the same block. In one example, the given block is updated with the neighboring block motion vector value with the lowest cost.

[0070] The GPU may output an optical flow of image data. The output of the GPU is the optical flow of an image (e.g., a frame of a video stream). The optical flow indicates how each pixel moves in the X direction and by how much, and how it moves in the Y direction and by how much. This is then used for further processing of the image (e.g., determining where to place a creative tool based on where the object to which the creative tool will be applied has moved / will move in the next frame). In this way, the computing device can generate a new mask by warping the old mask using the optical flow motion vector values.

[0071] The example embodiments described herein have been tested for performance by the inventors. The following table shows a performance comparison between a CPU-only implementation and an example embodiment. The performance data was generated on a Samsung Galaxy S7 device. For performance measurement, the optical flow was run approximately 100 times between two image frames, and the average performance is reported here. As shown in the results, it achieves approximately a 4x speedup.

[0072] Version Execution time for 180×320 image (milliseconds) CPU only 97 ms CPU only (with SIMD) 75 ms CPU+GPU 18 ms

[0073] Example embodiments may be used in a variety of use cases. For example, example embodiments may be used in a camera application to apply creative tools such as special effects and media overlays to a photo or video. In another example, example embodiments may be used in a messaging system or application to apply creative tools to a photo or video that is to be shared with one or more users via a messaging system. For example, a photo or video with creative tools may be sent as a message to one or more users, added to a media collection, etc.

[0074] Fig.10 1 is a block diagram illustrating a network system 1000 (e.g., a messaging system) for exchanging data (e.g., messages and associated content) over a network. The network system 1000 includes a plurality of client devices 1010, each of which hosts a plurality of client applications 1014. Each client application 1014 is communicatively coupled to other instances of the client application 1014 and a server system 1008 via a network 1004.

[0075] The client device 1010 may include, but is not limited to, a mobile phone, a desktop computer, a laptop computer, a personal digital assistant (PDA), a smart phone, a tablet computer, an ultrabook, a netbook, a notebook computer, a multiprocessor system, a microprocessor-based or programmable consumer electronic system, a game console, a set-top box, a vehicle-mounted computer, a wearable device, or any other communication device that a user can use to access the network system 1000. In some embodiments, the client device 1010 may include a display module (not shown) that displays information (e.g., in the form of a user interface). In further embodiments, the client device 1010 may include one or more of a touch screen, an accelerometer, a gyroscope, a camera, a microphone, a global positioning system (GPS) device, etc. In some embodiments, the client device 1010 is Figure 2 A mobile device 200 is provided.

[0076] The client device 1010 may be a device of a user for creating media content items such as videos, images (e.g., photos), and audio, and for sending and receiving messages containing such media content items, text, etc. to and from other users. The client device 1010 may be a device of a user for creating and editing media overlays and accessing multiple media collections. The client device 1010 may be a device of a user for applying a background blur effect to a photo or video as described above.

[0077] The one or more users may be people, machines, or other devices that interface with the client device 1010. In an example embodiment, a user may not be part of the system 1000, but may interface with the system 1000 via the client device 1010 or other device. For example, a user may provide input (e.g., touch screen input or alphanumeric input) to the client device 1010, and the input may be communicated to other entities in the system 1000 (e.g., third-party servers, server system 1080, etc.) via the network 1040. In this example, in response to receiving input from the user, the other entities in the system 1000 may communicate information to the client device 1010 via the network 1004 for presentation to the user. In this manner, a user may interface with multiple entities in the system 1000 using the client device 1010.

[0078] The system 1000 may also include a network 1004. One or more portions of the network 1004 may be an ad hoc network, an intranet, an extranet, a virtual private network (VPN), a local area network (LAN), a wireless LAN (WLAN), a wide area network (WAN), a wireless wide area network (WWAN), a metropolitan area network (MAN), a portion of the Internet, a portion of the public switched telephone network (PSTN), a cellular telephone network, a wireless network, a WI-FI network, a WiMax network, another type of network, or a combination of two or more such networks.

[0079] The client device 1010 can access the web client (e.g., a browser) via a web client such as the Internet developed by the company The client device 1010 may include one or more client applications 1014 (also referred to as "apps"), such as, but not limited to, a web browser, a messaging application, an electronic mail (email) application, an e-commerce website application, a mapping or positioning application, a media overlay application, an interactive messaging application, an application that applies a blur effect to an image, and the like.

[0080] In some embodiments, one or more client applications 1014 may be included in a given one of the client devices 1010 and configured to locally provide at least some of the user interface and functionality, wherein the client applications 1014 are configured to communicate with other entities in the system 1000 (e.g., third-party servers, server system 1008, etc.) on an on-demand basis for data and / or processing capabilities that are not available locally (e.g., to process user queries, authenticate users, verify payment methods, etc.). Conversely, one or more client applications 1014 may not be included in the client device 1010, and the client device 1010 may then use its web browser to access one or more applications hosted on other entities in the system 1000 (e.g., third-party servers, server system 1008, etc.).

[0081] In one example, client application 1014 can be a messaging application that allows a user to take a photo or video, add a caption or otherwise edit the photo or video, and then send the photo or video (e.g., applying a background blur effect in some embodiments) to another user. In one example, the message can be ephemeral and removed from the receiving user device after viewing or after a predetermined amount of time (e.g., 10 seconds, 24 hours, etc.). A transient message refers to a message that is accessible for a time-limited duration. A transient message can be text, images, videos, and other such content that can be merged together according to the embodiments described herein. The access time of a transient message can be set by the message sender. Alternatively, the access time can be a default setting or a setting specified by the recipient. Regardless of the setting technology, the message is transient.

[0082] The messaging application may also allow users to create galleries or collections of messages (also referred to herein as "media collections"). A gallery may be a collection of photos and videos viewed by other users who are "following" the user's gallery (e.g., subscribing to view and receive updates in the user's gallery). In one example, a gallery may also be ephemeral (e.g., lasting 24 hours, for the duration of an event (e.g., during a concert, sporting event, etc.), or for another predetermined time).

[0083] Transient messages may be associated with a message duration parameter, the value of which determines the amount of time that the transient message will be displayed to the recipient user of the transient message by the client application 1014. Transient messages may also be associated with a message recipient identifier and a message timer. The message timer may be responsible for determining the amount of time that the transient message is displayed to a specific recipient user identified by the message recipient identifier. For example, a transient message may only be displayed to the associated recipient user during a time period determined by the value of the message duration parameter.

[0084] In another example, a messaging application may allow a user to store photos and videos and create a gallery that is not ephemeral and can be sent to other users. For example, a user may assemble photos and videos from a recent vacation to share with friends and family.

[0085] The server system 1008 may provide server-side functionality to one or more client devices 1010 and / or one or more third-party servers (not shown) via a network 1004 (e.g., the Internet or a wide area network (WAN)). The server system 1008 may include an application programming interface (API) server 1002, an application server 1012, a messaging application server 1016, a media content processing system 1018, and a social networking system 1022, which may each be communicatively coupled to each other and to one or more data storage devices (such as, database 1020).

[0086] According to some example embodiments, server system 1008 may be a cloud computing environment. In one example embodiment, server system 1008, and any servers associated with server system 1008, may be associated with a cloud-based application.

[0087] The one or more databases 1020 may be storage devices that store information such as: unprocessed media content, original media content from a user (e.g., high-quality media content), processed media content (e.g., media content formatted to be shared with and viewed on a client device 1010), contextual data related to media content items, contextual data related to a user device (e.g., a computing or client device 1010), media overlays, media overlay smart gadgets or smart elements, user data, user device information, media content (e.g., videos and images), media content data (e.g., data associated with videos and images), computing device contextual data, serialized data, session data items, etc. The one or more databases 1020 may also store information related to third-party servers, third-party applications, client devices 1010, client applications 1014, users, etc.

[0088] The one or more databases 1020 may include cloud-based storage devices external to the server system 1008 (e.g., hosted by one or more third-party entities external to the server system 1008). Although the storage device is illustrated as a database 1020, it should be understood that the system 1000 can access and store data in a storage device, such as a database 1020, a cloud storage device, and other types of storage methods.

[0089] The system 1000 may also include one or more third-party servers (not shown). The one or more third-party servers may include one or more third-party applications. The one or more third-party applications executed on the third-party servers may interact with the server system 1008 via the API server 1002 via a programming interface provided by the API server 1002. For example, one or more of the third-party applications may request and utilize information from the server system 1008 via the API server 1002 to support one or more features or functions on a website hosted by a third party or an application hosted by a third party. The third-party website or application may, for example, provide functionality supported by related functions and data in the server system 1008.

[0090] Thus, each client application 1014 can communicate and exchange data with other client applications 1014 and server systems 1008 via the network 1004. Data exchanged between client applications 1014 and data exchanged between client applications 1014 and server systems 1008 include functionality (e.g., commands to call functions) and payload data (e.g., text, audio, video, or other multimedia data).

[0091] The server system 1008 provides server-side functionality to certain client applications 1014 via the network 1004. Although certain functions of the system 1000 are described herein as being performed by the client application 1014 or by the server system 1008, it should be understood that the location of certain functions in the client application 1014 or the server system 1008 is a design choice. For example, it may be technically preferable to first deploy certain techniques and functions within the server system 1008 and then migrate the techniques and functions to the client application 1014 where the client device 1010 has sufficient processing power.

[0092] The server system 1008 supports a variety of services and operations provided to the client applications 1014. Such operations include sending data to the client applications 1014, receiving data from the client applications 1014, and processing data generated by the client applications 1014. As examples, the data may include message content, client device information, geo-location information, media annotations and overlays, message content persistence conditions, social network information, live event information, date and time stamps, media content (e.g., videos and images), media content data (e.g., data associated with videos and images), and user data (e.g., user click data). The data exchange in the networked system 1000 is invoked and controlled by functions available through the user interface (UI) of the client application 1014.

[0093] In server system 1008, API server 1002 is coupled to and provides a programming interface to application server 1012. Application server 1012 is communicatively coupled to database server 1024, which facilitates access to one or more databases 1020 in which data associated with messages processed by application server 1012 is stored.

[0094] The API server 1002 receives and sends message data (e.g., commands and message payloads) between the client device 1010 and the application server 1012. Specifically, the API server 1002 provides a set of interfaces (e.g., routines and protocols) that can be called or queried by the client application 1014 in order to call the functions of the application server 1012. The API server 1002 exposes various functions supported by the application server 1012, including: account registration; login functionality; sending messages from a particular client application 1014 to another client application 1014 via the application server 1012; sending media files (e.g., images or videos) from the client application 1014 to the messaging application server 1016 for possible access by another client application 1014; setting up a collection of media data (e.g., a gallery, story, message collection, or media collection); obtaining a friend list of a user of the client device 1010; obtaining such a collection; obtaining messages and content; adding and removing friends from a social graph; the position of friends in a social graph; opening an application event (e.g., related to the client application 1014); etc.

[0095] Application server 1012 hosts multiple applications and subsystems, including messaging application server 1016, media content processing system 1018, and social networking system 1022. Messaging application server 1016 implements multiple message processing technologies and functions, which particularly relate to the aggregation and other processing of content (e.g., text and multimedia content) included in messages received from multiple instances of client application 1014. Text and media content from multiple sources can be aggregated into collections of content (e.g., referred to as stories, galleries, or media collections). Messaging application server 1016 then makes these collections available to client application 1014. Given the hardware requirements of such processing, other processor and memory intensive processing of data can also be performed on the server side by messaging application server 1016.

[0096] Application server 1012 also includes a media content processing system 1018 that is dedicated to performing a variety of media content processing operations, typically with respect to images or videos received within the payload of a message at messaging application server 1016. Media content processing system 1018 may access one or more data storage devices (e.g., database 1020) to retrieve stored data for use in processing media content and to store the results of the processed media content.

[0097] The social networking system 1022 supports various social networking functions and services and makes these functions and services available to the messaging application server 1016. To this end, the social networking system 1022 maintains and accesses the entity graph 1204 ( Fig.12 Examples of functionality and services supported by the social networking system 1022 include identifying other users of the networking system 1000 with whom a particular user has a relationship or with whom the particular user is "following," as well as also identifying other entities and interests of a particular user.

[0098] The messaging application server 1016 may be responsible for generating and delivering messages between users of the client devices 1010. The messaging application server 1016 may utilize any of a number of messaging networks and platforms to deliver messages to users. For example, the messaging application server 1016 may deliver messages using electronic mail (email), instant messaging (IM), short message service (SMS), text, fax, or voice (e.g., voice over IP (VoIP)) messages via a wired network (e.g., the Internet), plain old telephone service (POTS), or a wireless network (e.g., mobile, cellular, WIFI, long term evolution (LTE), or Bluetooth).

[0099] Fig.11 1 is a block diagram 1100 showing more details about the networked system 1000 according to an example embodiment. Specifically, the system 1100 is shown to include a messaging client application 1014 and an application server 1012, which in turn embody multiple subsystems, namely, a transient timer system 1102, a collection management system 1104, and an annotation system 1106.

[0100] The transient timer system 1102 is responsible for enforcing temporary access to content permitted by the messaging client application 1014 and the messaging application server 1016. To this end, the transient timer system 1102 incorporates a plurality of timers that selectively display and enable access to messages and associated content via the messaging client application 1014 based on duration and display parameters associated with the message, or collection of messages (e.g., otherwise referred to herein as a media collection, gallery, message collection, story, etc.).

[0101] The collection management system 1104 is responsible for managing collections of media (e.g., collections of text, images, video, and audio data), otherwise referred to herein as "media collections." In some examples, collections of content (e.g., messages including images, videos, text, and audio) may be organized into "event galleries" or "event stories." Such collections may be available for a specified period of time (e.g., the duration of an event to which the content is related). For example, content related to a concert may be available as a "story" for the duration of the concert. The collection management system 1104 may also be responsible for publishing an icon that provides notification of the existence of a particular collection to the user interface of the messaging client application 1014.

[0102] The collection management system 1104 also includes a curation interface 1108 that allows a collection manager to manage and curate a particular collection of content. For example, the curation interface 1108 enables an event organizer to curate a collection of content related to a particular event (e.g., to remove inappropriate content or redundant messages). In addition, the collection management system 1104 uses machine vision (or image recognition technology) and content rules to automatically curate content collections. In some embodiments, compensation (e.g., currency, non-monetary credits or points associated with a messaging system or a third-party reward system, travel miles, access to artwork or special lenses, etc.) may be paid to a user for including user-generated content in a collection. In this case, the curation interface 1108 operates to automatically pay fees to such users for using their content.

[0103] The annotation system 1106 provides various functions that enable users to annotate or otherwise modify or edit media content associated with a message. For example, the annotation system 1106 provides functions related to generating and publishing media overlays for messages processed by the networking system 1000. In one example, the annotation system 1106 operably provides media overlays (e.g., filters or media enhancements) to the messaging client application 1014 based on the geographic location of the client device 1010. In another example, the annotation system 1106 operably provides media overlays to the messaging client application 1014 based on other information (e.g., social network information of the user of the client device 1010). Media overlays may include audio and visual content and visual effects. Examples of audio and visual content include images, text, logos, animations, and sound effects. Examples of visual effects include color overlays. Audio and visual content or visual effects may be applied to media content items (e.g., photos) at the client device 1010. For example, media overlays include text that may be superimposed on photos taken by the client device 1010. In another example, the media overlay includes an identification of a location overlay (e.g., Venice Beach), the name of a live event, or the name of a business overlay (e.g., Beach Cafe). In another example, the annotation system 1106 uses the geographic location of the client device 1010 to identify a media overlay that includes the name of a business at the geographic location of the client device 1010. The media overlay may include other tags associated with the business. The media overlay may be stored in the database 1020 and may be accessed by the database server 1024.

[0104] The annotation system 1106 may also enable users to interact with interactive messages, such as by adding one or more media content items to the interactive message as described in more detail below. In one example embodiment, the annotation system 1106 provides a publishing platform that allows users or businesses to create interactive messages with multiple objects associated with the interactive message to which users can add personal content. For example, a designer may create a video of a rock band with multiple interactive objects for different members of the band (drummer, keyboardist, guitarist, etc.). The video of the rock band may be available to users as an interactive message.

[0105] In one example embodiment, the annotation system 1106 provides a user-based publishing platform that enables users to select a geographic location on a map and upload content associated with the selected geographic location. Users can also specify under what circumstances specific media overlays should be provided to other users. The annotation system 1106 generates a media overlay including the uploaded content and associates the uploaded content with the selected geographic location.

[0106] In another example embodiment, the annotation system 1106 provides a merchant-based publishing platform that enables merchants to select specific media overlays associated with geographic locations through a bidding process. For example, the annotation system 1106 associates the media overlays of the merchant with the highest bid with the corresponding geographic location within a predetermined amount of time.

[0107] Fig.12 12 is a schematic diagram 1200 illustrating data that may be stored in a database 1020 of a server system 1008 according to certain example embodiments. Although the contents of the database 1020 are illustrated as including a plurality of tables, it should be understood that the data may be stored in other types of data structures (e.g., as an object-oriented database).

[0108] The database 1020 includes message data stored in a message table 1214. The entity table 1202 stores entity data including an entity graph 1204. The entities whose records are maintained within the entity table 1202 may include individuals, corporate entities, organizations, objects, places, events, etc. Regardless of the type, any entity about which the server system 1008 stores data may be a recognized entity. Each entity has a unique identifier and an entity type identifier (not shown).

[0109] The entity graph 1204 also stores information about relationships and associations between entities. Such relationships can be social, professional (e.g., working in the same company or organization), interest-based, or activity-based, just to name a few.

[0110] Database 1020 also stores annotation data in the form of examples of media overlays or filters in annotation table 1212. Annotation data may also be referred to herein as "creative tools" or "interactive features." Annotation data may include predefined interactive messages to be provided to the user.

[0111] The media overlay or filter for which data is stored in the annotation table 1212 is associated with a video (for which data is stored in the video table 1210) and / or an image (for which data is stored in the image table 1208) and is applied to the video and / or image. In one example, a filter is an overlay that is displayed as an overlay on an image or video during presentation to a recipient user. The filter can be of various types, including a user-selected filter from a filter library presented to a sender user by the messaging client application 1014 when the sender user is composing a message. Other types of filters include geographic location filters (also known as geo-filters) that can be presented to the sender user based on geographic location. For example, based on geographic location information determined by a GPS unit of the client device 1010, the messaging client application 1014 can present a geographic location filter specific to an adjacent or specific location within the user interface. Another type of filter is a data filter, which can be selectively presented to the sender user by the messaging client application 1014 based on other inputs or information collected by the client device 1010 during the message creation process. Examples of data filters include the current temperature at a particular location, the current speed at which the sending user is traveling, the battery life of the client device 1010, or the current time.

[0112] Other annotation data that may be stored in the annotation table 1212 is so-called "shot" data. A "shot" may be real-time special effects and sounds that may be added to an image or video.

[0113] As described above, the video table 1210 stores video data, which in one embodiment is associated with a message for which the video data is recorded and maintained in the message table 1214. Similarly, the image table 1208 stores image data associated with a message for which message data is stored in the message table 1214. The entity table 1202 may associate a plurality of annotations from the annotation table 1212 with a plurality of images and videos stored in the image table 1208 and the video table 1210.

[0114] The story table 1206 stores data related to a collection of messages and associated images, video, or audio data that are compiled into a collection (e.g., a story, gallery, or media collection). The creation of a particular collection can be initiated by a particular user (e.g., any user for whom a record is maintained in the entity table 1202). A user can create a "personal story" in the form of a collection of content that the user has created and sent / broadcast. To this end, the user interface of the messaging client application 1014 may include a user-selectable icon to enable the sending user to add specific content to his or her personal story.

[0115] A collection of media or messages may also constitute a "live story," which is a collection of content from multiple users that is created manually, automatically, or using a combination of manual and automatic techniques. For example, a "live story" may consist of a curated stream of user-submitted content from various locations and events. For example, a user whose client device 1010 has location services enabled and who is at a common event location at a particular time may be presented with an option via the user interface of the messaging client application 1014 to contribute content to a particular live story. The live story may be identified to the user by the messaging client application 1014 based on his or her location. The end result is a "live story" told from the perspective of the community.

[0116] Another type of content collection is called a "location story," which enables users whose client devices 1010 are located within a particular geographic location (e.g., on a college or university campus) to contribute to a particular collection. In some embodiments, contributions to location stories may require secondary authentication to verify that the end user belongs to a particular organization or other entity (e.g., is a student on a university campus).

[0117] Fig.13 1 is a schematic diagram illustrating the structure of a message 1300 generated by a client application 1014 for communication with another client application 1014 or a messaging application server 1016 according to some embodiments. The content of a particular message 1300 is used to populate a message table 1214 stored in a database 1020 accessible to the messaging application server 1016. Similarly, the content of the message 1300 is stored in memory as "in-transit" or "in-flight" data of the client device 1010 or the application server 1012. The message 1300 is shown as including the following components:

[0118] Message identifier 1302 : A unique identifier that identifies the message 1300 .

[0119] Message text payload 1304 : The text to be generated by the user through the user interface of the client device 1010 and included in the message 1300 .

[0120] Message image payload 1306 : Image data captured by a camera component of the client device 1010 or retrieved from the memory of the client device 1010 and included in the message 1300 .

[0121] Message video payload 1308 : Video data captured by a camera component or retrieved from a memory component of the client device 1010 and included in the message 1300 .

[0122] Message audio payload 1310 : audio data captured by a microphone or retrieved from a memory component of the client device 1010 and included in the message 1300 .

[0123] Message annotation 1312: Annotation data representing an annotation (e.g., a media overlay such as a filter, sticker, or other enhancement) to be applied to the message image payload 1306, message video payload 1308, or message audio payload 1310 of the message 1300.

[0124] ·Message duration parameter 1314: A parameter value indicating the amount of time, in seconds, that the content of the message 1300 (e.g., message image payload 1306, message video payload 1308, message audio payload 1310) is to be presented to the user via the messaging client application 1014 or that the user has access to the content of the message 1300.

[0125] Message geolocation parameters 1316: Geolocation data (e.g., latitude and longitude coordinates) associated with the content payload of the message 1300. Multiple message geolocation parameter 1316 values ​​may be included in the payload, with each of these parameter values ​​being associated with a content item included in the content (e.g., a specific image in the message image payload 1306, or a specific video in the message video payload 1308).

[0126] Message story identifier 1318: An identification value that identifies one or more content collections (e.g., "stories") associated with a particular content item in the message image payload 1306 of the message 1300. For example, multiple images within the message image payload 1306 may each be associated with multiple content collections using an identifier value.

[0127] Message tags 1320: Each message 1300 may be tagged with a plurality of tags, each tag indicating the subject of the content included in the message payload. For example, where a particular image included in the message image payload 1306 depicts an animal (e.g., a lion), a tag value indicating the relevant animal may be included within the message tags 1320. The tag values ​​may be manually generated based on user input, or may be automatically generated using, for example, image recognition.

[0128] • Message sender identifier 1322: An identifier (eg, a messaging system identifier, an email address, or a device identifier) ​​that indicates the user of the client device 1010 on which the message 1300 was generated and from which the message 1300 was sent.

[0129] • Message recipient identifier 1324: Indicates an identifier (eg, a messaging system identifier, an email address, or a device identifier) ​​of the user of the client device 1010 to which the message 1300 is addressed.

[0130] The content (e.g., value) of each component of message 1300 may be a pointer to a location in a table storing content data values. For example, the image value in message image payload 1306 may be a pointer (or address) to a location in image table 1208. Similarly, the value in message video payload 1308 may point to data stored in video table 1210, the value stored in message annotation 1312 may point to data stored in annotation table 1212, the value stored in message story identifier 1318 may point to data stored in story table 1206, and the values ​​stored in message sender identifier 1322 and message recipient identifier 1324 may point to user records stored in entity table 1202.

[0131] Fig.14 1400 is a block diagram illustrating a software architecture 1402 that can be installed on any one or more of the devices described above. For example, in various embodiments, client device 1010, server system 1008, and servers 1002, 1012, 1016, 1018, 1022, and 1024 can be implemented using some or all of the elements of software architecture 1402. Fig.14 1500, and the like. Fig.151400. In this example, software architecture 1402 can be conceptualized as a stack of layers, where each layer can provide specific functionality. For example, software architecture 1402 includes layers such as operating system 1404, library 1406, framework 1408, and application 1410. Operationally, application 1410 calls API call 1412 through the software stack and receives message 1414 in response to API call 1412 consistent with some embodiments.

[0132] In various implementations, the operating system 1404 manages hardware resources and provides public services. The operating system 1404 includes, for example, a kernel 1420, services 1422, and drivers 1424. According to some embodiments, the kernel 1420 acts as an abstraction layer between the hardware and other software layers. For example, among other functions, the kernel 1420 provides memory management, processor management (e.g., scheduling), component management, networking, and security settings. Services 1422 may provide other public services to other software layers. According to some embodiments, the drivers 1424 are responsible for controlling or interfacing with the underlying hardware. For example, the drivers 1424 may include a display driver, a camera driver, or Low energy drivers, flash drives, serial communication drivers (e.g., Universal Serial Bus (USB) drivers), Drivers, audio drivers, power management drivers, etc.

[0133] In some embodiments, the library 1406 provides a low-level common infrastructure utilized by the application 1410. The library 1406 may include a system library 1430 (e.g., a C standard library) that may provide functions such as memory allocation functions, string manipulation functions, mathematical functions, etc. In addition, the library 1406 may include an API library 1432 such as a media library (e.g., a library for supporting the rendering and operation of various media formats (e.g., Moving Picture Experts Group 4 (MPEG4), Advanced Video Coding (H.264 or AVC), Moving Picture Experts Group Layer 3 (MP3), Advanced Audio Coding (AAC), Adaptive Multi-Rate (AMR) audio codec, Joint Photographic Experts Group (JPEG or JPG), or Portable Network Graphics (PNG))), a graphics library (e.g., an OpenGL framework for rendering two-dimensional (2D) and three-dimensional (3D) graphics content on a display), a database library (e.g., SQLite providing various relational database functions), a network library (e.g., WebKit providing network browsing functions), etc. The library 1406 may also include a variety of other libraries 1434 to provide a variety of other APIs to the application 1410.

[0134] According to some embodiments, the framework 1408 provides a high-level common infrastructure that can be used by the applications 1410. For example, the framework 1408 provides various graphical user interface (GUI) functions, advanced resource management, advanced location services, etc. The framework 1408 can provide a wide range of other APIs that can be used by the applications 1410, some of which may be specific to a particular operating system 1404 or platform.

[0135] In an example embodiment, the applications 1410 include a home application 1450, a contact application 1452, a browser application 1454, a reader application 1456, a location application 1458, a media application 1460, a messaging application 1462, a game application 1464, and a wide range of other applications, such as third-party applications 1466. According to some embodiments, the application 1410 is a program that executes functions defined in the program. Various programming languages ​​can be used to create one or more of the applications 1410 structured in various ways, such as object-oriented programming languages ​​(e.g., Objective-C, Java, or C++) or procedural programming languages ​​(e.g., C or assembly language). In a specific example, the third-party application 1466 (e.g., an application developed by an entity other than the seller of a particular platform using an ANDROID™ or IOS™ software development kit (SDK)) can be a program that is developed on a mobile operating system (e.g., IOS™, ANDROID™, Phone or another mobile operating system). In this example, third-party applications 1466 can call API calls 1412 provided by the operating system 1404 to facilitate the functions described herein.

[0136] Some embodiments may specifically include a camera-based application 1467. In some embodiments, this may be a standalone application that operates to manage communications with a server system, such as a third-party server or server system 1008. In other embodiments, this functionality may be integrated with another application (e.g., messaging application 1462). The camera-based application 1467 may request and display various data related to messaging, media content, media collections, media overlays, etc., and may provide the ability for a user to input data related to the system via a touch interface, keyboard, or using a camera device of the machine 1500, communicate with a server system via I / O components 1550, and receive and store object data in memory 1530. The presentation of information and user input associated with the information may be managed by the camera-based application 1467 using different frameworks 1408, library 1406 elements, or operating system 1404 operating on the machine 1500.

[0137] Fig.151 is a block diagram illustrating components of a machine 1500 capable of reading instructions from a machine-readable medium (e.g., a machine-readable storage medium) and performing any one or more of the methodologies discussed herein, according to some embodiments. Specifically, Fig.15 A diagrammatic representation of a machine 1500 in the example form of a computer system is shown within which instructions 1516 (e.g., software, programs, applications, applet, application, or other executable code) may be executed for causing the machine 1500 to perform any one or more of the methodologies discussed herein. In alternative embodiments, the machine 1500 operates as a standalone device or may be coupled (e.g., using a network) to other machines. In a networked deployment, the machine 1500 may operate as a server machine 1008, 1012, 1016, 1022, 1024, etc. or as a client device 1010 in a server-client network environment, or as a peer machine in a peer-to-peer (or distributed) network environment. The machine 1500 may include, but is not limited to, a server computer, a client computer, a personal computer (PC), a tablet computer, a laptop computer, a netbook, a personal digital assistant (PDA), an entertainment media system, a cellular phone, a smart phone, a mobile device, a wearable device (e.g., a smart watch), a smart home device (e.g., a smart appliance), other smart devices, a web appliance, a network router, a network switch, a network bridge, or any machine capable of sequentially or otherwise executing instructions 1516 that specify actions to be taken by the machine 1500. In addition, while only a single machine 1500 is shown, the term "machine" should also be taken to include a collection of machines 1500 that individually or collectively execute instructions 1516 to perform any one or more of the methodologies discussed herein.

[0138] In various embodiments, the machine 1500 includes a processor 1510, a memory 1530, and an I / O component 1550, which may be configured to communicate with each other via a bus 1502. In an example embodiment, the processor 1510 (e.g., a central processing unit (CPU), a reduced instruction set computing (RISC) processor, a complex instruction set computing (CISC) processor, a graphics processing unit (GPU), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a radio frequency integrated circuit (RFIC), another processor, or any suitable combination thereof) includes, for example, a processor 1512 and a processor 1514 that can execute instructions 1516. The term "processor" is intended to include a multi-core processor 1510 that may include two or more independent processors 1512, 1514 (also referred to as "cores") that can execute instructions 1516 simultaneously. Although Fig.15Multiple processors 1510 are shown, and the machine 1500 may include a single processor 1510 with a single core, a single processor 1510 with multiple cores (e.g., a multi-core processor 1510), multiple processors 1512, 1514 with a single core, multiple processors 1512, 1514 with multiple cores, or any combination thereof.

[0139] According to some embodiments, the memory 1530 includes a main memory 1532, a static memory 1534, and a storage unit 1536, all of which are accessible to the processor 1510 via the bus 1502. The storage unit 1536 may include a machine-readable medium 1518 on which are stored instructions 1516 embodying any one or more of the methodologies or functions described herein. During execution by the machine 1500, the instructions 1516 may also reside, in whole or at least in part, within the main memory 1532, within the static memory 1534, within at least one of the processors 1510 (e.g., within a cache memory of the processor), or any suitable combination thereof. Thus, in various embodiments, the main memory 1532, the static memory 1534, and the processor 1510 are considered to be the machine-readable medium 1518.

[0140] As used herein, the term "memory" refers to a machine-readable medium 1518 capable of temporarily or permanently storing data and may be understood to include, but is not limited to, random access memory (RAM), read-only memory (ROM), buffer memory, flash memory, and cache memory. Although the machine-readable medium 1518 is shown as a single medium in the example embodiment, the term "machine-readable medium" should be considered to include a single medium or multiple media (e.g., a centralized or distributed database, or associated caches and servers) capable of storing instructions 1516. The term "machine-readable medium" should also be understood to include any medium or combination of multiple media capable of storing instructions (e.g., instructions 1516) executed by a machine (e.g., machine 1500) so that the instructions 1516, when executed by one or more processors of the machine 1500 (e.g., processor 1510), cause the machine 1500 to perform any one or more of the methods described herein. Therefore, "machine-readable medium" refers to a single storage device or device, as well as a "cloud-based" storage system or storage network including multiple storage devices or devices. Thus, the term "machine-readable medium" should be understood to include, but is not limited to, one or more data storage repositories in the form of solid-state memory (e.g., flash memory), optical media, magnetic media, other non-volatile memory (e.g., erasable programmable read-only memory (EPROM)), or any suitable combination thereof. The term "machine-readable medium" specifically does not include non-transitory signals per se.

[0141] I / O components 1550 include a variety of components to receive input, provide output, generate output, send information, exchange information, collect measurements, etc. In general, it should be understood that I / O components 1550 may include Fig.15 1550 is grouped according to function for the purpose of simplifying the following discussion only, and the grouping is by no means limiting. In various example embodiments, the I / O component 1550 includes an output component 1552 and an input component 1554. The output component 1552 includes a visual component (e.g., a display such as a plasma display panel (PDP), a light emitting diode (LED) display, a liquid crystal display (LCD), a projector, or a cathode ray tube (CRT)), an auditory component (e.g., a speaker), a tactile component (e.g., a vibration motor), other signal generators, etc. The input component 1554 includes an alphanumeric input component (e.g., a keyboard, a touch screen configured to receive alphanumeric input, an optical keyboard, or other alphanumeric input component), a point-based input component (e.g., a mouse, a touch pad, a trackball, a joystick, a motion sensor, or other pointing instrument), a tactile input component (e.g., a physical button, a touch screen that provides the location and force of a touch or a touch gesture, or other tactile input components), an audio input component (e.g., a microphone), etc.

[0142] In some further example embodiments, the I / O component 1550 includes a biometric component 1556, a motion component 1558, an environmental component 1560, or a position component 1562, among various other components. For example, the biometric component 1556 includes components for detecting expressions (e.g., hand expressions, facial expressions, voice expressions, body postures, or eye tracking), measuring bio-signals (e.g., blood pressure, heart rate, body temperature, sweat, or brain waves), identifying people (e.g., voice recognition, retinal recognition, facial recognition, fingerprint recognition, or EEG-based recognition), etc. The motion component 1558 includes an acceleration sensor component (e.g., an accelerometer), a gravity sensor component, a rotation sensor component (e.g., a gyroscope), etc. Environmental component 1560 includes, for example, an illumination sensor component (e.g., a photometer), a temperature sensor component (e.g., one or more thermometers that detect ambient temperature), a humidity sensor component, a pressure sensor component (e.g., a barometer), an acoustic sensor component (e.g., one or more microphones that detect background noise), a proximity sensor component (e.g., an infrared sensor that detects nearby objects), a gas sensor component (e.g., a machine olfactory detection sensor that detects concentrations of hazardous gases for safety or measures pollutants in the atmosphere), or other components that can provide indications, measurements, or signals corresponding to the surrounding physical environment. Position component 1562 includes a position sensor component (e.g., a global positioning system (GPS) receiver component), an altitude sensor component (e.g., an altimeter or barometer that detects the altitude from which the air pressure can be obtained), an orientation sensor component (e.g., a magnetometer), and the like.

[0143] A variety of technologies may be used to achieve communication. The I / O components 1550 may include a communication component 1564 that is operable to couple the machine 1500 to a network 1580 or a device 1570 via coupling 1582 and coupling 1572, respectively. For example, the communication component 1564 includes a network interface component or other suitable device that interfaces with the network 1580. In further examples, the communication component 1564 includes a wired communication component, a wireless communication component, a cellular communication component, a near field communication (NFC) component, Components (e.g. Low energy consumption), Device 1570 may be another machine 1500 or any of a variety of peripheral devices (eg, a peripheral device coupled via a universal serial bus (USB)).

[0144] In addition, in some embodiments, the communication component 1564 detects an identifier or includes a component operable to detect an identifier. For example, the communication component 1564 includes a radio frequency identification (RFID) tag reader component, an NFC smart tag detection component, an optical reader component (e.g., an optical sensor for detecting one-dimensional barcodes such as universal product codes (UPC) barcodes, multi-dimensional barcodes (e.g., Quick Response (QR) codes, Aztec codes, Data Matrix, Digital Graphics, Max Code, PDF417, Super Code, Uniform Commercial Code Reduced Space Symbol (UCC RSS)-2D barcodes) and other optical codes), an acoustic detection component (e.g., a microphone for identifying a tagged audio signal), or any suitable combination thereof. In addition, various information may be obtained via the communication component 1564, such as obtaining a location via Internet Protocol (IP) geolocation, ... and obtaining a location via Internet Protocol (IP) geolocation. Signal triangulation to obtain location, detecting signals that indicate a specific location Or NFC beacon signal to obtain location, etc.

[0145] In various example embodiments, one or more portions of network 1580 may be an ad hoc network, an intranet, an extranet, a virtual private network (VPN), a local area network (LAN), a wireless local area network (WLAN), a wide area network (WAN), a wireless wide area network (WWAN), a metropolitan area network (MAN), the Internet, a portion of the Internet, a portion of a public switched telephone network (PSTN), a plain old telephone service (POTS) network, a cellular telephone network, a wireless network, 1580, or a portion of network 1580, may include a wireless or cellular network, and coupling 1582 may be a code division multiple access (CDMA) connection, a global system for mobile communications (GSM) connection, or another type of cellular or wireless coupling. In this example, coupling 1582 may implement any of a variety of types of data transmission technologies, such as single carrier radio transmission technology (1xRTT), evolution data optimized (EVDO) technology, general packet radio service (GPRS) technology, enhanced data rates for GSM evolution (EDGE) technology, the third generation partnership project (3GPP) including 3G, fourth generation wireless (4G) networks, universal mobile telecommunications system (UMTS), high speed packet access (HSPA), world wide interoperability for microwave access (WiMAX), long term evolution (LTE) standards, other standards defined by various standards development organizations, other remote protocols, or other data transmission technologies.

[0146] In an example embodiment, the instructions 1516 may be sent or received over the network 1580 using a transmission medium via a network interface device (e.g., a network interface component included in the communication component 1564), and may utilize any of a number of well-known transmission protocols (e.g., the Hypertext Transfer Protocol (HTTP)). Similarly, in other example embodiments, the instructions 1516 may be sent or received using a transmission medium via a coupling 1572 (e.g., a peer-to-peer coupling) to the device 1570. The term "transmission medium" shall be deemed to include any intangible medium capable of storing, encoding, or carrying the instructions 1516 to be executed by the machine 1500, and includes digital or analog communication signals or other intangible media to facilitate the communication of such software.

[0147] Furthermore, the machine-readable medium 1518 is non-transitory (in other words, does not have any transient signals) because it does not embody propagating signals. However, labeling the machine-readable medium 1518 as "non-transitory" should not be interpreted to mean that the medium is not capable of movement; the medium 1518 should be considered to be transportable from one physical location to another. Furthermore, because the machine-readable medium 1518 is tangible, the machine-readable medium 1518 can be considered a machine-readable device.

[0148] Throughout this specification, plural instances may implement components, operations or structures described as single instances. Although the individual operations of one or more methods are shown and described as separated operations, one or more of the individual operations may be performed in parallel, and the operations are not required to be performed in the illustrated order. The structure and function presented as separated components in the example configuration may be implemented as a combined structure or component. Similarly, the structure and function presented as a single component may be implemented as a separated component. These and other variations, modifications, additions and improvements fall within the scope of the subject matter herein.

[0149] Although an overview of the inventive subject matter has been described with reference to specific example embodiments, various modifications and changes may be made to these embodiments without departing from the broader scope of the embodiments of the present disclosure.

[0150] The embodiments illustrated herein are described in sufficient detail to enable those skilled in the art to practice the disclosed teachings. Other embodiments may be used and derived therefrom, such that structural and logical substitutions and changes may be made without departing from the scope of the present disclosure. Therefore, the detailed description is not to be construed in a limiting sense, and the scope of the various embodiments is defined solely by the appended claims, along with the full scope of equivalents to which such claims are entitled.

[0151] As used herein, the term "or" may be interpreted in an inclusive or exclusive sense. Moreover, multiple instances may be provided for resources, operations, or structures described herein as a single instance. In addition, the boundaries between various resources, operations, modules, engines, and data stores are arbitrary to some extent, and specific operations are shown in the context of a specific illustrative configuration. Other allocations of functions are envisioned and may fall within the scope of various embodiments of the present disclosure. In general, the structures and functions presented as separate resources in the example configuration may be implemented as combined structures or resources. Similarly, the structures and functions presented as a single resource may be implemented as separate resources. These and other variations, modifications, additions, and improvements fall within the scope of the embodiments of the present disclosure as represented in the appended claims. Therefore, the specification and the drawings will be considered to be illustrative rather than restrictive.

Claims

1. A method, include: receiving, by the computing device, image data from a camera of the computing device; generating, by the computing device, an image pyramid from the image data, the image pyramid comprising a plurality of levels of images in the image data, the image data being subsampled at a plurality of resolutions for each level; Initiating, by the computing device, a transmission of image data corresponding to at least one predetermined level of the image pyramid comprising a higher resolution to a graphics processing unit (GPU) of the computing device; Calculating, by a central processing unit (CPU) of the computing device, an optical flow of at least one predetermined coarse level of the image pyramid; transmitting, by the CPU of the computing device, the calculated optical flow of the at least one predetermined coarse level of the image pyramid to the GPU; calculating, by the GPU of the computing device, the optical flow of the at least one predetermined coarse level of the image pyramid calculated by the CPU to generate an optical flow of the image data by calculating the optical flow of the at least one predetermined level of higher resolution of the image pyramid; as well as The optical flow of the image data is output by the GPU of the computing device.

2. The method according to claim 1, in, The image data includes one or more frames for a video stream of video captured by the camera of the computing device.

3. The method according to claim 1, in, The image is a frame of a video stream for video captured by the camera of the computing device.

4. The method according to claim 1, in, Calculating, by the central processing unit CPU of the computing device, the optical flow of at least one predetermined coarse level of the image pyramid comprises: Calculate the source image gradient in the X and Y directions for each pixel; dividing the image into a grid of blocks; Calculate the sum of the gradients of each block; Compute the inverse Hessian matrix; Set up the initial flow field; performing an iterative block search; and Compute pixel-by-pixel flow fields.

5. The method according to claim 1, in, Calculating, by the central processing unit CPU of the computing device, the optical flow of at least one predetermined coarse level of the image pyramid comprises, for each level: Preprocess image gradients; Perform block-wise optical flow; A dense optical flow is performed based on the block-wise optical flow.

6. The method according to claim 5, in, Performing the block-wise optical flow includes performing, for each block of the level, an iterative inverse block search based on inverse components to find incremental optical flows of the image in the X and Y directions.

7. The method according to claim 6, in, Performing the iterative inverse block search includes calculating a cost of a block match, and wherein calculating the cost of the block match is implemented on a single instruction multiple data SIMD.

8. The method according to claim 5, in, Performing dense optical flow includes a process of evaluating pixel difference costs using neighboring optical flow outputs, and wherein the process is implemented on a single instruction multiple data SIMD by generating four bilinear interpolated pixels at a time.

9. The method according to claim 6, in, Performing an iterative inverse block search involves: (a) determining the pixel difference between the image and the previous frame; (b) using the pixel differences to calculate the difference in X and Y motion vectors; (c) Update X and Y; (d) determining whether the pixel cost is less than a predetermined threshold; and (e) If the pixel cost is not less than the predetermined threshold, return to step (a).

10. The method according to claim 1, in, Computing, by the GPU of the computing device, the optical flow of the at least one predetermined level of the image pyramid including a higher resolution comprises, for each parallel level: Preprocess image gradients; Perform block-wise optical flow; Perform adjacent synchronization; as well as A dense optical flow is performed based on the block-wise optical flow.

11. The method according to claim 10, in, Performing adjacent synchronization includes: For a given block of a plurality of blocks in a layer of the image pyramid: Determine all neighboring blocks of the given block; determining a cost value given by a cost function for each neighboring block motion vector value; comparing each neighboring block cost value to the cost value of the given block; and If any neighboring block cost value is less than the cost value of the given block, updating the vector value of the given block, wherein the vector value of the given block is updated to include the neighboring block motion vector value having the lowest cost value.

12. A computing device, include: a memory for storing instructions; as well as One or more hardware processors configured by the instructions to perform the following operations: receiving image data from a camera of the computing device; generating an image pyramid from the image data, the image pyramid comprising a plurality of levels of images in the image data, the image data being subsampled at a plurality of resolutions for each level; Initiating transmission of image data corresponding to at least one predetermined level of the image pyramid comprising a higher resolution to a graphics processing unit GPU of the computing device; calculating, by the central processing unit (CPU) of the computing device, an optical flow of at least one predetermined coarse level of the image pyramid; transmitting, by the CPU of the computing device, the calculated optical flow of the at least one predetermined coarse level of the image pyramid to the GPU; calculating, by the GPU of the computing device, the optical flow of the at least one predetermined coarse level of the image pyramid calculated by the CPU to generate an optical flow of the image data by calculating the optical flow of the at least one predetermined level of higher resolution of the image pyramid; as well as The optical flow of the image data is output by the GPU of the computing device.

13. The computing device according to claim 12, in, Calculating, by the central processing unit CPU of the computing device, the optical flow of at least one predetermined coarse level of the image pyramid comprises, for each level: Preprocess image gradients; Perform block-wise optical flow; A dense optical flow is performed based on the block-wise optical flow.

14. The computing device according to claim 13, in, Performing the block-wise optical flow includes performing, for each block of the level, an iterative inverse block search based on inverse components to find incremental optical flows of the image in the X and Y directions.

15. The computing device of claim 14, in, Performing the iterative inverse block search includes calculating a cost of a block match, and wherein calculating the cost of the block match is implemented on a single instruction multiple data SIMD.

16. The computing device of claim 13, in, Performing dense optical flow includes a process of evaluating pixel difference costs using neighboring optical flow outputs, and wherein the process is implemented on a single instruction multiple data SIMD by generating four bilinear interpolated pixels at a time.

17. The computing device of claim 14, in, Performing an iterative inverse block search involves: (a) determining the pixel difference between the image and the previous frame; (b) using the pixel differences to calculate the difference in X and Y motion vectors; (c) Update X and Y; (d) determining whether the pixel cost is less than a predetermined threshold; and (e) If the pixel cost is not less than the predetermined threshold, return to step (a).

18. The computing device of claim 12, in, Computing, by the GPU of the computing device, the optical flow of the at least one predetermined level of the image pyramid including a higher resolution comprises, for each parallel level: Preprocess image gradients; Perform block-wise optical flow; Perform adjacent synchronization; as well as A dense optical flow is performed based on the block-wise optical flow.

19. The computing device of claim 18, in, Performing adjacent synchronization includes: For a given block of a plurality of blocks in a layer of the image pyramid: Determine all neighboring blocks of the given block; determining a cost value given by a cost function for each neighboring block motion vector value; comparing each neighboring block cost value to the cost value of the given block; and If any neighboring block cost value is less than the cost value of the given block, updating the vector value of the given block, wherein the vector value of the given block is updated to include the neighboring block motion vector value having the lowest cost value.

20. A non-transitory computer-readable medium comprising instructions stored thereon, the instructions executable by at least one processor to cause a computing device to perform operations comprising: receiving image data from a camera of the computing device; generating an image pyramid from the image data, the image pyramid comprising a plurality of levels of images in the image data, the image data being subsampled at a plurality of resolutions for each level; Initiating transmission of image data corresponding to at least one predetermined level of the image pyramid comprising a higher resolution to a graphics processing unit GPU of the computing device; calculating, by the central processing unit (CPU) of the computing device, an optical flow of at least one predetermined coarse level of the image pyramid; transmitting, by the CPU of the computing device, the calculated optical flow of the at least one predetermined coarse level of the image pyramid to the GPU; calculating, by the GPU of the computing device, the optical flow of the at least one predetermined coarse level of the image pyramid calculated by the CPU to generate an optical flow of the image data by calculating the optical flow of the at least one predetermined level of higher resolution of the image pyramid; as well as The optical flow of the image data is output by the GPU of the computing device.