A method for cartoonizing images and videos in online classes
By combining generative adversarial networks and image processing modules, we solve the boring problem of images and videos in online classes, generate high-quality cartoon content, reduce visual fatigue and prevent myopia.
Patent Information
- Application Number
- CN202011013600.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-24
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2040-09-24
AI Technical Summary
Facing a single boring computer screen for a long time in online classes causes visual fatigue for users. Existing cartooning technology ignores details, resulting in color shifts and texture distortions, artifacts that users do not like.
Using a generative adversarial network combined with three independent image processing modules, through smooth contours, sparse color block structure and high-frequency texture representation, a loss function is designed to adjust the weight to generate high-quality cartoon images or videos, and the anti-myopia recognition module is used according to the user's needs. Behaviorally adjust image details to achieve cartooning of images and videos.
Generate high-quality cartoon images or videos, reduce visual fatigue, enhance learning experience, avoid artifacts, and automatically adjust image details to prevent myopia and bad habits.
Smart Images

Figure CN112132922B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of online image processing, and in particular relates to a method for cartoonizing images and videos in an online classroom. Background Art
[0002] In recent years, with the rapid development of the Internet, online education has developed on a larger scale with its special advantages. This technology has been gradually improved with the needs of teachers and students. However, facing a single boring computer screen for a long time, users in front of the screen are easily bored, their enthusiasm for learning decreases, and they feel visual fatigue.
[0003] Cartoons are used in various scenes. The effects of cartoons are funny, cute, and solemn. Cartoon art images can make people feel refreshed visually, add humor to life, and enrich spiritual life. Cartoonization is to use real pictures as input to get corresponding cartoon pictures. Some existing cartoonization technologies selectively ignore finer lines and textures, which eventually cause some color shifts, texture distortions, and other artifacts that users don't like. Summary of the invention
[0004] The purpose of the present invention is to overcome the shortcomings of the prior art and provide a method for cartoonizing images and videos in an online classroom, thereby solving the technical problem that the traditional classroom screen is monotonous and boring in the prior art. The present invention is used to realize cartoonization of classroom screens and generate high-quality cartoonized images or videos.
[0005] The object of the present invention is achieved by: a method for cartoonizing images and videos in an online classroom, comprising the following steps:
[0006] (1) Crawling several real images and cartoon images from the Internet as training data sets;
[0007] (2) Construct a generative adversarial network, distinguish the high-level features of the image extracted by the trained network, and design a loss function to adjust the weight of each component; design three independent image processing modules to extract the corresponding three cartoon representations, and guide the image cartoonization framework based on the generative adversarial network, balance the weight of each representation in the generative adversarial network, adjust the loss function, and obtain the optimal style of cartoon image output;
[0008] (3) Autonomously select cartoonization mode for input images in online classes;
[0009] (4) After training, the generator of the generative adversarial network inputs the online classroom image to be processed and outputs the corresponding cartoon image;
[0010] Among them, the cartoonization mode includes portrait cartoonization and overall cartoonization. The adversarial network consists of a generator G and two discriminators D x , D y composition.
[0011] In step (1), the three cartoon representations of the three independent image processing modules are: cartoon image through smooth contour surface representation, structure representation of different sparse color blocks, and texture representation reflecting high-frequency texture and details.
[0012] In order to further realize the cartoonization of the image, the step (2) is specifically to use the real image I in step (1) as a guide image and input it into the generator G to transform it into a cartoon image, where I1 represents the input image and I 11 represents the reference cartoon image, and the image processing module guides the optimization of the generated adversarial network image cartoonization framework, including the following steps,
[0013] (201) Image processing module F d In order to smooth the image while maintaining the global semantic structure, edge detection uses a distinguishable guided filter to preserve filtering, and the output only extracts the cartoon image that retains the color composition and surface features; the discriminator D x Determine whether the model output has a similar surface to the reference cartoon image, and guide the generator G to learn the information stored in the extracted surface representation. The surface loss function is designed as:
[0014] L sur (G, D x ) = log (D x (F d (I 11 , I 11 )))+log(1-D x (F d (G(I1),G(I1)))) (1);
[0015] (202) Image processing module F s Based on the input image, an inseparable graph is extracted, and a standard superpixel algorithm is used in each segmented area to color the generated structure representation with the average value of the pixel value; the pre-trained VGG n The network is used to implement spatial constraints, and the structural loss function is designed as:
[0016] L str =||VGG n (G(I1))-VGG(F s (G(I1)))|| (2);
[0017] (203) Image processing module F tReduce the influence of color and brightness and retain high-frequency features, and then let the network learn texture details autonomously. When learning texture features, the three color channels of RGB are analyzed and processed separately using a single-channel texture algorithm. The grayscale image converted from the RGB image is represented by U, F t The formula is:
[0018] F t (I rgb ) = (1-α)(β1*I r +β2*I g +β3*I b )+α*U (3)
[0019] In the formula (3), α is assumed to be between 0 and 1, and β1, β2, and β3 are assumed to be between -1 and 1;
[0020] Discriminator D y The texture representation extracted from the discriminative output image and the reference cartoon image is used to guide the generator G to learn the clear image and fine texture stored in the texture representation. The texture loss function is designed as:
[0021] L tex (G, D y ) = log (D y (F t (I 11 )))+log(1-D y (F t (G(I1)))(4);
[0022] (204) By adjusting λ1, λ2, λ3, and λ4 to optimize the loss function, the total loss function is designed as:
[0023] L=λ 1* L sur +λ 2* L str +λ 3* L tex +λ 4* L tv (5);
[0024] In formula (5), in order to reduce high-frequency noise, the loss function L is designed tv , the spatial dimensions of the image are represented by H, W, and C, and the formula is:
[0025] L tv =1 / (H*W*C)* ||(▽x(G(I1))+▽y(G(I1)))|| (6);
[0026] Among them, F t (I rgb) is to extract the color image and remove the brightness and color information; F d is the surface representation extraction, F s For structural representation extraction, F t is texture representation extraction, G(I1)) is the cartoon image generated by the generator G for image I1, VGG n (G(I1)) is the spatial constraint on G(I1); F s (G(I1) is the structural representation of extracted G(I1), VGG(F s (G(I1)) is the s (G(I1)) implements spatial constraints; F d (I 11 , I 11 ) is the input image I 11 , returns a surface representation with texture and details removed; F d (G(I1) is the surface representation of extracted G(I1), F d (G(I1), G(I1)) is the input image G(I1), and returns the surface representation with texture and details removed; I r ,I g and I b For three color channels, F t (I 11 ) is to extract I 11 Color image, remove brightness and color information, F t (G(I1)) is to extract the G(I1) color image and remove the brightness and color information. λ1 is the parameter of the surface loss function, λ2 is the parameter of the structure loss function, λ3 is the parameter of the texture loss function, λ4 is the parameter of the noise loss function, and α is, D y (F t (I 11 )) is the determining feature F t (I 11 ) from training sample I 11 The probability of D y (F t (G(I1))) is the determining feature F t (G(I1)) is the probability of coming from the training sample I1, and ▽x(G(I1)), ▽y(G(I1)) use the gradient descent algorithm to smooth G(I1) and reduce image distortion.
[0027] In order to achieve adaptive adjustment of cartoon images, in step (2), the anti-myopia recognition module generates the weight of each representation in the adversarial network for the user's posture in class, and adjusts the loss function.
[0028] As a further improvement of the present invention, in step (2), the anti-myopia recognition module is used to identify and detect the number of times the user at the receiving end closes his eyes and the distance between his head and the desk when reading or studying, so as to determine whether the user's posture in class is correct and his attention is focused.
[0029] In order to further realize the adaptive adjustment of the cartoon image, the following steps are further included between step (203) and step (204):
[0030] (204a) The anti-myopia recognition module uses the center point between the two points of the eye axis of both eyes as the starting point every 5 minutes, confirms the position of the picture being read by the eyes through the camera, and uses the Hough transform to detect the straight line to find the shortest distance between the starting point and the reading picture; every 2 minutes, the camera detects the number of times the eyes are opened and closed and the user's online learning posture;
[0031] (204b) Compare the shortest distance with the designed threshold value. If the shortest distance is less than the threshold value, the parameter represented by the surface is reduced to remind the user that the distance to the screen is close; compare the number of eye closures with the designed threshold value. If it is less than the threshold value, the parameter represented by the structure is increased to warn the user that the user is now in a tired state; identify the user's learning posture at this time. If the posture is incorrect, the parameter represented by the texture is increased to remind the user that the current learning posture is incorrect. If the posture is incorrect or the shortest distance is less than the threshold value or the number of eye closures is less than the threshold value, go to step (204c); if the posture is correct, the shortest distance is not less than the threshold value and the number of eye closures is not less than the threshold value, go to step (204);
[0032] (204c) The preset value x1 is used as the surface to represent a decreasing range of variation, the preset value x2 is used as the structure to represent an increasing range of variation, and the preset value x3 is used as the texture to represent an increasing range of variation. The loss function L' is designed as,
[0033] L′=(λ1–x1)L sur +(λ2+x2)L str +(λ3+x3)L tex +λ4L tv (7);
[0034] Among them, the shortest distance is less than the distance threshold, 0<x1<λ1, otherwise x1=0; the number of eye closures is less than the designed number threshold, 0<x2<λ2, otherwise x2=0; the posture is incorrect, 0<x3<λ3, otherwise x3=0.
[0035] In order to further realize the cartoonization of the video, when the video is selected to be cartoonized, the current frame of the input video is cartoonized and used as a reference frame to enable the subsequent frames to realize the real-time cartoonization of the video.
[0036] Compared with the prior art, the present invention puts real images and cartoon images into an image cartoonization framework based on a generative adversarial network for training to generate high-quality cartoonized images or videos; users can adjust the different styles of image output in the online classroom by balancing the weight of each representation, realize user cartoonization selection and modification, and solve the problem of user visual fatigue in the online classroom; adjust the loss function to add more details to the image, reduce the modification of inappropriate colors and details, and achieve the rationality and effectiveness of image and video cartoonization; according to the user's behavioral performance in front of the screen, the image can be automatically adjusted to form a warning effect, avoid the formation of bad habits of users, and prevent the increase of myopia. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is the overall flow chart of the present invention.
[0038] Figure 2 It is a cartoonized flowchart of the present invention. DETAILED DESCRIPTION
[0039] The present invention will be further described below in conjunction with the accompanying drawings.
[0040] like Figure 1 A method for cartoonizing images and videos in an online classroom is shown, comprising the following steps:
[0041] (1) Crawling several real images and several cartoon images from the Internet as training data sets, the real images and cartoon images obtained are used as training data sets, as follows:
[0042] Find a real picture website, which requires real face images and landscape images to be clearly visible;
[0043] Find a cartoon image website that requires the cartoon face images and landscape images to be clearly visible;
[0044] Using web crawler technology, we crawled 20,000 face images and 20,000 landscape images from real picture websites, and crawled 20,000 face images and 20,000 landscape images from cartoon picture websites;
[0045] (2) Construct a generative adversarial network, which consists of a generator G and two discriminators Dx and Dy, as follows:
[0046] First, the generator network is a fully convolutional network, which consists of three layers: convolutional layer, downsampling layer, and bilinear layer. The convolutional layer with stride=2 is used as the downsampling layer, and the bilinear interpolation layer is used as the upsampling layer. The generator G automatically generates cartoon image output by inputting real images; secondly, the discriminator network uses PatchGAN, and PatchGAN outputs an N*N matrix X. Each element of this N*N matrix X ij There are only two choices: right or wrong. The N*N matrix finally output by the successively stacked convolutional layers, each element of which represents a relatively large receptive field in the original image, that is, corresponds to a matrix in the original image;
[0047] Then the trained network is used to distinguish the high-level features of the image and the loss function is designed to adjust the weight of each component. Three independent image processing modules are designed to extract the corresponding three cartoon representations and guide the image cartoonization framework based on the generative adversarial network to balance the weight of each representation in the generative adversarial network and adjust the loss function to obtain the optimal style of the cartoon image output.
[0048] Based on the above-mentioned generative adversarial network, the real images in the training dataset are used as input, and the generator and discriminator are continuously adjusted during the training process to optimize the loss before passing through the anti-myopia recognition module;
[0049] (3) Autonomously select cartoonization mode for input images in online classes;
[0050] (4) After training, the generator of the generative adversarial network inputs the online classroom image to be processed and outputs the corresponding cartoon image;
[0051] Among them, the cartoonization mode includes portrait cartoonization and overall cartoonization. The adversarial network consists of a generator G and two discriminators D x , D y Composition; in step (1), the three cartoon representations of the three independent image processing modules are: the cartoon image is represented by a smooth contour surface, the structure of different sparse color blocks, and the texture that reflects high-frequency texture and details. The high-frequency texture is the image converted into a grayscale image, and the edge and texture information changes greatly.
[0052] In order to further realize the cartoonization of the image, the step (2) is specifically to use the real image I in step (1) as a guide image and input it into the generator G to transform it into a cartoon image, where I1 represents the input image and I 11 represents the reference cartoon image, and the image processing module guides the optimization of the generated adversarial network image cartoonization framework, including the following steps,
[0053] (201) Image processing module Fd In order to smooth the image while maintaining the global semantic structure, edge detection uses a distinguishable guided filter to preserve filtering, and the output only extracts the cartoon image that retains the color composition and surface features; the discriminator D x Determine whether the model output has a similar surface to the reference cartoon image, and guide the generator G to learn the information stored in the extracted surface representation. The surface loss function is designed as:
[0054] L sur (G, D x ) = log (D x (F d (I 11 , I 11 )))+log(1-D x (F d (G(I1),G(I1)))) (1);
[0055] (202) Image processing module F s Based on the input image, an inseparable graph is extracted, and a standard superpixel algorithm is used in each segmented area to color the generated structure representation with the average value of the pixel value; the pre-trained VGG n The network is used to implement spatial constraints, and the structural loss function is designed as:
[0056] L str =||VGG n (G(I1))-VGG(F s (G(I1)))|| (2);
[0057] (203) Image processing module F t Reduce the influence of color and brightness and retain high-frequency features, and then let the network learn texture details autonomously. When learning texture features, the three color channels of RGB are analyzed and processed separately using a single-channel texture algorithm. The grayscale image converted from the RGB image is represented by U, F t The formula is:
[0058] F t (I rgb ) = (1-α)(β1*I r +β2*I g +β3*I b )+α*U (3)
[0059] In the formula (3), let α be any value between 0 and 1, and let β1, β2, and β3 be any value between -1 and 1;
[0060] The discriminator Dy discriminates the texture representation extracted from the output image and the reference cartoon image, and guides the generator G to learn the clear image and fine texture stored in the texture representation. The texture loss function is designed as:
[0061] L tex (G, D y ) = log (D y (F t (I 11 )))+log(1-D y (F t (G(I1)))(4);
[0062] (204) By adjusting λ1, λ2, λ3, and λ4 to optimize the loss function, the total loss function is designed as:
[0063] L=λ 1* L sur +λ 2* L str +λ 3* L tex +λ 4* L tv (5);
[0064] In formula (5), in order to reduce high-frequency noise, the loss function L is designed tv , the spatial dimensions of the image are represented by H, W, and C, and the formula is:
[0065] L tv =1 / (H*W*C)* ||(▽x(G(I1))+▽y(G(I1)))|| (6);
[0066] Among them, F t (I rgb ) is to extract the color image and remove the brightness and color information; F d is the surface representation extraction, Fs is the structure representation extraction, F t is texture representation extraction, G(I1)) is the cartoon image generated by the generator G for image I1, VGG n (G(I1)) is the spatial constraint on G(I1); F s (G(I1) is the structural representation of extracted G(I1), VGG(F s (G(I1)) is the s (G(I1)) implements spatial constraints; F d (I 11 , I 11 ) is the input image I 11 , returns a surface representation with texture and details removed; F d(G(I1) is the surface representation of extracted G(I1), F d (G(I1), G(I1)) is the input image G(I1), and returns the surface representation with texture and details removed; I r ,I g and I b For three color channels, F t (I 11 ) is to extract I 11 Color image, remove brightness and color information, F t (G(I1)) is to extract the G(I1) color image and remove the brightness and color information. λ1 is the parameter of the surface loss function, λ2 is the parameter of the structure loss function, λ3 is the parameter of the texture loss function, λ4 is the parameter of the noise loss function, and α is, D y (F t (I 11 )) is the determining feature F t (I 11 ) from training sample I 11 The probability of D y (F t (G(I1))) is the determining feature F t (G(I1)) is the probability of coming from the training sample I1, and ▽x(G(I1)), ▽y(G(I1)) use the gradient descent algorithm to smooth G(I1) and reduce image distortion.
[0067] In step (2), the anti-myopia recognition module is used to identify the number of times the receiving end user closes his eyes and the distance between his head and the desk when reading or studying, and to determine whether the user's posture in class is correct and his attention is focused; the following steps are also included between step (203) and step (204):
[0068] (204a) The anti-myopia recognition module uses the center point between the two points of the eye axis of both eyes as the starting point every 5 minutes, confirms the position of the picture being read by the eyes through the camera, and uses the Hough transform to detect the straight line to find the shortest distance between the starting point and the reading picture; every 2 minutes, the camera detects the number of times the eyes are opened and closed and the user's online learning posture;
[0069] (204b) Compare the shortest distance with the designed threshold value. If the shortest distance is less than the threshold value, the parameter represented by the surface is reduced to remind the user that the distance to the screen is close; compare the number of eye closures with the designed threshold value. If it is less than the threshold value, the parameter represented by the structure is increased to warn the user that the user is now in a tired state; identify the user's learning posture at this time. If the posture is incorrect, the parameter represented by the texture is increased to remind the user that the current learning posture is incorrect. If the posture is incorrect or the shortest distance is less than the threshold value or the number of eye closures is less than the threshold value, go to step (204c); if the posture is correct, the shortest distance is not less than the threshold value and the number of eye closures is not less than the threshold value, go to step (204);
[0070] (204c) The preset value x1 is used as the surface to represent a decreasing range of variation, the preset value x2 is used as the structure to represent an increasing range of variation, and the preset value x3 is used as the texture to represent an increasing range of variation. The loss function L' is designed as,
[0071] L′=(λ1–x1)L sur +(λ2+x2)L str +(λ3+x3)L tex +λ4L tv (7);
[0072] Among them, the shortest distance is less than the distance threshold, 0<x1<λ1, otherwise x1=0; the number of eye closures is less than the designed number threshold, 0<x2<λ2, otherwise x2=0; the posture is incorrect, 0<x3<λ3, otherwise x3=0.
[0073] In order to further realize the cartoonization of the video, when the video is selected to be cartoonized, the current frame of the input video is cartoonized and used as a reference frame to enable the subsequent frames to realize the real-time cartoonization of the video.
[0074] In step (3) of the present invention, when cartooning a portrait, a real person image is obtained through human body detection and face recognition algorithms, and the portrait cartooning is realized through subsequent steps; the present invention puts the real image and the cartoon image into an image cartoonization framework based on a generative adversarial network for training, and generates high-quality cartoonized images or videos; the user can adjust the different styles of image output in the online class by balancing the weight of each representation, realize the user's cartoonization selection and modification, and solve the problem of user visual fatigue in the online class; adjust the loss function to add more details to the image, reduce the modification of inappropriate colors and details, and achieve the rationality and effectiveness of image and video cartooning; according to the user's behavior in front of the screen, the image can be automatically adjusted to form a warning effect, avoid the formation of bad habits of the user, and prevent the increase of myopia; it can be applied to the work of cartooning images and videos during online classes.
[0075] The present invention is not limited to the above-mentioned embodiments. On the basis of the technical solution disclosed in the present invention, technicians in this field can make some substitutions and deformations to some technical features therein according to the disclosed technical content without creative labor, and these substitutions and deformations are all within the protection scope of the present invention.
Claims
1. A method for cartoonizing images and videos in online classes, characterized in that: The following steps are included: (1) Crawling several real images and cartoon images from the Internet as training data sets; (2) Construct a generative adversarial network, distinguish the high-level features of the image extracted by the trained network, and design a loss function to adjust the weight of each component; design three independent image processing modules to extract the corresponding three cartoon representations, and guide the image cartoonization framework based on the generative adversarial network, balance the weight of each representation in the generative adversarial network, adjust the loss function, and obtain the optimal style of cartoon image output; (3) Autonomously select cartoonization mode for input images in online classes; (4) After training, the generator of the generative adversarial network inputs the online classroom image to be processed and outputs the corresponding cartoon image; Among them, the cartoonization mode includes portrait cartoonization and overall cartoonization. The adversarial network consists of a generator G and two discriminators D x , D y composition; Specifically, the step (2) is to use the real image I in step (1) as a guide image and input it into the generator G to transform it into a cartoon image, where I1 represents the input image and I 11 represents the reference cartoon image, and the image processing module guides the optimization of the generated adversarial network image cartoonization framework, including the following steps, (201) Image processing module F d In order to smooth the image while maintaining the global semantic structure, edge detection uses a differentiable guided filter to preserve filtering, and the output is a cartoon image that only retains color composition and surface features; the discriminator D x Determine whether the model output has a similar surface to the reference cartoon image, and guide the generator G to learn the information stored in the extracted surface representation. The surface loss function is designed as: L sur (G,D x )=log (D x (F d (I 11 ,I 11 )))+log(1-D x (F d (G(I1),G(I1)))) (1); (202) Image processing module F s Based on the input image, an inseparable graph is extracted, and a standard superpixel algorithm is used in each segmented area to color the generated structure representation with the average value of the pixel value; the pre-trained VGG n The network is used to implement spatial constraints, and the structural loss function is designed as: L str =||VGG n (G(I1))-VGG n (F s (G(I1)))|| (2); (203) Image processing module F t Reduce the influence of color and brightness and retain high-frequency features, and then let the network learn texture details autonomously. When learning texture features, the three color channels of RGB are analyzed and processed separately using a single-channel texture algorithm. The grayscale image converted from the RGB image is represented by U, F t The formula is: F t (I) rgb )=(1-α)(β1*I r +β2*I g +β3*I b )+α*U (3); In the formula (3), α is assumed to be between 0 and 1, and β1, β2, and β3 are assumed to be between -1 and 1; Discriminator D y The texture representation extracted from the discriminative output image and the reference cartoon image is used to guide the generator G to learn the clear image and fine texture stored in the texture representation. The texture loss function is designed as: L tex (G,D y )=log (D y (F t (I 11 )))+log(1-D y (F t (G(I1))))(4); (204) By adjusting λ1, λ2, λ3, and λ4 to optimize the loss function, the total loss function is designed as: L=λ 1* L sur +λ 2* L str +λ 3* L tex +λ 4* L tv (5); In formula (5), in order to reduce high-frequency noise, the loss function L is designed tv , the spatial dimensions of the image are represented by H, W, and C, and the formula is: L tv =1 / (H*W*C)* ||(▽x(G(I1))+▽y(G(I1)))|| (6); Among them, F t (I rgb ) is to extract the color image and remove the brightness and color information; F d is the surface representation extraction, F s For structural representation extraction, F t is texture representation extraction, G(I1) is the cartoon image generated by generator G for image I1, VGG n (G(I1)) is the spatial constraint on G(I1); F s (G(I1)) is the structural representation of extracted G(I1), VGG n (F s (G(I1))) is the s (G(I1)) implements spatial constraints; F d (I 11 , I 11 ) is the input image I 11 , returns a surface representation with texture and details removed; F d (G(I1), G(I1)) is the input image G(I1), and returns the surface representation with texture and details removed; I r ,I g and I b For three color channels, F t (I 11 ) is to extract I 11 Color image, remove brightness and color information, F t (G(I1)) is the extraction of G(I1) color image, removing brightness and color information, λ1 is the parameter of surface loss function, λ2 is the parameter of structure loss function, λ3 is the parameter of texture loss function, λ4 is the parameter of noise loss function, D y (F t (I 11 )) is the determining feature F t (I 11 ) from training sample I 11 The probability of D y (F t (G(I1))) is the determining feature F t (G(I1)) is the probability of the training sample I1, ▽x(G(I1)), ▽y(G(I1)) use the gradient descent algorithm to smooth G(I1) and reduce image distortion; In step (2), the anti-myopia recognition module is used to judge the posture of the user in class, balance the weight of each representation in the generative adversarial network, and adjust the loss function. The anti-myopia recognition module is used to identify the number of times the user at the receiving end closes his eyes and the distance between the head and the desk when reading or studying, and judge whether the user's posture in class is correct and whether the user is concentrating. The following steps are also included between step (203) and step (204): (204a) The anti-myopia recognition module uses the center point between the two points of the eye axis of both eyes as the starting point every 5 minutes, confirms the position of the picture being read by the eyes through the camera, and uses the Hough transform to detect the straight line to find the shortest distance between the starting point and the reading picture; every 2 minutes, the camera detects the number of times the eyes are opened and closed and the user's online learning posture; (204b) Compare the shortest distance with the designed threshold value. If the shortest distance is less than the threshold value, the parameter represented by the surface is reduced to remind the user that the distance to the screen is close; compare the number of eye closures with the designed threshold value. If it is less than the threshold value, the parameter represented by the structure is increased to warn the user that the user is now in a tired state; identify the user's learning posture at this time. If the posture is incorrect, the parameter represented by the texture is increased to remind the user that the current learning posture is incorrect. If the posture is incorrect or the shortest distance is less than the threshold value or the number of eye closures is less than the threshold value, go to step (204c); if the posture is correct, the shortest distance is not less than the threshold value and the number of eye closures is not less than the threshold value, go to step (204); (204c) The preset value x1 is used as the surface to represent a decreasing range of variation, the preset value x2 is used as the structure to represent an increasing range of variation, and the preset value x3 is used as the texture to represent an increasing range of variation. The loss function L' is designed as, L′=(λ1–x1)L sur +(λ2 +x2)L str +(λ3 +x3)L tex +λ4L tv (7); Among them, the shortest distance is less than the distance threshold, 0<x1<λ1, otherwise x1=0; the number of eye closures is less than the designed number threshold, 0<x2<λ2, otherwise x2=0; the posture is incorrect, 0<x3<λ3, otherwise x3=0.
2. A method for cartoonizing images and videos in an online classroom according to claim 1, characterized in that: In the step (1), the three cartoon representations of the three independent image processing modules are: cartoon image through smooth contour surface representation, structure representation of different sparse color blocks, and texture representation reflecting high-frequency texture and details.
3. A method for cartoonizing images and videos in an online classroom according to claim 1 or 2, characterized in that: When a video is selected to be cartoonized, the current frame of the input video is cartoonized and used as a reference frame to enable subsequent frames to achieve real-time video cartoonization.
