WO2023020334A1 - Image direction adjustment method and apparatus, and storage medium and electronic device - Google Patents

Image direction adjustment method and apparatus, and storage medium and electronic device Download PDF

Info

Publication number
WO2023020334A1
WO2023020334A1 PCT/CN2022/111133 CN2022111133W WO2023020334A1 WO 2023020334 A1 WO2023020334 A1 WO 2023020334A1 CN 2022111133 W CN2022111133 W CN 2022111133W WO 2023020334 A1 WO2023020334 A1 WO 2023020334A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
rotation angle
target
probability value
camera
Prior art date
Application number
PCT/CN2022/111133
Other languages
French (fr)
Chinese (zh)
Inventor
王红梅
郑侠松
Original Assignee
广州视源电子科技股份有限公司
广州视睿电子科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 广州视源电子科技股份有限公司, 广州视睿电子科技有限公司 filed Critical 广州视源电子科技股份有限公司
Publication of WO2023020334A1 publication Critical patent/WO2023020334A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/60Rotation of whole images or parts thereof

Definitions

  • the present application relates to the field of computer technology, and in particular to an image orientation adjustment method, device, storage medium and electronic equipment.
  • the mainstream adjustment method is realized through gravity sensing.
  • Some mobile terminals have a built-in gravity sensor, which measures the acceleration caused by the movement of the mobile terminal through the gravity sensor, so as to calculate the tilt angle of the mobile terminal relative to the horizontal plane, and then adjust the image accordingly according to the tilt angle.
  • the method to adjust the image direction requires an additional gravity sensor, which increases the cost of image direction adjustment.
  • Embodiments of the present application provide an image orientation adjustment method, device, storage medium, and electronic equipment, which can adjust the image orientation to the positive orientation without adding an additional gravity sensor, saving the cost of image orientation adjustment.
  • This technical scheme is as follows:
  • an embodiment of the present application provides a method for adjusting an image direction, the method including:
  • the object detection model is obtained by training based on forward target object sample images and non-positive target object sample images;
  • an embodiment of the present application provides a method for adjusting an image direction, the method comprising:
  • the four images include a forward target object image
  • the object detection model is based on the forward target object
  • the sample image and the sample image of the non-positive target object are trained;
  • an image orientation adjustment device comprising:
  • An image acquisition module configured to acquire the first image collected by the camera for the subject
  • An image rotation module configured to rotate the first image according to different specified angles to obtain a second image, a third image, and a fourth image, wherein the first image, the second image, and the first image
  • the three images and the fourth image include a forward target object image
  • a probability value determination module configured to obtain object probability values corresponding to the first image, the second image, the third image, and the fourth image by using a pre-trained object detection model, and determine the object probability The maximum probability value in the value, the object detection model is obtained based on the training of the forward target object sample image and the non-positive target object sample image;
  • a direction adjustment module configured to identify the rotation angle of the target image indicated by the maximum probability value, and adjust the display direction of the first image based on the rotation angle.
  • the embodiment of the present application provides an image orientation adjustment device, the device comprising:
  • a camera opening module configured to receive a shooting instruction, and turn on the camera in response to the shooting instruction
  • a picture display module configured to display the first image collected by the camera for the shooting object
  • the image rotation module is used to rotate the first image according to different specified angles to obtain a second image, a third image, and a fourth image, wherein the first image, the second image, and the The third image and the fourth image include a forward target object image;
  • a probability value determination module configured to output object probability values corresponding to the first image, the second image, the third image, and the fourth image respectively obtained by using a pre-trained object detection model, the object
  • the detection model is trained based on the sample image of the forward target object and the sample image of the non-positive target object;
  • a direction adjustment module configured to determine the maximum probability value among the object probability values, identify the rotation angle of the target image indicated by the maximum probability value, adjust the display direction of the first image based on the rotation angle, and display the adjusted after the first image.
  • an embodiment of the present application provides a computer storage medium, where a plurality of instructions are stored in the computer storage medium, and the instructions are adapted to be loaded by a processor and execute the above-mentioned method steps.
  • an embodiment of the present application provides an electronic device, which may include: a processor and a memory; wherein, the memory stores a computer program, and the computer program is adapted to be loaded by the processor and execute the above-mentioned method steps .
  • the mobile terminal obtains the first image captured by the camera for the subject, and rotates the first image according to different specified angles to obtain the second image, the third image, and the fourth image.
  • the object detection model obtains the object probability values corresponding to the first image, the second image, the third image, and the fourth image, and determines the maximum probability value among the object probability values, because the pre-trained object detection model is based on the forward target object sample images and non-forward target object sample images, then the image corresponding to the maximum probability value obtained by using the trained object detection model is the forward target object image, and then identify the rotation of the target image indicated by the maximum probability value Angle, adjust the display direction of the first image based on the rotation angle, so that the direction of the final displayed image can be positive, so as to conform to the user's usage habits and facilitate the user's use. During this process, no additional gravity is required sensor, saving the cost of image orientation adjustment.
  • FIG. 1 is a schematic flow chart of an image orientation adjustment method provided in an embodiment of the present application
  • Fig. 2a is a schematic structural diagram of an image orientation adjustment system provided by an embodiment of the present application.
  • Fig. 2b is a schematic structural diagram of another image orientation adjustment system provided by an embodiment of the present application.
  • Fig. 3a is a schematic diagram of an example of a first image provided by an embodiment of the present application.
  • Fig. 3b is an example schematic diagram of another first image provided by the embodiment of the present application.
  • Fig. 4 is a schematic diagram of an example of image size conversion provided by an embodiment of the present application.
  • Fig. 5 is a schematic diagram of an example of a first image, a second image, a third image, and a fourth image provided by an embodiment of the present application;
  • Fig. 6 is a schematic diagram of an example before and after image direction adjustment provided by the embodiment of the present application.
  • FIG. 7 is a schematic flowchart of a method for adjusting an image direction provided by an embodiment of the present application.
  • Fig. 8 is a schematic diagram of an example of a prompt information display interface provided by an embodiment of the present application.
  • FIG. 9 is a schematic flowchart of a method for adjusting an image direction provided by an embodiment of the present application.
  • FIG. 10 is a schematic diagram of an example of enabling a camera function provided by an embodiment of the present application.
  • Fig. 11 is a schematic diagram of an example of a prompt information display interface provided by an embodiment of the present application.
  • FIG. 12 is a schematic structural diagram of an image orientation adjustment device provided in an embodiment of the present application.
  • FIG. 13 is a schematic structural diagram of an image orientation adjustment device provided in an embodiment of the present application.
  • Fig. 14 is a schematic structural diagram of a direction adjustment module provided by an embodiment of the present application.
  • Fig. 15 is a schematic structural diagram of an image orientation adjustment device provided by an embodiment of the present application.
  • Fig. 16 is a schematic structural diagram of an image orientation adjustment device provided by an embodiment of the present application.
  • Fig. 17 is a schematic structural diagram of a direction adjustment module provided by an embodiment of the present application.
  • FIG. 18 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • the method can be implemented relying on a computer program, and can run on an image orientation adjustment device based on the von Neumann system.
  • the computer program can be integrated in the application, or run as an independent utility application.
  • the image orientation adjustment device in the embodiment of the present application may be a mobile terminal, including but not limited to: personal computer, tablet computer, handheld device, vehicle-mounted device, wearable device, computing device or other processing device connected to a wireless modem, etc. .
  • User terminals can be called by different names in different networks, for example: user equipment, access terminal, subscriber unit, subscriber station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication Equipment, user agent or user device, cellular phone, cordless phone, personal digital assistant (PDA), terminal equipment in 5G network or future evolution network, etc.
  • PDA personal digital assistant
  • This method includes but is not limited to application to student learning machines.
  • This learning machine refers to a tablet computer that is generally used for students to take online classes or conduct other learning projects. It has a camera set on the top of the learning machine and has a shooting function.
  • FIG. 1 provides a schematic flowchart of a method for adjusting an image direction according to an embodiment of the present application.
  • a learning machine is taken as an example for description, and the image direction adjustment method may include the following steps:
  • the camera includes a camera, and the camera can be a device that communicates with the learning machine in a wireless or wired manner, wherein the wireless way for the learning machine to communicate with the camera includes but is not limited to, for example, a cellular network, a wireless local area network, Infrared network, near-field communication network or Bluetooth network, etc., wired methods include but not limited to Universal Serial Bus (Universal Serial Bus, USB).
  • USB Universal Serial Bus
  • the camera can also be a part of the learning machine, that is, a device installed on the camera of the learning machine.
  • the shooting object can be any object that the user wants to shoot, for example, it can include animals, people, books, etc., and can include one or more.
  • the first image may be a pre-browsing image captured by the camera of the camera based on the shooting picture, or may be a pre-browsing image obtained based on the capturing of the shooting picture by the camera installed on the learning machine in response to the shooting instruction of the learning machine.
  • the first image can be displayed on the screen.
  • the user triggers to turn on the camera of the learning machine, and the camera of the learning machine collects images of the subject to obtain the first image.
  • the acquisition of the first image by the learning machine can be based on a preset timing acquisition mechanism, for example, acquisition in the second second after the camera is turned on, or it can be acquired in a preset certain step length (eg, once every 2 seconds).
  • the image direction of the first image is forward, as shown in Figure 3a, the first image displayed in the avatar area of the sidebar of the learning machine in the figure is a forward image, in this case, it is not necessary to adjust the image direction Adjustment.
  • the first image is an image rotated by a certain angle or an image not rotated with the device.
  • the learning machine The first image is an image rotated by a certain angle before adjustment.
  • the first image can also be resized according to a certain ratio without changing the aspect ratio, for example: if the initial size ratio of the image is M ⁇ N, reduce the image without changing the aspect ratio size, so as to transform it into M0 ⁇ N0, if there is a vacant area after the transformation, fill in 0 pixels, and obtain the first image I0 with the size of M0 ⁇ N0, as shown in Figure 4. Therefore, under the condition that the image information is not lost, the size of the image can be reduced, thereby reducing the amount of calculation.
  • a certain ratio without changing the aspect ratio for example: if the initial size ratio of the image is M ⁇ N, reduce the image without changing the aspect ratio size, so as to transform it into M0 ⁇ N0, if there is a vacant area after the transformation, fill in 0 pixels, and obtain the first image I0 with the size of M0 ⁇ N0, as shown in Figure 4. Therefore, under the condition that the image information is not lost, the size of the image can be reduced, thereby reducing the amount of calculation.
  • the solution provided by the embodiment of the present application adjusts the display direction of the image based on the analysis of the content of the image. It needs a forward target object image as a basis. In order to facilitate the detection of the direction of the target object in the first image, the first image is divided into Rotate by the specified angle.
  • the first image is an image of the target object facing a horizontal direction or a vertical direction
  • different specified angles may be 90°, 180° and 270°.
  • the second image, the third image and the fourth image obtained after rotating the first image by 90°, 180° and 270° respectively are shown in FIG. 5 , wherein the first image is the image of the forward target object.
  • angles that rotate in the same direction such as clockwise or counterclockwise.
  • the resized first image is correspondingly rotated according to different specified angles to obtain a second image, a third image and a fourth image having the same size as the first image.
  • the object detection model is generated based on training of positive target object sample images and non-positive target object sample images, specifically, it can be a classifier for a two-class classification problem.
  • the probability value that the target object in the image is positive is output, that is, the object probability value.
  • the sample image of the forward target object may be a forward image of any target object.
  • the target object can be any object that the user wants to identify, such as animals, people, and books.
  • the sample image of the non-forward target object can be any image except the forward target object.
  • the non-direct target object can be any object except user 1, such as user 2, cat, dog, etc.
  • the first image, the second image, the third image and the fourth image are identified using a pre-trained object detection model, thereby obtaining the first image, the second image, the third image and the The object probability values corresponding to the fourth images respectively, and determine the maximum probability value, because the image indicated by the maximum probability value has the highest probability of being the image of the forward target object, and the first image, the second image, the third image and the fourth image includes a forward target object image, so it can be determined that the image indicated by the maximum probability value is the forward target object image.
  • the target image indicated by the maximum probability value is one of the first image, the second image, the third image, and the fourth image.
  • the rotation angle of the image is used as the first image. The rotation angle of the image.
  • the target image is the first image, then determine that the rotation angle is 0°; if the target image is the second image, then determine that the rotation angle is the rotation angle of the second image (ie 90°), and so on.
  • the basis for determining the rotation angle is the mapping relationship between the angle and the image.
  • the first image is rotated according to the rotation angle, so as to adjust the display direction of the first image.
  • the rotation angle is 0°, it means that the target image is the first image, that is, the first image is the image of the forward target object, then keep the display direction of the first image unchanged; if the rotation angle is the rotation angle of the second image , it means that the target image is the second image, that is, the second image is the forward target object image, then the angle of the first image is adjusted according to the rotation angle of the second image, and so on.
  • the target image is the forward target object image obtained by rotating the first image according to a certain angle
  • the learning machine acquires the first image captured by the camera for the subject, and when the first image includes the target object, the first image is rotated according to different specified angles to obtain the second image, the third image and For the fourth image, use the pre-trained object detection model to identify the first image, the second image, the third image and the fourth image to obtain the corresponding object probability values, and determine the maximum probability value of the object probability value, because the pre-trained
  • the object detection model is trained based on the sample image of the forward target object and the sample image of the non-positive target object. If the object probability value obtained by using the trained object detection model is the largest, the image corresponding to the maximum probability value can be considered as the forward target.
  • An object image identifying a rotation angle of the target image indicated by the maximum probability value, and adjusting a display direction of the first image based on the rotation angle.
  • the technical solution provided by the embodiment of the present application is based on adjusting the image direction of the image content, and the image direction can be adjusted to the positive direction without adding an additional gravity sensor, which saves the cost of image direction adjustment.
  • FIG. 7 provides a schematic flowchart of an image adjustment method according to an embodiment of the present application.
  • a learning machine is taken as an example for description, and the image direction adjustment may include the following steps:
  • the sample image of the forward target object may be a forward image of any target object.
  • the target object can be any object that the user wants to shoot, for example, it can include animals, people, books, etc., and can include one or more.
  • the sample image of the non-positive target object can be any In the image, for example, the target object is user 1, then the non-direct target object can be any object except user 1, such as user 2, cat, dog, etc.
  • Collect sample images of positive target objects and sample images of non-positive target objects to provide material basis for subsequent training of the object detection model.
  • it is necessary to ensure that the sample images of positive target objects and non-positive The amount of positive target object sample images is sufficiently large.
  • the object detection model can be based on conventional face detection networks such as retinaface and mtcnn, or can combine different deep learning blocks to form a network for training. In this way, a classifier that detects whether there is a target object in the image and outputs a corresponding object probability value is obtained.
  • the training samples are a sample image of a positive target object and a sample image of a non-positive target object.
  • the trained object detection model when used to identify the direction of the target object in the image, the corresponding object probability value is output, and a probability threshold is set in advance according to the training result, and the probability threshold is combined with the object probability value output by the object detection model. If the maximum probability value is less than the probability threshold, it means that the target object is not included in the image; if the maximum probability value is greater than or equal to the probability threshold, it means that the target object is included in the image.
  • the maximum probability value is greater than the probability threshold, the larger the object probability value, the greater the probability that the image is a positive target object image; the smaller the probability value, the smaller the probability that the image is a positive target object image.
  • the first image collected by the camera on the learning machine for the subject is shown in Figure 3b.
  • the first image has been rotated, which does not match the direction of the user's actual needs, which is inconvenient for the user. use.
  • the first image is rotated according to different specified angles to obtain the second image, the third image and the fourth image.
  • S102 which will not be repeated here.
  • the probability value that the image is a positive target object image can be obtained through the pre-trained object detection model.
  • the first image, the second image, the third image and the fourth image are identified using a pre-trained object detection model, and the first image, the second image, the third image and the fourth image are obtained.
  • the object probability values corresponding to the four images such as P1, P2, P3, P4, and determine the maximum probability value in P1, P2, P3, P4, because the image indicated by the maximum probability value has the highest probability of being the forward target object image, so It may be determined that the fourth image with the maximum probability value indicated by P4 is the forward target object image.
  • the obtained maximum probability value is greater than or equal to the probability threshold, based on the settings of the object detection model in the creation and training process, it can be considered that the image includes the target object, and because the image indicated by the maximum probability value can be considered as the positive target object image, Therefore, it is determined that the image indicated by the maximum probability value is the target image, and the target image is one of the first image, the second image, the third image, and the fourth image.
  • the target image determined based on the maximum probability value is the first image
  • the rotation angle of the first image is 0° compared to the first image
  • the rotation angle is determined to be 0°
  • the first image itself is considered to be the forward target object image
  • the rotation angle is determined to be the rotation angle of the second image, and the first image is rotated according to the rotation angle of the second image The rotation angle is adjusted so that the first image is the image of the forward target object.
  • the target image is the third image
  • determine that the rotation angle is the rotation angle of the third image
  • the rotation angle is determined to be the rotation angle of the third image, and the first image is rotated according to the rotation angle of the third image The rotation angle is adjusted so that the first image is the image of the forward target object.
  • the rotation angle is determined to be the rotation angle of the fourth image, and the first image is rotated according to the rotation angle of the fourth image.
  • the rotation angle is adjusted so that the first image is the image of the forward target object.
  • the maximum probability value is less than the probability threshold, based on the settings of the object detection model during creation and training, it can be considered that the target image is not included in the image, and a specified value is output, and the specified value is used to indicate that there is no target object in the first image.
  • the specified value can be any number, letter or symbol, etc., which can be set in advance during the training of the object detection model. For example, if the specified value is set to -1 during training, then if the maximum probability value is less than the probability threshold, the specified value is output -1 means that there is no target object in the first image.
  • the camera After the object detection model outputs the specified value indicating that there is no target object in the first image, the camera is triggered to acquire the next frame of image collected for the subject again, and the next frame of image is used as the new first image for detection, and the first image is executed.
  • An image is rotated according to different specified angles to obtain the second image, the third image and the fourth image, and the steps of S205-S213 are continued to obtain the first image adjusted to the forward target object image.
  • a prompt message is output to prompt the user to detect the shooting angle of the camera.
  • the preset number of frames may be 3 frames, 4 frames, etc., and the specific number is not limited.
  • the prompt information can be output in the form of audio, text or animation, or multiple ways in parallel, and the specific ways and contents are not limited.
  • a feasible prompting method may be a text box prompt, a text box pops up, and the content of the text box is "no portrait is recognized in the current image, please take a new photo".
  • the possible faults of the camera include but are not limited to: the camera is damaged, the camera is blocked by other objects, and so on.
  • the objects that exist at the shooting angle of the camera include but are not limited to: the target object cannot be captured at the current shooting angle of the camera, and the wrong camera is used, for example, the rear camera is used instead of the front camera.
  • the front camera can be a camera placed on the upper end of the panel where the display screen of the learning machine is located.
  • the rear camera may be a camera placed on the back panel of the learning machine.
  • the first image when the first image includes the target object, the first image is rotated according to different angles to obtain four images including a forward target object image, and the pre-trained object detection model is used to obtain four images.
  • the object probability value corresponding to each image determine the rotation angle of the target image based on the maximum probability value, and adjust the display direction of the first image based on the rotation angle; if the maximum probability value is less than the preset threshold, it means that there is no object in the first image target object, re-acquire the next frame of image as the first image for identification, and finally obtain the first image whose display direction is positive.
  • the technical solution provided by the embodiment of the present application is to analyze and adjust the image direction based on the image content, which can The image direction can be adjusted to the positive direction without adding an additional gravity sensor, which saves the cost of image direction adjustment.
  • FIG. 9 provides a schematic flowchart of a method for adjusting an image direction according to an embodiment of the present application.
  • the embodiment of the present application is described on the learning machine side, and the image direction adjustment method may include the following steps:
  • the camera can be a device that communicates with the learning machine in a wireless or wired manner, and as shown in Figure 2b, the camera can also be a part of the learning machine, that is, a device installed on the learning machine.
  • the learning machine when the user triggers the learning machine to turn on the shooting function of the camera, the learning machine sends a shooting command, and when the learning machine receives the shooting command, it responds to the shooting command and turns on The shooting function of the camera, the camera is aimed at the subject to shoot.
  • the shooting object can be any object that the user wants to shoot, for example, it can include animals, people, books, etc., and can also include one or more.
  • the first image refers to the first image obtained by the camera in response to the start shooting instruction sent by the learning machine based on the acquisition of the shooting picture.
  • the first image may be a pre-browsing image captured by the camera of the camera based on the shooting picture, or may be a pre-browsing image obtained based on the capturing of the shooting picture by the camera installed on the learning machine in response to the shooting instruction of the learning machine.
  • the first image can be displayed on the screen.
  • the first image collected by the camera is displayed in the avatar area of the learning machine, and a prompt message is displayed to prompt the user whether to enable the direction detection of the target object, and the user can choose according to the actual situation.
  • the prompt information may be output in the form of audio, text, or animation, or in parallel in multiple ways, and the specific ways and contents are not limited.
  • a feasible prompting method may be a text box prompt, a text box pops up, and the content of the text box is "whether to enable image orientation detection".
  • S304 Receive a confirmation instruction for the target object in the prompt information, and enable a function of detecting the direction of the target object in response to the confirmation instruction;
  • the method of clicking the button depends on the specific conditions of the learning machine. If the learning machine is a touch screen, you can directly click with your fingers; if the learning machine supports voice control, you can also use voice to select options; if the learning machine supports mouse control, You can use the mouse to operate.
  • the technical solution provided by the embodiment of the present application is to adjust the display direction of the image based on the analysis of the content of the image.
  • a forward target object image is required as a basis.
  • the first The image is rotated by a different specified angle.
  • the pre-trained object detection model can be a classifier based on the two-class classification problem trained based on the sample image of the forward target object and the sample image of the non-positive target object.
  • the probability value of the image is the image of the forward target object, and the probability value The larger the , the more likely the image is the image of the forward target object.
  • the maximum probability value is determined by using the object probability value of the image acquired by the pre-trained object detection model. For details, refer to S205, which will not be repeated here.
  • the object probability value may be a probability value that the image includes a forward target object.
  • the probability threshold may be a threshold set according to the training effect during the training process of the object detection model.
  • the maximum probability value is greater than or equal to the probability threshold, it can be considered that the image includes the target object.
  • the second image, the third image, and the fourth image are obtained by rotating the first image according to different specified angles.
  • the four images include a forward target object image, and the pre-trained object detection model is used to obtain the four images.
  • the object probability value, the image indicated by the maximum probability value can be considered as the forward target object image, and the indicated image is used as the target image to determine the rotation angle of the target image.
  • the target image is the first image, determine the rotation angle as 0°; if the target image is the second image, determine the rotation angle as the rotation angle of the second image, and so on.
  • the target direction of the first image After determining the rotation angle of the target image, determine the target direction of the first image based on the rotation angle of the target image, because the target image is a positive target object image obtained by rotating the first image according to the specified angle, so the display direction of the target image is considered to be
  • the first image is to be adjusted to face the target direction of the target object image
  • the obtained maximum probability value is greater than or equal to the probability threshold, based on the settings of the object detection model in the creation and training process, it can be considered that the image includes the target object, and because the image indicated by the maximum probability value can be considered as the positive target object image, Therefore, it is determined that the image indicated by the maximum probability value is the target image.
  • the target image is the first image
  • the first image is the forward target object image
  • the rotation angle of the first image is 0° compared with the first image, and there is no need to adjust the display direction of the first image, so the first image is maintained
  • the display orientation of is unchanged, and the first image is displayed.
  • the rotation angle is determined to be the rotation angle of the second image, and the display direction of the first image is adjusted according to the rotation angle of the second image, and The adjusted first image is displayed.
  • the rotation angle is determined to be the rotation angle of the third image, and the display direction of the first image is adjusted according to the rotation angle of the third image, and The adjusted first image is displayed.
  • the rotation angle is determined to be the rotation angle of the fourth image, and the display direction of the first image is adjusted according to the rotation angle of the fourth image, and The adjusted first image is displayed.
  • the maximum probability value is less than the probability threshold, based on the settings of the object detection model during creation and training, it can be considered that the target image is not included in the image, and a specified value is output, and the specified value is used to indicate that there is no target object in the first image.
  • the specified value can be any number, letter or symbol, etc., which can be set in advance during the training of the object detection model. For example, if the specified value is set to -1 during training, then if the maximum probability value is less than the probability threshold, the specified value is output -1 means that there is no target object in the first image.
  • the camera After the object detection model outputs the specified value indicating that there is no target object in the first image, the camera is triggered to acquire the next frame of image collected for the subject again, and the next frame of image is used as the new first image for detection, and the first image is executed.
  • An image is rotated according to different specified angles to obtain the second image, the third image and the fourth image, and the steps of S306-S315 are continued to obtain the first image adjusted to the forward target object image.
  • a prompt message is output to prompt the user to detect the shooting angle of the camera.
  • the prompt information can be outputted in the form of audio, text or animation, and multiple ways can be used in parallel, and the specific ways and contents are not limited.
  • a feasible prompting method may be a text box prompt, a text box pops up, and the content of the text box is "no portrait is recognized in the current image, please take a new photo".
  • the possible faults of the camera include but are not limited to: the camera is damaged, the camera is blocked by other objects, and so on.
  • the objects that exist at the shooting angle of the camera include but are not limited to: the target object cannot be captured at the current shooting angle of the camera, the wrong camera is used, for example, the rear camera is used instead of the front camera, etc.
  • the front camera can be a camera placed on the upper end of the panel where the display screen of the learning machine is located.
  • the rear camera may be a camera placed on the back panel of the learning machine.
  • the learning machine turns on the camera to obtain the first image and displays it for processing.
  • a pop-up window prompts the user to confirm to turn on the detection, and turns on the detection after receiving the confirmation command Function, through the object detection model to obtain the object probability values of the second image, the third image and the fourth image obtained by rotating the first image at a specified angle, when the maximum probability value is greater than or equal to the probability threshold, identify the target image based on the maximum probability value Rotation angle of the first image, and adjust the display direction of the first image to display the adjusted first image; when the maximum probability value is less than the probability threshold, it means that there is no target object in the first image, then re-acquire the next frame of image as the first image One image is recognized.
  • the user is prompted to check the camera and its shooting angle, and the image is acquired again for detection, so as to finally obtain the first image whose display direction is positive.
  • This application implements The technical solution provided by the example is to analyze and adjust the image direction based on the image content, and the image direction can be adjusted to the positive direction without adding an additional gravity sensor, which saves the cost of image direction adjustment.
  • FIG. 12 shows a schematic structural diagram of image direction adjustment provided by an exemplary embodiment of the present application.
  • the device for adjusting the image direction can be implemented as all or a part of the terminal through software, hardware or a combination of the two.
  • the device 1 includes an image acquisition module 11 , an image rotation module 12 , a probability value determination module 13 and a direction adjustment module 14 .
  • An image acquisition module 11 configured to acquire the first image collected by the camera for the object to be photographed
  • the image rotation module 12 is used to rotate the first image according to different specified angles to obtain the second image, the third image and the fourth image, wherein the first image, the second image, the third image and the fourth image Include a positive target object image;
  • the probability value determination module 13 is used to obtain the object probability values corresponding to the first image, the second image, the third image and the fourth image respectively by using the pre-trained object detection model, and determine the maximum probability value in the object probability values, and the object detection
  • the model is trained based on the sample image of the forward target object and the sample image of the non-positive target object;
  • the direction adjustment module 14 is configured to identify the rotation angle of the target image indicated by the maximum probability value, and adjust the display direction of the first image based on the rotation angle.
  • the device 1 further includes:
  • a sample collection module 15 configured to collect a forward target object sample image and a non-positive target object sample image
  • the model training module 16 is used to create an initial object detection model, and train the initial object detection model based on the forward target object sample image and the non-positive target object sample image to obtain a trained object detection model.
  • the direction adjustment module 14 is specifically used for:
  • the direction adjustment module 14 includes:
  • An image determining unit 141 configured to determine the target image indicated by the maximum probability value
  • a direction adjustment unit 142 configured to determine that the rotation angle is 0° if the target image is the first image, and keep the display direction of the first image unchanged;
  • the direction adjusting unit 142 is further configured to determine the rotation angle as the rotation angle of the second image if the target image is the second image, and adjust the rotation angle of the second image according to the rotation angle of the second image. adjusting the display direction of the first image;
  • the direction adjusting unit 142 is further configured to determine the rotation angle as the rotation angle of the third image if the target image is the third image, and adjust the rotation angle of the third image according to the rotation angle of the third image. adjusting the display direction of the first image;
  • the direction adjustment unit 142 is further configured to determine the rotation angle as the rotation angle of the fourth image if the target image is the fourth image, and adjust the rotation angle of the fourth image according to the rotation angle of the fourth image. The display orientation of the first image is adjusted.
  • the device 1 further includes:
  • a specified value output module 17 configured to output a specified value when the maximum probability value is smaller than the probability threshold, the specified value indicating that there is no target object in the first image.
  • the image acquisition module 11 is further configured to acquire the next frame of image collected by the camera for the subject, use the next frame of image as the first image, and trigger the image rotation module 12
  • the first image is rotated respectively according to different specified angles to obtain the second image, the third image and the fourth image.
  • the device further includes an information output module 18, configured to output a prompt message of camera failure when there is no target object in the first images of the preset number of frames collected continuously , the prompt information is used to prompt the user to adjust the shooting angle of the camera.
  • an information output module 18 configured to output a prompt message of camera failure when there is no target object in the first images of the preset number of frames collected continuously , the prompt information is used to prompt the user to adjust the shooting angle of the camera.
  • the first image when the first image includes the target object, the first image is rotated according to different angles to obtain four images including a forward target object image, and the pre-trained object detection model is used to obtain four images.
  • the object probability value corresponding to each image determine the rotation angle of the target image based on the maximum probability value, and adjust the display direction of the first image based on the rotation angle; if the maximum probability value is less than the preset threshold, it means that there is no object in the first image target object, re-acquire the next frame of image as the first image for identification, and finally obtain the first image whose display direction is positive.
  • the technical solution provided by the embodiment of the present application is to analyze and adjust the image direction based on the image content, which can The image direction can be adjusted to the positive direction without adding an additional gravity sensor, which saves the cost of image direction adjustment.
  • FIG. 15 shows a schematic structural diagram of an image orientation adjustment device provided by an exemplary embodiment of the present application.
  • the device 2 includes a camera opening module 21 , a picture display module 22 , an image rotation module 23 , a probability value determination module 24 , and a direction adjustment module 25 .
  • the camera opening module 21 is configured to receive a shooting instruction, and open the camera in response to the shooting instruction;
  • a picture display module 22 configured to display the first image collected by the camera for the subject
  • An image rotation module 23 configured to rotate the first image according to different specified angles to obtain a second image, a third image and a fourth image, wherein the first image, the second image, the The third image and the fourth image include a forward target object image;
  • a probability value determination module 24 configured to output the object probability values corresponding to the first image, the second image, the third image, and the fourth image respectively obtained by using a pre-trained object detection model, the The object detection model is trained based on the sample image of the forward target object and the sample image of the non-positive target object;
  • a direction adjustment module 25 configured to determine the maximum probability value among the object probability values, and identify the rotation angle of the target image indicated by the maximum probability value, adjust the display direction of the first image based on the rotation angle, and and displaying the adjusted first image.
  • the device 2 further includes:
  • the detection prompt display module 26 is used to display whether to open the prompt information for direction detection of the target object
  • the detection and activation module 27 is configured to receive a confirmation instruction for the prompt information, and respond to the confirmation instruction to enable the function of detecting the direction of the target object.
  • the device 2 further includes:
  • a specified value output module 28 configured to output a specified value when the maximum probability value is less than the probability threshold, the specified value indicating that there is no target object in the first image.
  • the image acquisition module 22 is also configured to acquire the next frame of image collected by the camera for the subject, use the next frame of image as the first image, and trigger the image rotation module 23
  • the first image is rotated respectively according to different specified angles to obtain the second image, the third image and the fourth image.
  • the device further includes an information output module 29, configured to output a prompt message of camera failure when there is no target object in the first images of the preset number of frames collected continuously , the prompt information is used to prompt the user to check the camera and its shooting angle.
  • an information output module 29 configured to output a prompt message of camera failure when there is no target object in the first images of the preset number of frames collected continuously , the prompt information is used to prompt the user to check the camera and its shooting angle.
  • the direction adjustment module 25 is specifically used for:
  • the angle adjustment unit 25 includes:
  • a direction adjustment unit 252 configured to keep the display direction of the first image unchanged and display the first image if the target image is the first image;
  • the direction adjustment unit 252 is further configured to adjust the display direction of the first image according to the rotation angle of the second image if the target image is the second image, and display the adjusted the first image;
  • the direction adjusting unit 252 is further configured to adjust the display direction of the first image according to the rotation angle of the third image if the target image is the third image, and display the adjusted the first image;
  • the direction adjustment unit 252 is further configured to adjust the display direction of the first image according to the rotation angle of the fourth image if the target image is the fourth image, and display the adjusted Describe the first image.
  • the learning machine turns on the camera to obtain the first image and displays it for processing.
  • a pop-up window prompts the user to confirm to turn on the detection, and turns on the detection after receiving the confirmation command Function, through the object detection model to obtain the object probability values of the second image, the third image and the fourth image obtained by rotating the first image at a specified angle, when the maximum probability value is greater than or equal to the probability threshold, identify the target image based on the maximum probability value Rotation angle of the first image, and adjust the display direction of the first image to display the adjusted first image; when the maximum probability value is less than the probability threshold, it means that there is no target object in the first image, then re-acquire the next frame of image as the first image One image is recognized.
  • the user is prompted to check the camera and its shooting angle, and the image is acquired again for detection, so as to finally obtain the first image whose display direction is positive.
  • This application implements The technical solution provided by the example is to analyze and adjust the image direction based on the image content, and the image direction can be adjusted to the positive direction without adding an additional gravity sensor, which saves the cost of image direction adjustment.
  • the image orientation adjustment device provided in the above-mentioned embodiments executes the image orientation adjustment method
  • the division of the above-mentioned functional modules is used as an example for illustration.
  • the above-mentioned functions can be assigned to different function modules as required Module completion means that the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.
  • the image orientation adjustment device and the image orientation adjustment method embodiment provided by the above embodiment belong to the same idea, and the implementation process thereof is detailed in the method embodiment, and will not be repeated here.
  • the embodiment of the present application also provides a computer storage medium, the computer storage medium can store a plurality of instructions, and the instructions are suitable for being loaded by the processor and executing the method steps of the above-mentioned embodiments shown in Figures 1-11
  • the specific execution process refer to the specific description of the embodiments shown in FIGS. 1-11 , and details are not repeated here.
  • the present application also provides a computer program product, the computer program product stores at least one instruction, and the at least one instruction is loaded by the processor and executes the specific descriptions of the embodiments shown in FIGS. 1-11 above.
  • the processor executes the specific descriptions of the embodiments shown in FIGS. 1-11 above.
  • the mobile terminal 1000 may include: at least one processor 1001 , at least one network interface 1004 , a user interface 1003 , a memory 1005 , and at least one communication bus 1002 .
  • the communication bus 1002 is used to realize connection and communication between these components.
  • the user interface 1003 may include a display screen (Display) and a camera (Camera), and the optional user interface 1003 may also include a standard wired interface and a wireless interface.
  • Display display screen
  • Camera Camera
  • the optional user interface 1003 may also include a standard wired interface and a wireless interface.
  • the network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).
  • the processor 1001 may include one or more processing cores.
  • the processor 1001 uses various interfaces and lines to connect various parts of the entire electronic device 1000, and by running or executing instructions, programs, code sets or instruction sets stored in the memory 1005, and calling data stored in the memory 1005, execute Various functions of the electronic device 1000 and processing data.
  • the processor 1001 may use at least one of Digital Signal Processing (Digital Signal Processing, DSP), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA), and Programmable Logic Array (Programmable Logic Array, PLA). implemented in the form of hardware.
  • DSP Digital Signal Processing
  • FPGA Field-Programmable Gate Array
  • PLA Programmable Logic Array
  • the processor 1001 may integrate one or a combination of a central processing unit (Central Processing Unit, CPU), an image processor (Graphics Processing Unit, GPU) and a modem.
  • CPU Central Processing Unit
  • GPU Graphics Processing Unit
  • the CPU mainly handles the operating system, user interface and application programs, etc.
  • the GPU is used to render and draw the content that needs to be displayed on the display screen
  • the modem is used to handle wireless communication. It can be understood that the above modem may also not be integrated into the processor 1001, but implemented by a single chip.
  • the memory 1005 may include a random access memory (Random Access Memory, RAM), and may also include a read-only memory (Read-Only Memory).
  • the memory 1005 includes a non-transitory computer-readable storage medium (non-transitory computer-readable storage medium). The memory 1005 may be used to store instructions, programs, codes, sets of codes or sets of instructions.
  • the memory 1005 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), Instructions and the like for implementing the above method embodiments; the storage data area can store the data and the like involved in the above method embodiments.
  • the memory 1005 may also be at least one storage device located away from the aforementioned processor 1001 .
  • the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and an image orientation adjustment application program.
  • the user interface 1003 is mainly used to provide the user with an input interface to obtain the data input by the user; and the processor 1001 can be used to call the generated image orientation adjustment application program stored in the memory 1005, And specifically do the following:
  • the object detection model is obtained by training based on forward target object sample images and non-positive target object sample images;
  • the processor 1001 executes acquiring the first image captured by the camera for the subject, the following operations are further performed:
  • An initial object detection model is created, and the initial object detection model is trained based on the sample image of the forward target object and the sample image of the non-positive target object to obtain a trained object detection model.
  • the processor 1001 identifies the rotation angle of the target image indicated by the maximum probability value, determines the target direction of the first image based on the rotation angle, and determines the target direction of the first image based on the rotation angle of the target image indicated by the maximum probability value.
  • adjusting the display direction of the first image specifically perform the following operations:
  • the maximum probability value is greater than or equal to a probability threshold, identifying a rotation angle of the target image indicated by the maximum probability value, and adjusting a display direction of the first image based on the rotation angle.
  • the processor 1001 when the processor 1001 identifies the rotation angle of the target image indicated by the maximum probability value, and adjusts the display direction of the first image based on the rotation angle, specifically perform the following operations:
  • the target image is the first image, then determine that the rotation angle is 0°, and keep the display direction of the first image unchanged;
  • the target image is the second image, determining that the rotation angle is the rotation angle of the second image, and adjusting the display direction of the first image according to the rotation angle of the second image;
  • the target image is the third image, determining that the rotation angle is the rotation angle of the third image, and adjusting the display direction of the first image according to the rotation angle of the third image;
  • the processor 1001 also performs the following operations:
  • the processor 1001 outputs a specified value when the maximum probability value is smaller than the probability threshold, and the specified value indicates that there is no target object in the first image, the processing The device 1001 also performs the following operations:
  • the processor 1001 when the processor 1001 executes acquiring the next frame of image captured by the camera for the subject, using the next frame of image as the first image, and executing the When the first image is rotated according to different specified angles to obtain the second image, the third image and the fourth image, the processor 1001 further performs the following operations:
  • a prompt message of camera failure is output, and the prompt message is used to prompt the user to adjust the shooting angle of the camera.
  • processor 1001 also performs the following operations:
  • the four images include a forward target object image
  • the object detection model is based on the forward target object
  • the sample image and the sample image of the non-positive target object are trained;
  • the processor 1001 also performs the following operations:
  • a confirmation instruction for the prompt information is received, and a function of detecting the direction of the target object is turned on in response to the confirmation instruction.
  • the processor 1001 when the processor 1001 determines the target direction of the first image based on the maximum probability value, it specifically performs the following operations:
  • the processor 1001 also performs the following operations:
  • the processor 1001 outputs a specified value when the maximum probability value is smaller than the probability threshold, and the specified value indicates that there is no target object in the first image, the processing The device 1001 also performs the following operations:
  • the processor 1001 when the processor 1001 executes acquiring the next frame of image captured by the camera for the subject, using the next frame of image as the first image, and executing the When the first image is rotated according to different specified angles to obtain the second image, the third image and the fourth image, the processor 1001 further performs the following operations:
  • a prompt message of camera failure is output, and the prompt message is used to prompt the user to adjust the shooting angle of the camera.
  • the processor 1001 performs identifying the rotation angle of the target image indicated by the maximum probability value, adjusts the display direction of the first image based on the rotation angle, and displays the adjusted first image. For an image, perform the following operations:
  • the target image is the first image, keeping the display direction of the first image unchanged and displaying the first image;
  • the target image is the second image, adjusting the display direction of the first image according to the rotation angle of the second image, and displaying the adjusted first image;
  • the target image is the third image, adjusting the display direction of the first image according to the rotation angle of the third image, and displaying the adjusted first image;
  • the target image is the fourth image, adjusting the display direction of the first image according to the rotation angle of the fourth image, and displaying the adjusted first image.
  • the learning machine turns on the camera to obtain the first image and displays it for processing.
  • a pop-up window prompts the user to confirm to turn on the detection, and turns on the detection after receiving the confirmation command Function, through the object detection model to obtain the object probability values of the second image, the third image and the fourth image obtained by rotating the first image at a specified angle, when the maximum probability value is greater than or equal to the probability threshold, identify the target image based on the maximum probability value rotation angle of the first image, and adjust the display direction of the first image; when the maximum probability value is less than the probability threshold, it means that there is no target object in the first image, and then re-acquire the next frame image as the first image for identification.
  • the user is prompted to check the camera and its shooting angle, and the image is acquired again for detection, so as to finally obtain the first image whose display direction is positive.
  • the technical solution provided by the embodiment of this application is based on the image The content is analyzed and the image direction is adjusted, and the image direction can be adjusted to positive without adding an additional gravity sensor, which saves the cost of image direction adjustment.
  • the processes in the methods of the above embodiments can be implemented through computer programs to instruct related hardware, and the programs can be stored in a computer-readable storage medium. During execution, it may include the processes of the embodiments of the above-mentioned methods.
  • the storage medium may be a magnetic disk, an optical disk, a read-only memory or a random access memory, and the like.

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)

Abstract

Disclosed in the present application are an image direction adjustment method and apparatus, and a storage medium and an electronic device. The method comprises: acquiring a first image of a photographed subject that is captured by a camera; rotating the first image according to different designated angles to obtain a second image, a third image, and a fourth image; using a pre-trained object test model to respectively acquire object probability values corresponding to the first image, the second image, the third image, and the fourth image, and determining the maximum probability value among the object probability values, wherein the object test model is obtained by means of training based on a forward target object sample image and a non-forward target object sample image; and identifying the rotation angle of a target image that is indicated by the maximum probability value, and then adjusting the display direction of the first image on the basis of the rotation angle. By means of the present application, an image direction can be adjusted to be forward, without additionally adding a gravity sensor, thereby saving on the cost of the adjustment of the image direction.

Description

图像方向调整方法、装置、存储介质及电子设备Image orientation adjustment method, device, storage medium and electronic equipment
本申请要求于2021年8月16日提交中国专利局,申请号为202110940091.7、发明名称为“图像方向调整方法、装置、存储介质及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application with the application number 202110940091.7 and the title of the invention "image orientation adjustment method, device, storage medium and electronic equipment" submitted to the China Patent Office on August 16, 2021, the entire contents of which are incorporated by reference incorporated in this application.
技术领域technical field
本申请涉及计算机技术领域,尤其涉及一种图像方向调整方法、装置、存储介质及电子设备。The present application relates to the field of computer technology, and in particular to an image orientation adjustment method, device, storage medium and electronic equipment.
背景技术Background technique
移动终端在针对拍摄对象拍摄图像时,由于摄像头只负责拍摄,且拍摄应用不会考虑移动终端是否会进行旋转以做出相应的响应,这将出现当拍摄后移动终端进行了90°、180°或者270°等角度的旋转,而图像并不跟随旋转的情况,或者出现即使将摄像头正对着拍摄对象进行拍摄且拍摄后移动终端并不进行旋转,但拍摄到的图像依然发生90°、180°或者270°等角度的旋转的情况,而无法呈现拍摄对象为正向的图像。When the mobile terminal takes pictures of the subject, since the camera is only responsible for taking pictures, and the shooting application does not consider whether the mobile terminal will rotate to make a corresponding response, this will occur when the mobile terminal is rotated by 90°, 180° Or the rotation of 270° and other angles, but the image does not follow the rotation, or even if the camera is facing the subject to shoot and the mobile terminal does not rotate after shooting, the captured image still has 90°, 180° ° or 270° and other angles of rotation, it is impossible to present an image in which the subject is facing forward.
为了将图像调整为正向,现如今,主流的调整方式是通过重力感应实现的。一些移动终端内置有重力传感器,通过重力传感器测量因移动终端的动作改变而产生的加速度,从而计算出该移动终端相对于水平面的倾斜角度,再根据该倾斜角度对图像进行相应的调整,采用此方法进行图像方向的调整需要额外增加重力传感器,提高了图像方向调整的成本。In order to adjust the image to be positive, nowadays, the mainstream adjustment method is realized through gravity sensing. Some mobile terminals have a built-in gravity sensor, which measures the acceleration caused by the movement of the mobile terminal through the gravity sensor, so as to calculate the tilt angle of the mobile terminal relative to the horizontal plane, and then adjust the image accordingly according to the tilt angle. The method to adjust the image direction requires an additional gravity sensor, which increases the cost of image direction adjustment.
发明内容Contents of the invention
本申请实施例提供了一种图像方向调整方法、装置、存储介质及电子设备,可以不需要额外增加重力传感器就可以将图像方向调整为正向,节省了图像方向调整的成本。本技术方案如下:Embodiments of the present application provide an image orientation adjustment method, device, storage medium, and electronic equipment, which can adjust the image orientation to the positive orientation without adding an additional gravity sensor, saving the cost of image orientation adjustment. This technical scheme is as follows:
第一方面,本申请实施例提供了一种图像方向调整方法,所述方法包括:In the first aspect, an embodiment of the present application provides a method for adjusting an image direction, the method including:
获取摄像头针对拍摄对象采集的第一图像;Obtaining the first image collected by the camera for the subject;
将所述第一图像分别按照不同的指定角度进行旋转,得到第二图像、第三图像以及第四图像,其中,所述第一图像、所述第二图像、所述第三图像以及所述第四图像中包括一张正向目标物体图像;Rotating the first image according to different specified angles to obtain a second image, a third image and a fourth image, wherein the first image, the second image, the third image and the The fourth image includes a forward target object image;
采用预先训练的物体检测模型分别获取所述第一图像、所述第二图像、所述第三图像以及所述第四图像对应的物体概率值,确定所述物体概率值中的最大概率值,所述物体检测模型基于正向目标物体样本图像以及非正向目标物体样本图像训练得到;Obtaining object probability values corresponding to the first image, the second image, the third image, and the fourth image respectively by using a pre-trained object detection model, and determining a maximum probability value among the object probability values, The object detection model is obtained by training based on forward target object sample images and non-positive target object sample images;
识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向。Identifying the rotation angle of the target image indicated by the maximum probability value, and adjusting the display direction of the first image based on the rotation angle.
第二方面,本申请实施例提供了一种图像方向调整方法,所述方法包括:In a second aspect, an embodiment of the present application provides a method for adjusting an image direction, the method comprising:
接收拍摄指令,响应于所述拍摄指令,开启摄像头;receiving a shooting instruction, and turning on the camera in response to the shooting instruction;
显示所述摄像头针对拍摄对象采集的第一图像;displaying the first image collected by the camera for the subject;
将所述第一图像分别按照不同的指定角度进行旋转得到第二图像、第三图像以及第四图像,其中,所述第一图像、所述第二图像、所述第三图像以及所述第四图像中包括一张正向目标物体图像;Rotating the first image according to different specified angles to obtain a second image, a third image and a fourth image, wherein the first image, the second image, the third image and the first The four images include a forward target object image;
输出采用预先训练的物体检测模型分别获取的所述第一图像、所述第二图像、所述第三图像以及所述第四图像对应的物体概率值,所述物体检测模型基于正向目标物体样本图像以及非正向目标物体样本图像训练得到;Outputting the object probability values corresponding to the first image, the second image, the third image, and the fourth image respectively obtained by using a pre-trained object detection model, the object detection model is based on the forward target object The sample image and the sample image of the non-positive target object are trained;
确定所述物体概率值中的最大概率值,识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向,并显示调整后的所述第一图像。determining the maximum probability value among the object probability values, identifying the rotation angle of the target image indicated by the maximum probability value, adjusting the display direction of the first image based on the rotation angle, and displaying the adjusted first image image.
第三方面,本申请实施例提供了一种图像方向调整装置,所述装置包括:In a third aspect, an embodiment of the present application provides an image orientation adjustment device, the device comprising:
图像获取模块,用于获取摄像头针对拍摄对象采集的第一图像;An image acquisition module, configured to acquire the first image collected by the camera for the subject;
图像旋转模块,用于将所述第一图像分别按照不同的指定角度旋转,得到第二图像、第三图像以及 第四图像,其中,所述第一图像、所述第二图像、所述第三图像以及所述第四图像中包括一张正向目标物体图像;An image rotation module, configured to rotate the first image according to different specified angles to obtain a second image, a third image, and a fourth image, wherein the first image, the second image, and the first image The three images and the fourth image include a forward target object image;
概率值确定模块,用于采用预先训练的物体检测模型分别获取所述第一图像、所述第二图像、所述第三图像以及所述第四图像对应的物体概率值,确定所述物体概率值中的最大概率值,所述物体检测模型基于正向目标物体样本图像以及非正向目标物体样本图像训练得到;A probability value determination module, configured to obtain object probability values corresponding to the first image, the second image, the third image, and the fourth image by using a pre-trained object detection model, and determine the object probability The maximum probability value in the value, the object detection model is obtained based on the training of the forward target object sample image and the non-positive target object sample image;
方向调整模块,用于识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向。A direction adjustment module, configured to identify the rotation angle of the target image indicated by the maximum probability value, and adjust the display direction of the first image based on the rotation angle.
第四方面,本申请实施例提供了一种图像方向调整装置,所述装置包括:In a fourth aspect, the embodiment of the present application provides an image orientation adjustment device, the device comprising:
摄像头开启模块,用于接收拍摄指令,响应于所述拍摄指令,开启摄像头;A camera opening module, configured to receive a shooting instruction, and turn on the camera in response to the shooting instruction;
画面显示模块,用于显示所述摄像头针对拍摄对象采集的所述第一图像;A picture display module, configured to display the first image collected by the camera for the shooting object;
图像旋转模块,用于将所述第一图像分别按照不同的指定角度进行旋转后得到的第二图像、第三图像以及第四图像,其中,所述第一图像、所述第二图像、所述第三图像以及所述第四图像中包括一张正向目标物体图像;The image rotation module is used to rotate the first image according to different specified angles to obtain a second image, a third image, and a fourth image, wherein the first image, the second image, and the The third image and the fourth image include a forward target object image;
概率值确定模块,用于输出采用预先训练的物体检测模型分别获取的所述第一图像、所述第二图像、所述第三图像以及所述第四图像对应的物体概率值,所述物体检测模型基于正向目标物体样本图像以及非正向目标物体样本图像训练得到;A probability value determination module, configured to output object probability values corresponding to the first image, the second image, the third image, and the fourth image respectively obtained by using a pre-trained object detection model, the object The detection model is trained based on the sample image of the forward target object and the sample image of the non-positive target object;
方向调整模块,用于确定所述物体概率值中的最大概率值,识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向,并显示调整后的所述第一图像。A direction adjustment module, configured to determine the maximum probability value among the object probability values, identify the rotation angle of the target image indicated by the maximum probability value, adjust the display direction of the first image based on the rotation angle, and display the adjusted after the first image.
第五方面,本申请实施例提供了一种计算机存储介质,所述计算机存储介质存储有多条指令,所述指令适于由处理器加载并执行上述的方法步骤。In a fifth aspect, an embodiment of the present application provides a computer storage medium, where a plurality of instructions are stored in the computer storage medium, and the instructions are adapted to be loaded by a processor and execute the above-mentioned method steps.
第六方面,本申请实施例提供一种电子设备,可包括:处理器和存储器;其中,所述存储器存储有计算机程序,所述计算机程序适于由所述处理器加载并执行上述的方法步骤。In a sixth aspect, an embodiment of the present application provides an electronic device, which may include: a processor and a memory; wherein, the memory stores a computer program, and the computer program is adapted to be loaded by the processor and execute the above-mentioned method steps .
本申请实施例提供的技术方案带来的有益效果至少包括:The beneficial effects brought by the technical solutions provided by the embodiments of the present application at least include:
在本申请实施例中,移动终端获取摄像头针对拍摄对象采集的第一图像,将第一图像分别按照不同的指定角度进行旋转,从而得到第二图像、第三图像以及第四图像,采用预先训练的物体检测模型获取第一图像、第二图像、第三图像以及第四图像对应的物体概率值,确定物体概率值中的最大概率值,因为预先训练的物体检测模型是基于正向目标物体样本图像和非正向目标物体样本图像进行训练的,那么采用训练好的物体检测模型得到的最大概率值对应的图像即为正向目标物体图像,进而识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向,从而可以使得最终显示的图像方向为正向,以符合用户的使用习惯,方便用户使用,在此过程中,不需要额外增加重力传感器,节省了图像方向调整的成本。In the embodiment of the present application, the mobile terminal obtains the first image captured by the camera for the subject, and rotates the first image according to different specified angles to obtain the second image, the third image, and the fourth image. The object detection model obtains the object probability values corresponding to the first image, the second image, the third image, and the fourth image, and determines the maximum probability value among the object probability values, because the pre-trained object detection model is based on the forward target object sample images and non-forward target object sample images, then the image corresponding to the maximum probability value obtained by using the trained object detection model is the forward target object image, and then identify the rotation of the target image indicated by the maximum probability value Angle, adjust the display direction of the first image based on the rotation angle, so that the direction of the final displayed image can be positive, so as to conform to the user's usage habits and facilitate the user's use. During this process, no additional gravity is required sensor, saving the cost of image orientation adjustment.
附图说明Description of drawings
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present application. Those skilled in the art can also obtain other drawings based on these drawings without creative work.
图1是本申请实施例提供的一种图像方向调整方法的流程示意图;FIG. 1 is a schematic flow chart of an image orientation adjustment method provided in an embodiment of the present application;
图2a是本申请实施例提供的一种图像方向调整系统的架构示意图;Fig. 2a is a schematic structural diagram of an image orientation adjustment system provided by an embodiment of the present application;
图2b是本申请实施例提供的另一种图像方向调整系统的架构示意图;Fig. 2b is a schematic structural diagram of another image orientation adjustment system provided by an embodiment of the present application;
图3a是本申请实施例提供的一种第一图像的举例示意图;Fig. 3a is a schematic diagram of an example of a first image provided by an embodiment of the present application;
图3b是本申请实施例提供的另一种第一图像的举例示意图;Fig. 3b is an example schematic diagram of another first image provided by the embodiment of the present application;
图4是本申请实施例提供的一种图像尺寸变换的举例示意图;Fig. 4 is a schematic diagram of an example of image size conversion provided by an embodiment of the present application;
图5是本申请实施例提供的一种第一图像、第二图像、第三图像、第四图像的举例示意图;Fig. 5 is a schematic diagram of an example of a first image, a second image, a third image, and a fourth image provided by an embodiment of the present application;
图6是本申请实施例提供的一种图像方向调整前后的举例示意图;Fig. 6 is a schematic diagram of an example before and after image direction adjustment provided by the embodiment of the present application;
图7是本申请实施例提供的一种图像方向调整方法的流程示意图;FIG. 7 is a schematic flowchart of a method for adjusting an image direction provided by an embodiment of the present application;
图8是本申请实施例提供的一种提示信息展示界面的举例示意图;Fig. 8 is a schematic diagram of an example of a prompt information display interface provided by an embodiment of the present application;
图9是本申请实施例提供的一种图像方向调整方法的流程示意图;FIG. 9 is a schematic flowchart of a method for adjusting an image direction provided by an embodiment of the present application;
图10是本申请实施例提供的一种开启摄像头功能的举例示意图;FIG. 10 is a schematic diagram of an example of enabling a camera function provided by an embodiment of the present application;
图11是本申请实施例提供的一种提示信息展示界面的举例示意图;Fig. 11 is a schematic diagram of an example of a prompt information display interface provided by an embodiment of the present application;
图12是本申请实施例提供的一种图像方向调整装置的结构示意图;FIG. 12 is a schematic structural diagram of an image orientation adjustment device provided in an embodiment of the present application;
图13是本申请实施例提供的一种图像方向调整装置的结构示意图;FIG. 13 is a schematic structural diagram of an image orientation adjustment device provided in an embodiment of the present application;
图14是本申请实施例提供的一种方向调整模块的结构示意图;Fig. 14 is a schematic structural diagram of a direction adjustment module provided by an embodiment of the present application;
图15是本申请实施例提供的一种图像方向调整装置的结构示意图;Fig. 15 is a schematic structural diagram of an image orientation adjustment device provided by an embodiment of the present application;
图16是本申请实施例提供的一种图像方向调整装置的结构示意图;Fig. 16 is a schematic structural diagram of an image orientation adjustment device provided by an embodiment of the present application;
图17是本申请实施例提供的一种方向调整模块的结构示意图;Fig. 17 is a schematic structural diagram of a direction adjustment module provided by an embodiment of the present application;
图18是本申请实施例提供的一种电子设备的结构示意图。FIG. 18 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
具体实施方式Detailed ways
为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步详细描述。In order to make the purpose, technical solution and advantages of the present application clearer, the implementation manners of the present application will be further described in detail below in conjunction with the accompanying drawings.
下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中描述的实施方式并不代表与本申请一致的所有实施方式。相反,它们仅是如所附权利要求书中所详述的、本申请的一些方面相一致的装置和方法的例子。When the following description refers to the accompanying drawings, the same numerals in different drawings refer to the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with aspects of the present application as recited in the appended claims.
在本申请的描述中,需要理解的是,术语“第一”、“第二”等仅用于描述目的,而不能理解为指示或暗示相对重要性。对于本领域的普通技术人员而言,可以具体情况理解上述术语在本申请中的具体含义。此外,在本申请的描述中,除非另有说明,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。字符“/”一般表示前后关联对象是一种“或”的关系。In the description of the present application, it should be understood that the terms "first", "second" and so on are used for descriptive purposes only, and should not be understood as indicating or implying relative importance. Those of ordinary skill in the art can understand the specific meanings of the above terms in this application in specific situations. In addition, in the description of the present application, unless otherwise specified, "plurality" means two or more. "And/or" describes the association relationship of associated objects, indicating that there may be three types of relationships, for example, A and/or B may indicate: A exists alone, A and B exist simultaneously, and B exists independently. The character "/" generally indicates that the contextual objects are an "or" relationship.
下面结合具体的实施例对本申请进行详细说明。The present application will be described in detail below in conjunction with specific embodiments.
该方法可依赖于计算机程序实现,可运行于基于冯诺依曼体系的图像方向调整装置上。该计算机程序可集成在应用中,也可作为独立的工具类应用运行。其中,本申请实施例中的图像方向调整装置可以为移动终端,包括但不限于:个人电脑、平板电脑、手持设备、车载设备、可穿戴设备、计算设备或连接到无线调制解调器的其它处理设备等。在不同的网络中用户终端可以叫做不同的名称,例如:用户设备、接入终端、用户单元、用户站、移动站、移动台、远方站、远程终端、移动设备、用户终端、终端、无线通信设备、用户代理或用户装置、蜂窝电话、无绳电话、个人数字处理(Personal Digital Assistant,PDA)、5G网络或未来演进网络中的终端设备等。The method can be implemented relying on a computer program, and can run on an image orientation adjustment device based on the von Neumann system. The computer program can be integrated in the application, or run as an independent utility application. Wherein, the image orientation adjustment device in the embodiment of the present application may be a mobile terminal, including but not limited to: personal computer, tablet computer, handheld device, vehicle-mounted device, wearable device, computing device or other processing device connected to a wireless modem, etc. . User terminals can be called by different names in different networks, for example: user equipment, access terminal, subscriber unit, subscriber station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication Equipment, user agent or user device, cellular phone, cordless phone, personal digital assistant (PDA), terminal equipment in 5G network or future evolution network, etc.
该方法包括但不限于应用于学生学习机,此学习机指的是一般用于学生上网课或者进行其他学习项目的平板电脑,其带有一个设置在学习机顶部的摄像头,具有拍摄功能。This method includes but is not limited to application to student learning machines. This learning machine refers to a tablet computer that is generally used for students to take online classes or conduct other learning projects. It has a camera set on the top of the learning machine and has a shooting function.
请参见图1,为本申请实施例提供了一种图像方向调整方法的流程示意图。Please refer to FIG. 1 , which provides a schematic flowchart of a method for adjusting an image direction according to an embodiment of the present application.
本申请实施例以学习机为例进行描述,该图像方向调整方法可以包括以下步骤:In this embodiment of the present application, a learning machine is taken as an example for description, and the image direction adjustment method may include the following steps:
S101,获取摄像头针对拍摄对象采集的第一图像;S101, acquiring the first image collected by the camera for the subject;
具体的,如图2a所示,摄像机包括摄像头,摄像机可以为通过无线或有线方式与学习机进行通信的器件,其中学习机与摄像机进行通信的无线方式包括但不限于例如蜂窝网络、无线局域网、红外网络、近场通信网或蓝牙网络等,有线方式包括但不限于通用串行总线(Universal Serial Bus,USB)等。如图2b所示,摄像头也可以为作为学习机的一部分,即安装在学习机上的摄像机上的器件。Specifically, as shown in Figure 2a, the camera includes a camera, and the camera can be a device that communicates with the learning machine in a wireless or wired manner, wherein the wireless way for the learning machine to communicate with the camera includes but is not limited to, for example, a cellular network, a wireless local area network, Infrared network, near-field communication network or Bluetooth network, etc., wired methods include but not limited to Universal Serial Bus (Universal Serial Bus, USB). As shown in FIG. 2b, the camera can also be a part of the learning machine, that is, a device installed on the camera of the learning machine.
其中,拍摄对象可以为用户想要拍摄的任意物体,例如可以包括动物、人、书籍等,可以包括一个 或多个。Wherein, the shooting object can be any object that the user wants to shoot, for example, it can include animals, people, books, etc., and can include one or more.
其中,第一图像可以为摄像机的摄像头基于拍摄画面捕捉到的预先浏览图像,也可以为安装在学习机上的摄像头响应学习机的拍摄指令,基于拍摄画面的捕捉而得到的预先浏览图像。该第一图像可以在屏幕上进行显示。Wherein, the first image may be a pre-browsing image captured by the camera of the camera based on the shooting picture, or may be a pre-browsing image obtained based on the capturing of the shooting picture by the camera installed on the learning machine in response to the shooting instruction of the learning machine. The first image can be displayed on the screen.
例如,如图2b所示,用户触发打开学习机的摄像头,学习机的摄像头针对拍摄对象进行图像采集,从而得到第一图像。学习机获取第一图像可以为基于预设的定时获取机制进行获取,例如开启摄像头之后的第2秒钟进行获取,也可以为预设一定步长(例如每2秒一次)进行获取。For example, as shown in FIG. 2 b , the user triggers to turn on the camera of the learning machine, and the camera of the learning machine collects images of the subject to obtain the first image. The acquisition of the first image by the learning machine can be based on a preset timing acquisition mechanism, for example, acquisition in the second second after the camera is turned on, or it can be acquired in a preset certain step length (eg, once every 2 seconds).
在一些情况下,第一图像的图像方向为正向,如图3a所示,图中学习机侧栏的头像区域显示的第一图像为正向图像,这种情况可以不需要对图像方向进行调整。In some cases, the image direction of the first image is forward, as shown in Figure 3a, the first image displayed in the avatar area of the sidebar of the learning machine in the figure is a forward image, in this case, it is not necessary to adjust the image direction Adjustment.
可以理解的是,在第一图像未进行方向调整之前,第一图像为经过旋转了一定角度的图像或未跟随设备旋转的图像,一种可能的情况为如图3b所示,学习机中的第一图像为未调整前被旋转了一定角度的图像。It can be understood that, before the direction adjustment of the first image is performed, the first image is an image rotated by a certain angle or an image not rotated with the device. One possible situation is as shown in FIG. 3b , the learning machine The first image is an image rotated by a certain angle before adjustment.
可选的,还可以在不改变纵横比的前提下按照一定比例对第一图像进行尺寸变换,例如:若图像的初始尺寸比例为M×N,将其在不改变纵横比的前提下缩小图像尺寸,从而变换成M0×N0,若变换后有空缺区域则填充0像素,得到尺寸为M0×N0的第一图像I0,如图4所示。从而可以保证图像信息不丢失的情况下,缩小图像尺寸,进而可以减小计算量。Optionally, the first image can also be resized according to a certain ratio without changing the aspect ratio, for example: if the initial size ratio of the image is M×N, reduce the image without changing the aspect ratio size, so as to transform it into M0×N0, if there is a vacant area after the transformation, fill in 0 pixels, and obtain the first image I0 with the size of M0×N0, as shown in Figure 4. Therefore, under the condition that the image information is not lost, the size of the image can be reduced, thereby reducing the amount of calculation.
S102,将所述第一图像分别按照不同的指定角度进行旋转,得到第二图像、第三图像以及第四图像,其中,所述第一图像、所述第二图像、所述第三图像以及所述第四图像中包括一张正向目标物体图像;S102. Rotate the first image according to different specified angles to obtain a second image, a third image, and a fourth image, wherein the first image, the second image, the third image, and The fourth image includes a forward target object image;
本申请实施例提供的方案基于对图像的内容分析调整图像的显示方向,需要有一张正向目标物体图像作为基础,为了便于检测第一图像中的目标物体的方向,将第一图像分别按照不同的指定角度进行旋转。The solution provided by the embodiment of the present application adjusts the display direction of the image based on the analysis of the content of the image. It needs a forward target object image as a basis. In order to facilitate the detection of the direction of the target object in the first image, the first image is divided into Rotate by the specified angle.
其中,第一图像为目标物体朝向水平方向或者垂直方向的图像,那么不同的指定角度可以为90°、180°和270°。例如,将第一图像分别按照90°、180°和270°进行旋转后得到的第二图像、第三图像以及第四图像如图5所示,其中,第一图像为正向目标物体图像。Wherein, the first image is an image of the target object facing a horizontal direction or a vertical direction, then different specified angles may be 90°, 180° and 270°. For example, the second image, the third image and the fourth image obtained after rotating the first image by 90°, 180° and 270° respectively are shown in FIG. 5 , wherein the first image is the image of the forward target object.
需要说明的是,该不同的指定角度可以理解为按照同一方向进行旋转的角度,如顺时针或逆时针。It should be noted that the different specified angles can be understood as angles that rotate in the same direction, such as clockwise or counterclockwise.
经过旋转后,得到第二图像I1、第三图像I2以及第四图像I3,进而可以得到图像与角度的映射关系γ(I,D)={I 0:0°,I 1:90°,I 2:180°,I 3:270°}。 After rotation, the second image I1, the third image I2 and the fourth image I3 are obtained, and then the mapping relationship between the image and the angle can be obtained γ(I,D)={I 0 :0°,I 1 :90°,I 2 : 180°, I 3 : 270°}.
可选的,相应的对尺寸调整后的第一图像按照不同的指定角度进行旋转,得到的与第一图像尺寸相同的第二图像、第三图像以及第四图像。Optionally, the resized first image is correspondingly rotated according to different specified angles to obtain a second image, a third image and a fourth image having the same size as the first image.
S103,采用预先训练的物体检测模型分别获取所述第一图像、所述第二图像、所述第三图像以及所述第四图像对应的物体概率值,确定所述物体概率值中的最大概率值,所述物体检测模型基于正向目标物体样本图像以及非正向目标物体样本图像训练得到;S103. Obtain object probability values corresponding to the first image, the second image, the third image, and the fourth image respectively by using a pre-trained object detection model, and determine a maximum probability among the object probability values Value, the object detection model is obtained based on the training of the sample image of the forward target object and the sample image of the non-positive target object;
物体检测模型为基于正向目标物体样本图像和非正向目标物体样本图像训练生成,具体可以为一个二类分类问题的分类器。将图像输入至该物体检测模型中,则输出图像中目标物体是正向的概率值,即物体概率值。物体概率值越大,图像中目标物体是正向的可能性越大。The object detection model is generated based on training of positive target object sample images and non-positive target object sample images, specifically, it can be a classifier for a two-class classification problem. When an image is input into the object detection model, the probability value that the target object in the image is positive is output, that is, the object probability value. The larger the object probability value, the more likely the target object in the image is positive.
其中,正向目标物体样本图像可以为任意目标物体的正向图像。Wherein, the sample image of the forward target object may be a forward image of any target object.
目标物体可以为任意用户想要识别的物体,如动物、人、书籍。非正向目标物体样本图像可以为除正向目标物体之外的任意图像。例如,目标物体为用户1,那么非正向目标物体可以为除用户1之外的任意物体,如用户2、猫、狗等。The target object can be any object that the user wants to identify, such as animals, people, and books. The sample image of the non-forward target object can be any image except the forward target object. For example, if the target object is user 1, then the non-direct target object can be any object except user 1, such as user 2, cat, dog, etc.
当第一图像中包括目标物体时,将第一图像、第二图像、第三图像以及第四图像采用预先训练的物体检测模型进行识别,从而得到第一图像、第二图像、第三图像以及第四图像分别对应的物体概率值,并确定其中的最大概率值,因为最大概率值指示的图像是正向目标物体图像的概率最大,而第一图像、第二图像、第三图像以及第四图像中包括一张正向目标物体图像,因此可以确定最大概率值指示的图像为正向目标物体图像。When the first image includes the target object, the first image, the second image, the third image and the fourth image are identified using a pre-trained object detection model, thereby obtaining the first image, the second image, the third image and the The object probability values corresponding to the fourth images respectively, and determine the maximum probability value, because the image indicated by the maximum probability value has the highest probability of being the image of the forward target object, and the first image, the second image, the third image and the fourth image includes a forward target object image, so it can be determined that the image indicated by the maximum probability value is the forward target object image.
S104,识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向;S104. Identify the rotation angle of the target image indicated by the maximum probability value, and adjust the display direction of the first image based on the rotation angle;
最大概率值指示的目标图像即为第一图像、第二图像、第三图像以及第四图像中的一张图像,当确定目标图像具体为哪张图像后,将该图像的旋转角度作为第一图像的旋转角度。The target image indicated by the maximum probability value is one of the first image, the second image, the third image, and the fourth image. After determining which image the target image is, the rotation angle of the image is used as the first image. The rotation angle of the image.
例如,若目标图像为第一图像,则确定旋转角度为0°;若目标图像为第二图像,则确定旋转角度为第二图像的旋转角度(即90°),以此类推,具体根据图像确定旋转角度的依据为角度与图像的映射关系。For example, if the target image is the first image, then determine that the rotation angle is 0°; if the target image is the second image, then determine that the rotation angle is the rotation angle of the second image (ie 90°), and so on. The basis for determining the rotation angle is the mapping relationship between the angle and the image.
确定了目标图像的旋转角度后,将第一图像按照该旋转角度进行旋转,从而实现对第一图像的显示方向的调整。After the rotation angle of the target image is determined, the first image is rotated according to the rotation angle, so as to adjust the display direction of the first image.
例如,若旋转角度为0°,则说明目标图像为第一图像,即第一图像为正向目标物体图像,那么保持第一图像的显示方向不变;若旋转角度为第二图像的旋转角度,则说明目标图像为第二图像,即第二图像为正向目标物体图像,那么按照第二图像的旋转角度对第一图像的角度进行调整,以此类推。For example, if the rotation angle is 0°, it means that the target image is the first image, that is, the first image is the image of the forward target object, then keep the display direction of the first image unchanged; if the rotation angle is the rotation angle of the second image , it means that the target image is the second image, that is, the second image is the forward target object image, then the angle of the first image is adjusted according to the rotation angle of the second image, and so on.
因为目标图像为第一图像按照一定角度旋转得到的正向目标物体图像,将第一图像按照目标图像的旋转角度进行显示方向的调整,调整后得到的第一图像为正向目标物体图像,调整前后效果如图6所示。Because the target image is the forward target object image obtained by rotating the first image according to a certain angle, adjust the display direction of the first image according to the rotation angle of the target image, and the adjusted first image is the forward target object image, adjust The before and after effects are shown in Figure 6.
在本申请实施例中,学习机获取摄像头针对拍摄对象采集的第一图像,当第一图像中包括目标物体时,对第一图像按照不同的指定角度进行旋转获得第二图像、第三图像以及第四图像,采用预先训练的物体检测模型对第一图像、第二图像、第三图像以及第四图像进行识别获得相应的物体概率值,并确定物体概率值的最大概率值,因为预先训练的物体检测模型是基于正向目标物体样本图像和非正向目标物体样本图像进行训练的,若采用训练的物体检测模型获取得到的物体概率值最大,则最大概率值对应的图像可以认为是正向目标物体图像,识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向。本申请实施例提供的技术方案是基于对图像内容进行图像方向的调整,可以不需要额外增加重力传感器就可以将图像方向调整为正向,节省了图像方向调整的成本。In the embodiment of the present application, the learning machine acquires the first image captured by the camera for the subject, and when the first image includes the target object, the first image is rotated according to different specified angles to obtain the second image, the third image and For the fourth image, use the pre-trained object detection model to identify the first image, the second image, the third image and the fourth image to obtain the corresponding object probability values, and determine the maximum probability value of the object probability value, because the pre-trained The object detection model is trained based on the sample image of the forward target object and the sample image of the non-positive target object. If the object probability value obtained by using the trained object detection model is the largest, the image corresponding to the maximum probability value can be considered as the forward target. An object image, identifying a rotation angle of the target image indicated by the maximum probability value, and adjusting a display direction of the first image based on the rotation angle. The technical solution provided by the embodiment of the present application is based on adjusting the image direction of the image content, and the image direction can be adjusted to the positive direction without adding an additional gravity sensor, which saves the cost of image direction adjustment.
请参见图7,为本申请实施例提供了一种图像调整方法的流程示意图。本申请实施例以学习机为例进行描述,该图像方向调整可以包括以下步骤:Please refer to FIG. 7 , which provides a schematic flowchart of an image adjustment method according to an embodiment of the present application. In this embodiment of the present application, a learning machine is taken as an example for description, and the image direction adjustment may include the following steps:
S201,采集正向目标物体样本图像以及非正向目标物体样本图像;S201, collecting a sample image of a forward target object and a sample image of a non-positive target object;
其中,正向目标物体样本图像可以为任意目标物体的正向图像。Wherein, the sample image of the forward target object may be a forward image of any target object.
其中,目标物体可以为用户想要拍摄的任意物体,例如可以包括动物、人、书籍等,可以包括一个或多个,非正向目标物体样本图像可以为任意除正向目标物体之外的任意图像,例如,目标物体为用户1,那么非正向目标物体可以为除用户1之外的任意物体,如用户2、猫、狗等。Among them, the target object can be any object that the user wants to shoot, for example, it can include animals, people, books, etc., and can include one or more. The sample image of the non-positive target object can be any In the image, for example, the target object is user 1, then the non-direct target object can be any object except user 1, such as user 2, cat, dog, etc.
采集正向目标物体样本图像以及非正向目标物体样本图像,为后续对物体检测模型的训练提供素材基础,为了提高物体检测模型的识别率和可靠性,需要保证正向目标物体样本图像以及非正向目标物体样本图像的量足够大。Collect sample images of positive target objects and sample images of non-positive target objects to provide material basis for subsequent training of the object detection model. In order to improve the recognition rate and reliability of the object detection model, it is necessary to ensure that the sample images of positive target objects and non-positive The amount of positive target object sample images is sufficiently large.
S202,创建初始物体检测模型,基于所述正向目标物体样本图像以及所述非正向目标物体样本图像对所述初始物体检测模型进行训练,得到训练完成的物体检测模型;S202. Create an initial object detection model, and train the initial object detection model based on the forward target object sample image and the non-forward target object sample image to obtain a trained object detection model;
具体的,因物体检测模型的目的是得到图像对应的物体概率值,物体检测模型可以是基于retinaface、mtcnn这样的常规人脸检测网络,也可以将不同深度学习组块组合形成网络用于训练,从而得到一个检测图像中是否存在目标物体,并且输出相应的物体概率值的分类器,训练样本是正向目标物体样本图像和非正向目标物体样本图像。Specifically, because the purpose of the object detection model is to obtain the object probability value corresponding to the image, the object detection model can be based on conventional face detection networks such as retinaface and mtcnn, or can combine different deep learning blocks to form a network for training. In this way, a classifier that detects whether there is a target object in the image and outputs a corresponding object probability value is obtained. The training samples are a sample image of a positive target object and a sample image of a non-positive target object.
因此,采用训练完成的物体检测模型识别图像中目标物体的方向时,输出相应的物体概率值,预先根据训练结果设定一个概率阈值,将该概率阈值与物体检测模型输出的物体概率值中的最大值进行比较,若最大概率值小于概率阈值,则说明图像中不包括目标物体;若最大概率值大于或者等于概率阈值,则说明图像中包括目标物体。Therefore, when the trained object detection model is used to identify the direction of the target object in the image, the corresponding object probability value is output, and a probability threshold is set in advance according to the training result, and the probability threshold is combined with the object probability value output by the object detection model. If the maximum probability value is less than the probability threshold, it means that the target object is not included in the image; if the maximum probability value is greater than or equal to the probability threshold, it means that the target object is included in the image.
当最大概率值大于概率阈值时,物体概率值越大,则说明图像是正向目标物体图像的概率越大;概 率值越小,则说明图像是正向目标物体图像的概率越小。When the maximum probability value is greater than the probability threshold, the larger the object probability value, the greater the probability that the image is a positive target object image; the smaller the probability value, the smaller the probability that the image is a positive target object image.
S203,获取摄像头针对拍摄对象采集的第一图像;S203, acquiring the first image collected by the camera for the subject;
以摄像头为安装在学习机的摄像机上的器件为例,学习机上的摄像头针对拍摄对象采集的第一图像如图3b所示,第一图像经过了旋转,与用户实际需求方向不符,不方便用户使用。Taking the camera as a device installed on the camera of the learning machine as an example, the first image collected by the camera on the learning machine for the subject is shown in Figure 3b. The first image has been rotated, which does not match the direction of the user's actual needs, which is inconvenient for the user. use.
获取摄像头针对拍摄对象采集的第一图像具体可参见S101,此处不再赘述。Refer to S101 for details of acquiring the first image captured by the camera with respect to the subject, which will not be repeated here.
S204,将所述第一图像分别按照不同的指定角度进行旋转,得到第二图像、第三图像以及第四图像,其中,所述第一图像、所述第二图像、所述第三图像以及所述第四图像中包括一张正向目标物体图像;S204. Rotate the first image according to different specified angles to obtain a second image, a third image, and a fourth image, wherein the first image, the second image, the third image, and The fourth image includes a forward target object image;
将第一图像分别按照不同的指定角度进行旋转,得到第二图像、第三图像以及第四图像具体可参见S102,此处不再赘述。The first image is rotated according to different specified angles to obtain the second image, the third image and the fourth image. For details, refer to S102, which will not be repeated here.
S205,采用预先训练的物体检测模型分别获取所述第一图像、所述第二图像、所述第三图像以及所述第四图像对应的物体概率值,确定所述物体概率值中的最大概率值,所述物体检测模型基于正向目标物体样本图像以及非正向目标物体样本图像训练得到;S205. Obtain object probability values corresponding to the first image, the second image, the third image, and the fourth image respectively by using a pre-trained object detection model, and determine a maximum probability among the object probability values Value, the object detection model is obtained based on the training of the sample image of the forward target object and the sample image of the non-positive target object;
通过预先训练的物体检测模型能够得到图像是正向目标物体图像的概率值,概率值越大,图像是正向目标物体图像的可能性越大。The probability value that the image is a positive target object image can be obtained through the pre-trained object detection model. The larger the probability value, the greater the possibility that the image is a positive target object image.
当第一图像中包括目标物体时,将第一图像、第二图像、第三图像以及第四图像采用预先训练的物体检测模型进行识别,获得第一图像、第二图像、第三图像以及第四图像对应的物体概率值,例如为P1、P2、P3、P4,并确定P1、P2、P3、P4中的最大概率值,因为最大概率值指示的图像是正向目标物体图像的概率最大,因此可以确定最大概率值如P4指示的第四图像为正向目标物体图像。When the target object is included in the first image, the first image, the second image, the third image and the fourth image are identified using a pre-trained object detection model, and the first image, the second image, the third image and the fourth image are obtained. The object probability values corresponding to the four images, such as P1, P2, P3, P4, and determine the maximum probability value in P1, P2, P3, P4, because the image indicated by the maximum probability value has the highest probability of being the forward target object image, so It may be determined that the fourth image with the maximum probability value indicated by P4 is the forward target object image.
S206,当所述最大概率值大于或者等于概率阈值时,确定所述最大概率值指示的目标图像;S206. When the maximum probability value is greater than or equal to a probability threshold, determine a target image indicated by the maximum probability value;
当得到的最大概率值大于或者等于概率阈值时,基于物体检测模型在创建并训练过程中的设置,可以认为图像中包括目标物体,又因为最大概率值指示的图像可以认为是正向目标物体图像,因此确定最大概率值指示的图像为目标图像,且目标图像为第一图像、第二图像、第三图像以及第四图像中的一张图像。When the obtained maximum probability value is greater than or equal to the probability threshold, based on the settings of the object detection model in the creation and training process, it can be considered that the image includes the target object, and because the image indicated by the maximum probability value can be considered as the positive target object image, Therefore, it is determined that the image indicated by the maximum probability value is the target image, and the target image is one of the first image, the second image, the third image, and the fourth image.
S207,若所述目标图像为所述第一图像,则确定所述旋转角度为0°,保持所述第一图像的显示方向不变;S207. If the target image is the first image, determine that the rotation angle is 0°, and keep the display direction of the first image unchanged;
若基于最大概率值确定的目标图像为第一图像,因第一图像相较于第一图像旋转角度为0°,则确定旋转角度为0°,认为第一图像自身为正向目标物体图像,无需调整图像方向,保持第一图像的显示方向不变。If the target image determined based on the maximum probability value is the first image, since the rotation angle of the first image is 0° compared to the first image, the rotation angle is determined to be 0°, and the first image itself is considered to be the forward target object image, There is no need to adjust the image orientation, keeping the display orientation of the first image unchanged.
S208,若所述目标图像为所述第二图像,则确定所述旋转角度为所述第二图像的旋转角度,按照所述第二图像的旋转角度对所述第一图像的显示方向进行调整;S208. If the target image is the second image, determine that the rotation angle is the rotation angle of the second image, and adjust the display direction of the first image according to the rotation angle of the second image ;
若基于最大概率值确定的目标图像为第二图像,因第二图像是由第一图像按照指定角度旋转得到,则确定旋转角度为第二图像的旋转角度,将第一图像按照第二图像的旋转角度进行调整,从而使第一图像为正向目标物体图像。If the target image determined based on the maximum probability value is the second image, since the second image is obtained by rotating the first image according to a specified angle, the rotation angle is determined to be the rotation angle of the second image, and the first image is rotated according to the rotation angle of the second image The rotation angle is adjusted so that the first image is the image of the forward target object.
S209,若所述目标图像为所述第三图像,则确定所述旋转角度为所述第三图像的旋转角度,按照所述第三图像的旋转角度对所述第一图像的显示方向进行调整;S209. If the target image is the third image, determine that the rotation angle is the rotation angle of the third image, and adjust the display direction of the first image according to the rotation angle of the third image ;
若基于最大概率值确定的目标图像为第三图像,因第三图像是由第一图像按照指定角度旋转得到,则确定旋转角度为第三图像的旋转角度,将第一图像按照第三图像的旋转角度进行调整,从而使第一图像为正向目标物体图像。If the target image determined based on the maximum probability value is the third image, since the third image is obtained by rotating the first image according to a specified angle, the rotation angle is determined to be the rotation angle of the third image, and the first image is rotated according to the rotation angle of the third image The rotation angle is adjusted so that the first image is the image of the forward target object.
S210,若所述目标图像为所述第四图像,则确定所述旋转角度为所述第四图像的旋转角度,按照所述第四图像的旋转角度对所述第一图像的显示方向进行调整;S210, if the target image is the fourth image, determine that the rotation angle is the rotation angle of the fourth image, and adjust the display direction of the first image according to the rotation angle of the fourth image ;
若基于最大概率值确定的目标图像为第四图像,因第四图像是由第一图像按照指定角度旋转得到,则确定旋转角度为第四图像的旋转角度,将第一图像按照第四图像的旋转角度进行调整,从而使第一图像为正向目标物体图像。If the target image determined based on the maximum probability value is the fourth image, because the fourth image is obtained by rotating the first image according to a specified angle, the rotation angle is determined to be the rotation angle of the fourth image, and the first image is rotated according to the rotation angle of the fourth image. The rotation angle is adjusted so that the first image is the image of the forward target object.
S211,当所述最大概率值小于所述概率阈值时,输出指定值,所述指定值指示所述第一图像中不存 在目标物体;S211. When the maximum probability value is less than the probability threshold, output a specified value, the specified value indicating that there is no target object in the first image;
若最大概率值小于概率阈值,基于物体检测模型在创建并训练过程中的设置,可以认为图像中不包括目标图像,输出指定值,指定值用于指示第一图像中不存在目标物体。If the maximum probability value is less than the probability threshold, based on the settings of the object detection model during creation and training, it can be considered that the target image is not included in the image, and a specified value is output, and the specified value is used to indicate that there is no target object in the first image.
其中,指定值可以为任意数字、字母或者符号等,在进行物体检测模型训练时预先设置即可,例如,在训练时设置指定值为-1,则若最大概率值小于概率阈值,输出指定值-1,即代表第一图像中不存在目标物体。Among them, the specified value can be any number, letter or symbol, etc., which can be set in advance during the training of the object detection model. For example, if the specified value is set to -1 during training, then if the maximum probability value is less than the probability threshold, the specified value is output -1 means that there is no target object in the first image.
S212,获取所述摄像头针对所述拍摄对象采集的下一帧图像,将所述下一帧图像作为所述第一图像,并执行所述将所述第一图像分别按照不同的指定角度进行旋转,得到所述第二图像、所述第三图像以及所述第四图像的步骤;S212. Acquire the next frame of image collected by the camera for the subject, use the next frame of image as the first image, and execute the step of rotating the first image according to different specified angles , the step of obtaining the second image, the third image and the fourth image;
物体检测模型输出指示第一图像不存在目标物体的指定值后,触发摄像头再次获取针对拍摄对象采集的下一帧图像,并将下一帧图像作为新的第一图像用于检测,执行将第一图像分别按照不同的指定角度进行旋转,得到第二图像、第三图像以及第四图像的步骤,并继续执行S205-S213的步骤,从而得到调整为正向目标物体图像的第一图像。After the object detection model outputs the specified value indicating that there is no target object in the first image, the camera is triggered to acquire the next frame of image collected for the subject again, and the next frame of image is used as the new first image for detection, and the first image is executed. An image is rotated according to different specified angles to obtain the second image, the third image and the fourth image, and the steps of S205-S213 are continued to obtain the first image adjusted to the forward target object image.
S213,当连续采集的预设帧数的所述第一图像中均不存在目标物体时,输出摄像头故障的提示信息,所述提示信息用于提示用户调整所述摄像头的拍摄角度;S213. When there is no target object in the first images of the preset number of frames collected continuously, output a prompt message of a camera failure, where the prompt message is used to prompt the user to adjust the shooting angle of the camera;
当连续采集的预设帧数的第一图像中均检测认为不存在目标物体,则认为摄像头可能存在故障或者摄像头的拍摄角度存在问题,输出提示信息用于提示用户检测摄像头的拍摄角度。If no target object is detected in the first images of the preset number of frames collected continuously, it is considered that the camera may be malfunctioning or there is a problem with the shooting angle of the camera, and a prompt message is output to prompt the user to detect the shooting angle of the camera.
其中,预设帧数可以为3帧、4帧等,具体数量不做限定。Wherein, the preset number of frames may be 3 frames, 4 frames, etc., and the specific number is not limited.
提示信息可采用如音频、文本或者动画的方式输出,也可多种方式并行,具体方式和内容不做限定。The prompt information can be output in the form of audio, text or animation, or multiple ways in parallel, and the specific ways and contents are not limited.
如图8所示,一种可行的提示方式可以为文本框提示,弹出一个文本框,文本框内容为“当前图像中没有识别到人像,请重新拍摄”。As shown in FIG. 8 , a feasible prompting method may be a text box prompt, a text box pops up, and the content of the text box is "no portrait is recognized in the current image, please take a new photo".
其中,摄像头可能存在的故障包括但不限于:摄像头已损坏、摄像头被其他物体遮挡等。Among them, the possible faults of the camera include but are not limited to: the camera is damaged, the camera is blocked by other objects, and so on.
其中,摄像头的拍摄角度存在的物体包括但不限于:当前摄像头的拍摄角度无法拍摄到目标物体、使用错误的摄像头例如应当使用前置摄像头却误用了后置摄像头。Among them, the objects that exist at the shooting angle of the camera include but are not limited to: the target object cannot be captured at the current shooting angle of the camera, and the wrong camera is used, for example, the rear camera is used instead of the front camera.
其中,前置摄像头可以为放置于学习机显示屏所在面板的上端的摄像头。Wherein, the front camera can be a camera placed on the upper end of the panel where the display screen of the learning machine is located.
其中,后置摄像头可以为放置于学习机背板的摄像头。Wherein, the rear camera may be a camera placed on the back panel of the learning machine.
在用户调重新调整好摄像头后,重复获取第一图像以及接下来的其他步骤。After the user has readjusted the camera, repeat the acquisition of the first image and the following other steps.
在本申请实施例中,当第一图像中包括目标物体时,将第一图像按照不同角度旋转得到包括一张正向目标物体图像在内的四张图像,采用预先训练的物体检测模型获取四张图像对应的物体概率值,基于其中的最大概率值确定目标图像的旋转角度,基于旋转角度调整第一图像的显示方向;若最大概率值小于预先设置的阈值,即说明第一图像中不存在目标物体,则重新获取下一帧图像作为第一图像进行识别,从而最终得到显示方向为正向的第一图像,本申请实施例提供的技术方案是基于图像内容进行分析并调整图像方向,可以不需要额外增加重力传感器就可以将图像方向调整为正向,节省了图像方向调整的成本。In the embodiment of the present application, when the first image includes the target object, the first image is rotated according to different angles to obtain four images including a forward target object image, and the pre-trained object detection model is used to obtain four images. The object probability value corresponding to each image, determine the rotation angle of the target image based on the maximum probability value, and adjust the display direction of the first image based on the rotation angle; if the maximum probability value is less than the preset threshold, it means that there is no object in the first image target object, re-acquire the next frame of image as the first image for identification, and finally obtain the first image whose display direction is positive. The technical solution provided by the embodiment of the present application is to analyze and adjust the image direction based on the image content, which can The image direction can be adjusted to the positive direction without adding an additional gravity sensor, which saves the cost of image direction adjustment.
请参见图9,为本申请实施例提供了一种图像方向调整方法流程示意图。Please refer to FIG. 9 , which provides a schematic flowchart of a method for adjusting an image direction according to an embodiment of the present application.
本申请实施例以学习机侧进行描述,该图像方向调整方法可以包括以下步骤:The embodiment of the present application is described on the learning machine side, and the image direction adjustment method may include the following steps:
S301,接收拍摄指令,响应于所述拍摄指令,开启摄像头;S301. Receive a shooting instruction, and turn on the camera in response to the shooting instruction;
如图2a所示,摄像头可以为通过无线或有线方式与学习机进行通信的器件,如图2b所示,摄像头也可以为作为学习机的一部分,即安装在学习机上的器件。As shown in Figure 2a, the camera can be a device that communicates with the learning machine in a wireless or wired manner, and as shown in Figure 2b, the camera can also be a part of the learning machine, that is, a device installed on the learning machine.
以摄像头为安装在学习机上的器件为例,如图10所示,当用户触发学习机开启摄像头的拍摄功能时,学习机发送拍摄指令,当学习机接收到拍摄指令时,响应于拍摄指令开启摄像头的拍摄功能,摄像头针对的拍摄对象进行拍摄。Taking the camera as a device installed on the learning machine as an example, as shown in Figure 10, when the user triggers the learning machine to turn on the shooting function of the camera, the learning machine sends a shooting command, and when the learning machine receives the shooting command, it responds to the shooting command and turns on The shooting function of the camera, the camera is aimed at the subject to shoot.
其中,拍摄对象可以为用户想要拍摄的任意物体,例如可以包括动物、人、书籍等,也可以包括一 个或多个。Wherein, the shooting object can be any object that the user wants to shoot, for example, it can include animals, people, books, etc., and can also include one or more.
S302,显示所述摄像头针对拍摄对象采集的第一图像;S302, displaying the first image collected by the camera for the shooting object;
第一图像是指摄像头响应学习机发送的开始拍摄指令,基于拍摄画面的获取而得到的第一图像。The first image refers to the first image obtained by the camera in response to the start shooting instruction sent by the learning machine based on the acquisition of the shooting picture.
基于拍摄画面的获取而得到的第一图像具体可参见S101,此处不再赘述。For details of the first image obtained based on the acquisition of the photographed picture, refer to S101, which will not be repeated here.
其中,第一图像可以为摄像机的摄像头基于拍摄画面捕捉到的预先浏览图像,也可以为安装在学习机上的摄像头响应学习机的拍摄指令,基于拍摄画面的捕捉而得到的预先浏览图像。该第一图像可以在屏幕上进行显示。Wherein, the first image may be a pre-browsing image captured by the camera of the camera based on the shooting picture, or may be a pre-browsing image obtained based on the capturing of the shooting picture by the camera installed on the learning machine in response to the shooting instruction of the learning machine. The first image can be displayed on the screen.
S303,显示是否开启对目标物体进行方向检测的提示信息;S303, displaying whether to enable a prompt message for direction detection of the target object;
在学习机的头像区域显示摄像头采集的第一图像,并显示提示信息用于提示用户是否开启对目标物体的方向检测,用户可根据实际情况进行选择。The first image collected by the camera is displayed in the avatar area of the learning machine, and a prompt message is displayed to prompt the user whether to enable the direction detection of the target object, and the user can choose according to the actual situation.
其中,提示信息可采用如音频、文本或者动画的方式输出提示信息,也可多种方式并行,具体方式和内容不做限定。Wherein, the prompt information may be output in the form of audio, text, or animation, or in parallel in multiple ways, and the specific ways and contents are not limited.
如图11所示,一种可行的提示方式可以为文本框提示,弹出一个文本框,文本框内容为“是否开启图像方向检测”。As shown in FIG. 11 , a feasible prompting method may be a text box prompt, a text box pops up, and the content of the text box is "whether to enable image orientation detection".
S304,接收针对所述提示信息中目标物体的确认指令,响应于所述确认指令,开启对目标物体进行方向检测的功能;S304. Receive a confirmation instruction for the target object in the prompt information, and enable a function of detecting the direction of the target object in response to the confirmation instruction;
若用户在图11所示的提示文本框中点击“是”按键,表示用户同意开启对目标图像进行方向检测,学习机接收针对提示信息的确认指令,响应于确认指令,开启对目标物体进行方向检测的功能;若用户点击“否”按键,则不开启图像检测功能。If the user clicks the "Yes" button in the prompt text box shown in Figure 11, it means that the user agrees to enable the direction detection of the target image. The detection function; if the user clicks the "No" button, the image detection function will not be enabled.
其中,点击按键的方法根据学习机的具体情况而定,若学习机为触摸屏,可直接用手指点击;若学习机支持语音控制,也可采用语音进行选项的选择;若学习机支持鼠标控制,则可以使用鼠标进行操作。Among them, the method of clicking the button depends on the specific conditions of the learning machine. If the learning machine is a touch screen, you can directly click with your fingers; if the learning machine supports voice control, you can also use voice to select options; if the learning machine supports mouse control, You can use the mouse to operate.
S305,将所述第一图像分别按照不同的指定角度进行旋转得到第二图像、第三图像以及第四图像,其中,所述第一图像、所述第二图像、所述第三图像以及所述第四图像中包括一张正向目标物体图像;S305. Rotate the first image according to different specified angles to obtain a second image, a third image, and a fourth image, wherein the first image, the second image, the third image, and the The fourth image includes a forward target object image;
本申请实施例提供的技术方案是基于对图像的内容分析调整图像的显示方向,需要有一张正向目标物体图像作为基础,为了便于对第一图像进行图像中的目标物体的检测,将第一图像按照不同的指定角度进行旋转。The technical solution provided by the embodiment of the present application is to adjust the display direction of the image based on the analysis of the content of the image. A forward target object image is required as a basis. In order to facilitate the detection of the target object in the first image, the first The image is rotated by a different specified angle.
将所述第一图像分别按照不同的指定角度进行旋转具体可参见S102,此处不再赘述。For details of rotating the first image according to different specified angles, refer to S102 for details, which will not be repeated here.
S306,输出采用预先训练的物体检测模型分别获取的所述第一图像、所述第二图像、所述第三图像以及所述第四图像对应的物体概率值,并确定最大概率值,所述物体检测模型基于正向目标物体样本图像以及非正向目标物体样本图像训练得到;S306. Output the object probability values corresponding to the first image, the second image, the third image, and the fourth image respectively acquired by using the pre-trained object detection model, and determine the maximum probability value, the The object detection model is trained based on the sample image of the forward target object and the sample image of the non-positive target object;
预先训练的物体检测模型可以为基于正向目标物体样本图像和非正向目标物体样本图像训练的二类分类问题的分类器,通过此模型能够得到图像是正向目标物体图像的概率值,概率值越大,图像是正向目标物体图像的可能性越大。The pre-trained object detection model can be a classifier based on the two-class classification problem trained based on the sample image of the forward target object and the sample image of the non-positive target object. Through this model, the probability value of the image is the image of the forward target object, and the probability value The larger the , the more likely the image is the image of the forward target object.
物体检测模型的训练过程可参见S201和S202,此处不再赘述。For the training process of the object detection model, refer to S201 and S202, which will not be repeated here.
采用预先训练的物体检测模型获取的图像的物体概率值,确定最大概率值,具体可参见S205,此处不再赘述。The maximum probability value is determined by using the object probability value of the image acquired by the pre-trained object detection model. For details, refer to S205, which will not be repeated here.
其中,物体概率值可以为图像中包括正向目标物体的概率值。Wherein, the object probability value may be a probability value that the image includes a forward target object.
S307,当所述最大概率值大于或者等于概率阈值时,识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度确定所述第一图像的目标方向;S307. When the maximum probability value is greater than or equal to a probability threshold, identify the rotation angle of the target image indicated by the maximum probability value, and determine the target direction of the first image based on the rotation angle;
其中,概率阈值可以为物体检测模型训练过程中根据训练效果设置的阈值。Wherein, the probability threshold may be a threshold set according to the training effect during the training process of the object detection model.
当最大概率值大于或者等于概率阈值时,可以认为图像中包括目标物体。When the maximum probability value is greater than or equal to the probability threshold, it can be considered that the image includes the target object.
第二图像、第三图像以及第四图像为第一图像分别按照不同的指定角度旋转得到,四张图像中包括了一张正向目标物体图像,采用预先训练的物体检测模型获取四张图像的物体概率值,则其中的最大概率值指示的图像可以认为是正向目标物体图像,将指示的图像作为目标图像,确定目标图像的旋转角度。The second image, the third image, and the fourth image are obtained by rotating the first image according to different specified angles. The four images include a forward target object image, and the pre-trained object detection model is used to obtain the four images. The object probability value, the image indicated by the maximum probability value can be considered as the forward target object image, and the indicated image is used as the target image to determine the rotation angle of the target image.
例如:若目标图像为第一图像,则确定旋转角度为0°;若目标图像为第二图像,则确定旋转角度为第二图像的旋转角度,以此类推。For example: if the target image is the first image, determine the rotation angle as 0°; if the target image is the second image, determine the rotation angle as the rotation angle of the second image, and so on.
确定目标图像的旋转角度后,基于目标图像的旋转角度确定第一图像的目标方向,因为目标图像是由第一图像按照指定角度旋转得到的正向目标物体图像,因此目标图像的显示方向认为是第一图像要调整为正向目标物体图像的目标方向After determining the rotation angle of the target image, determine the target direction of the first image based on the rotation angle of the target image, because the target image is a positive target object image obtained by rotating the first image according to the specified angle, so the display direction of the target image is considered to be The first image is to be adjusted to face the target direction of the target object image
S308,确定所述最大概率值指示的目标图像;S308. Determine the target image indicated by the maximum probability value;
当得到的最大概率值大于或者等于概率阈值时,基于物体检测模型在创建并训练过程中的设置,可以认为图像中包括目标物体,又因为最大概率值指示的图像可以认为是正向目标物体图像,因此确定最大概率值指示的图像为目标图像。When the obtained maximum probability value is greater than or equal to the probability threshold, based on the settings of the object detection model in the creation and training process, it can be considered that the image includes the target object, and because the image indicated by the maximum probability value can be considered as the positive target object image, Therefore, it is determined that the image indicated by the maximum probability value is the target image.
S309,若所述目标图像为所述第一图像,则保持所述第一图像的显示方向不变,并显示所述第一图像;S309. If the target image is the first image, keep the display direction of the first image unchanged, and display the first image;
若目标图像为第一图像,可以认为第一图像为正向目标物体图像,因为第一图像相较于第一图像旋转角度为0°,无需调整第一图像的显示方向,则保持第一图像的显示方向不变,并显示第一图像。If the target image is the first image, it can be considered that the first image is the forward target object image, because the rotation angle of the first image is 0° compared with the first image, and there is no need to adjust the display direction of the first image, so the first image is maintained The display orientation of is unchanged, and the first image is displayed.
S310,若所述目标图像为所述第二图像,则按照所述第二图像的旋转角度对所述第一图像的显示方向进行调整,并显示调整后的所述第一图像;S310. If the target image is the second image, adjust the display direction of the first image according to the rotation angle of the second image, and display the adjusted first image;
若目标图像为第二图像,可以认为第二图像为正向目标物体图像,则确定旋转角度为第二图像的旋转角度,按照第二图像的旋转角度对第一图像的显示方向进行调整,并显示调整后的第一图像。If the target image is the second image, it can be considered that the second image is the forward target object image, then the rotation angle is determined to be the rotation angle of the second image, and the display direction of the first image is adjusted according to the rotation angle of the second image, and The adjusted first image is displayed.
S311,若所述目标图像为所述第三图像,则按照所述第三图像的旋转角度对所述第一图像的显示方向进行调整,并显示调整后的所述第一图像;S311. If the target image is the third image, adjust the display direction of the first image according to the rotation angle of the third image, and display the adjusted first image;
若目标图像为第三图像,可以认为第三图像为正向目标物体图像,则确定旋转角度为第三图像的旋转角度,按照第三图像的旋转角度对第一图像的显示方向进行调整,并显示调整后的第一图像。If the target image is the third image, it can be considered that the third image is the forward target object image, then the rotation angle is determined to be the rotation angle of the third image, and the display direction of the first image is adjusted according to the rotation angle of the third image, and The adjusted first image is displayed.
S312,若所述目标图像为所述第四图像,则按照所述第四图像的旋转角度对所述第一图像的显示方向进行调整,并显示调整后的所述第一图像;S312. If the target image is the fourth image, adjust the display direction of the first image according to the rotation angle of the fourth image, and display the adjusted first image;
若目标图像为第四图像,可以认为第四图像为正向目标物体图像,则确定旋转角度为第四图像的旋转角度,按照第四图像的旋转角度对第一图像的显示方向进行调整,并显示调整后的第一图像。If the target image is the fourth image, it can be considered that the fourth image is the forward target object image, then the rotation angle is determined to be the rotation angle of the fourth image, and the display direction of the first image is adjusted according to the rotation angle of the fourth image, and The adjusted first image is displayed.
S313,当所述最大概率值小于所述概率阈值时,输出指定值,所述指定值指示所述第一图像中不存在目标物体;S313. When the maximum probability value is less than the probability threshold, output a specified value, where the specified value indicates that there is no target object in the first image;
若最大概率值小于概率阈值,基于物体检测模型在创建并训练过程中的设置,可以认为图像中不包括目标图像,输出指定值,指定值用于指示第一图像中不存在目标物体。If the maximum probability value is less than the probability threshold, based on the settings of the object detection model during creation and training, it can be considered that the target image is not included in the image, and a specified value is output, and the specified value is used to indicate that there is no target object in the first image.
其中,指定值可以为任意数字、字母或者符号等,在进行物体检测模型训练时预先设置即可,例如,在训练时设置指定值为-1,则若最大概率值小于概率阈值,输出指定值-1,即代表第一图像中不存在目标物体。Among them, the specified value can be any number, letter or symbol, etc., which can be set in advance during the training of the object detection model. For example, if the specified value is set to -1 during training, then if the maximum probability value is less than the probability threshold, the specified value is output -1 means that there is no target object in the first image.
S314,获取所述摄像头针对所述拍摄对象采集的下一帧图像,将所述下一帧图像作为所述第一图像,并执行所述将所述第一图像分别按照不同的指定角度进行旋转,得到所述第二图像、所述第三图像以及所述第四图像的步骤;S314. Acquire the next frame of image collected by the camera for the subject, use the next frame of image as the first image, and execute the step of rotating the first image according to different specified angles , the step of obtaining the second image, the third image and the fourth image;
物体检测模型输出指示第一图像不存在目标物体的指定值后,触发摄像头再次获取针对拍摄对象采集的下一帧图像,并将下一帧图像作为新的第一图像用于检测,执行将第一图像分别按照不同的指定角度进行旋转,得到第二图像、第三图像以及第四图像的步骤,并继续执行S306-S315的步骤,从而得到调整为正向目标物体图像的第一图像。After the object detection model outputs the specified value indicating that there is no target object in the first image, the camera is triggered to acquire the next frame of image collected for the subject again, and the next frame of image is used as the new first image for detection, and the first image is executed. An image is rotated according to different specified angles to obtain the second image, the third image and the fourth image, and the steps of S306-S315 are continued to obtain the first image adjusted to the forward target object image.
S315,当连续采集的预设帧数的所述第一图像中均不存在目标物体时,输出摄像头故障的提示信息,所述提示信息用于提示用户调整所述摄像头的拍摄角度;S315. When there is no target object in the first images of the preset number of frames continuously collected, output a prompt message of camera failure, where the prompt message is used to prompt the user to adjust the shooting angle of the camera;
当连续采集的预设帧数的第一图像中均检测认为不存在目标物体,则认为摄像头可能存在故障或者摄像头的拍摄角度存在问题,输出提示信息用于提示用户检测摄像头的拍摄角度。If no target object is detected in the first images of the preset number of frames collected continuously, it is considered that the camera may be malfunctioning or there is a problem with the shooting angle of the camera, and a prompt message is output to prompt the user to detect the shooting angle of the camera.
其中,提示信息可采用如音频、文本或者动画的方式输出提示信息,也可多种方式并行,具体方式 和内容不做限定。Wherein, the prompt information can be outputted in the form of audio, text or animation, and multiple ways can be used in parallel, and the specific ways and contents are not limited.
如图8所示,一种可行的提示方式可以为文本框提示,弹出一个文本框,文本框内容为“当前图像中没有识别到人像,请重新拍摄”。As shown in FIG. 8 , a feasible prompting method may be a text box prompt, a text box pops up, and the content of the text box is "no portrait is recognized in the current image, please take a new photo".
其中,摄像头可能存在的故障包括但不限于:摄像头已损坏、摄像头被其他物体遮挡等。Among them, the possible faults of the camera include but are not limited to: the camera is damaged, the camera is blocked by other objects, and so on.
其中,摄像头的拍摄角度存在的物体包括但不限于:当前摄像头的拍摄角度无法拍摄到目标物体、使用错误的摄像头例如应当使用前置摄像头却误用了后置摄像头等。Among them, the objects that exist at the shooting angle of the camera include but are not limited to: the target object cannot be captured at the current shooting angle of the camera, the wrong camera is used, for example, the rear camera is used instead of the front camera, etc.
其中,前置摄像头可以为放置于学习机显示屏所在面板的上端的摄像头。Wherein, the front camera can be a camera placed on the upper end of the panel where the display screen of the learning machine is located.
其中,后置摄像头可以为放置于学习机背板的摄像头。Wherein, the rear camera may be a camera placed on the back panel of the learning machine.
在用户调重新调整好摄像头后,重复获取第一图像并执行S303-S315的步骤。After the user adjusts and adjusts the camera, the steps of acquiring the first image and performing S303-S315 are repeated.
在本申请实施例中,在用户触发摄像头开启功能后,学习机开启摄像头获取第一图像并显示处理,当用户开启检测功能时,弹出弹窗提示用户确定开启检测,接收到确认指令后开启检测功能,通过物体检测模型得到第一图像按指定角度旋转得到的第二图像、第三图像以及第四图像的物体概率值,当最大概率值大于或者等于概率阈值时,基于最大概率值识别目标图像的旋转角度,并调整第一图像的显示方向后显示调整后的第一图像;当最大概率值小于概率阈值时,即说明第一图像中不存在目标物体,则重新获取下一帧图像作为第一图像进行识别,若连续采集的第一图像不包括目标物体,则提示用户检查摄像头及其拍摄角度,并再次获取图像进行检测,从而最终得到显示方向为正向的第一图像,本申请实施例提供的技术方案是基于图像内容进行分析并调整图像方向,可以不需要额外增加重力传感器就可以将图像方向调整为正向,节省了图像方向调整的成本。In the embodiment of the present application, after the user triggers the function of turning on the camera, the learning machine turns on the camera to obtain the first image and displays it for processing. When the user turns on the detection function, a pop-up window prompts the user to confirm to turn on the detection, and turns on the detection after receiving the confirmation command Function, through the object detection model to obtain the object probability values of the second image, the third image and the fourth image obtained by rotating the first image at a specified angle, when the maximum probability value is greater than or equal to the probability threshold, identify the target image based on the maximum probability value Rotation angle of the first image, and adjust the display direction of the first image to display the adjusted first image; when the maximum probability value is less than the probability threshold, it means that there is no target object in the first image, then re-acquire the next frame of image as the first image One image is recognized. If the first image collected continuously does not include the target object, the user is prompted to check the camera and its shooting angle, and the image is acquired again for detection, so as to finally obtain the first image whose display direction is positive. This application implements The technical solution provided by the example is to analyze and adjust the image direction based on the image content, and the image direction can be adjusted to the positive direction without adding an additional gravity sensor, which saves the cost of image direction adjustment.
下述为本申请装置实施例,可以用于执行本申请方法实施例。对应本申请装置实施例中未披露的细节,请参照本申请方法实施例。The following are device embodiments of the present application, which can be used to implement the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
请参见图12,其示出了本申请一个示例性实施例提供的图像方向调整的结构示意图。该图像方向调整装置可以通过软件、硬件或者两者结合实现成为终端的全部或者一部分。该装置1包括图像获取模块11、图像旋转模块12、概率值确定模块13以及方向调整模块14。Please refer to FIG. 12 , which shows a schematic structural diagram of image direction adjustment provided by an exemplary embodiment of the present application. The device for adjusting the image direction can be implemented as all or a part of the terminal through software, hardware or a combination of the two. The device 1 includes an image acquisition module 11 , an image rotation module 12 , a probability value determination module 13 and a direction adjustment module 14 .
图像获取模块11,用于获取摄像头针对拍摄对象采集的第一图像;An image acquisition module 11, configured to acquire the first image collected by the camera for the object to be photographed;
图像旋转模块12,用于将第一图像分别按照不同的指定角度进行旋转,得到第二图像、第三图像以及第四图像,其中,第一图像、第二图像、第三图像以及第四图像中包括一张正向目标物体图像;The image rotation module 12 is used to rotate the first image according to different specified angles to obtain the second image, the third image and the fourth image, wherein the first image, the second image, the third image and the fourth image Include a positive target object image;
概率值确定模块13,用于采用预先训练的物体检测模型分别获取第一图像、第二图像、第三图像以及第四图像对应的物体概率值,确定物体概率值中的最大概率值,物体检测模型基于正向目标物体样本图像以及非正向目标物体样本图像训练得到;The probability value determination module 13 is used to obtain the object probability values corresponding to the first image, the second image, the third image and the fourth image respectively by using the pre-trained object detection model, and determine the maximum probability value in the object probability values, and the object detection The model is trained based on the sample image of the forward target object and the sample image of the non-positive target object;
方向调整模块14,用于识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向。The direction adjustment module 14 is configured to identify the rotation angle of the target image indicated by the maximum probability value, and adjust the display direction of the first image based on the rotation angle.
可选的,如图13所示,所述装置1还包括:Optionally, as shown in Figure 13, the device 1 further includes:
样本采集模块15,用于采集正向目标物体样本图像以及非正向目标物体样本图像;A sample collection module 15, configured to collect a forward target object sample image and a non-positive target object sample image;
模型训练模块16,用于创建初始物体检测模型,基于正向目标物体样本图像以及非正向目标物体样本图像对初始物体检测模型进行训练,得到训练完成的物体检测模型。The model training module 16 is used to create an initial object detection model, and train the initial object detection model based on the forward target object sample image and the non-positive target object sample image to obtain a trained object detection model.
可选的,方向调整模块14,具体用于:Optionally, the direction adjustment module 14 is specifically used for:
当最大概率值大于或者等于概率阈值时,识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向。When the maximum probability value is greater than or equal to the probability threshold, identifying the rotation angle of the target image indicated by the maximum probability value, and adjusting the display direction of the first image based on the rotation angle.
可选的,如图14所示,所述方向调整模块14,包括:Optionally, as shown in Figure 14, the direction adjustment module 14 includes:
图像确定单元141,用于确定所述最大概率值指示的目标图像;An image determining unit 141, configured to determine the target image indicated by the maximum probability value;
方向调整单元142,用于若所述目标图像为所述第一图像,则确定所述旋转角度为0°,保持所述第一图像的显示方向不变;A direction adjustment unit 142, configured to determine that the rotation angle is 0° if the target image is the first image, and keep the display direction of the first image unchanged;
所述方向调整单元142,还用于若所述目标图像为所述第二图像,则确定所述旋转角度为所述第二 图像的旋转角度,按照所述第二图像的旋转角度对所述第一图像的显示方向进行调整;The direction adjusting unit 142 is further configured to determine the rotation angle as the rotation angle of the second image if the target image is the second image, and adjust the rotation angle of the second image according to the rotation angle of the second image. adjusting the display direction of the first image;
所述方向调整单元142,还用于若所述目标图像为所述第三图像,则确定所述旋转角度为所述第三图像的旋转角度,按照所述第三图像的旋转角度对所述第一图像的显示方向进行调整;The direction adjusting unit 142 is further configured to determine the rotation angle as the rotation angle of the third image if the target image is the third image, and adjust the rotation angle of the third image according to the rotation angle of the third image. adjusting the display direction of the first image;
所述方向调整单元142,还用于若所述目标图像为所述第四图像,则确定所述旋转角度为所述第四图像的旋转角度,按照所述第四图像的旋转角度对所述第一图像的显示方向进行调整。The direction adjustment unit 142 is further configured to determine the rotation angle as the rotation angle of the fourth image if the target image is the fourth image, and adjust the rotation angle of the fourth image according to the rotation angle of the fourth image. The display orientation of the first image is adjusted.
可选的,如图13所示,所述装置1还包括:Optionally, as shown in Figure 13, the device 1 further includes:
指定值输出模块17,用于当所述最大概率值小于所述概率阈值时,输出指定值,所述指定值指示所述第一图像中不存在目标物体。A specified value output module 17, configured to output a specified value when the maximum probability value is smaller than the probability threshold, the specified value indicating that there is no target object in the first image.
可选的,所述图像获取模块11,还用于获取所述摄像头针对所述拍摄对象采集的下一帧图像,将所述下一帧图像作为所述第一图像,并触发图像旋转模块12将所述第一图像分别按照不同的指定角度进行旋转,得到所述第二图像、所述第三图像以及所述第四图像。Optionally, the image acquisition module 11 is further configured to acquire the next frame of image collected by the camera for the subject, use the next frame of image as the first image, and trigger the image rotation module 12 The first image is rotated respectively according to different specified angles to obtain the second image, the third image and the fourth image.
可选的,如图13所示,所述装置还包括信息输出模块18,用于当连续采集的预设帧数的所述第一图像中均不存在目标物体时,输出摄像头故障的提示信息,所述提示信息用于提示用户调整所述摄像头的拍摄角度。Optionally, as shown in FIG. 13 , the device further includes an information output module 18, configured to output a prompt message of camera failure when there is no target object in the first images of the preset number of frames collected continuously , the prompt information is used to prompt the user to adjust the shooting angle of the camera.
在本申请实施例中,当第一图像中包括目标物体时,将第一图像按照不同角度旋转得到包括一张正向目标物体图像在内的四张图像,采用预先训练的物体检测模型获取四张图像对应的物体概率值,基于其中的最大概率值确定目标图像的旋转角度,基于旋转角度调整第一图像的显示方向;若最大概率值小于预先设置的阈值,即说明第一图像中不存在目标物体,则重新获取下一帧图像作为第一图像进行识别,从而最终得到显示方向为正向的第一图像,本申请实施例提供的技术方案是基于图像内容进行分析并调整图像方向,可以不需要额外增加重力传感器就可以将图像方向调整为正向,节省了图像方向调整的成本。In the embodiment of the present application, when the first image includes the target object, the first image is rotated according to different angles to obtain four images including a forward target object image, and the pre-trained object detection model is used to obtain four images. The object probability value corresponding to each image, determine the rotation angle of the target image based on the maximum probability value, and adjust the display direction of the first image based on the rotation angle; if the maximum probability value is less than the preset threshold, it means that there is no object in the first image target object, re-acquire the next frame of image as the first image for identification, and finally obtain the first image whose display direction is positive. The technical solution provided by the embodiment of the present application is to analyze and adjust the image direction based on the image content, which can The image direction can be adjusted to the positive direction without adding an additional gravity sensor, which saves the cost of image direction adjustment.
请参见图15所示,其示出了本申请一个示例性实施例提供的图像方向调整装置的结构示意图。该装置2包括了摄像头开启模块21、画面显示模块22、图像旋转模块23、概率值确定模块24,方向调整模块25。Please refer to FIG. 15 , which shows a schematic structural diagram of an image orientation adjustment device provided by an exemplary embodiment of the present application. The device 2 includes a camera opening module 21 , a picture display module 22 , an image rotation module 23 , a probability value determination module 24 , and a direction adjustment module 25 .
摄像头开启模块21,用于接收拍摄指令,响应于所述拍摄指令,开启摄像头;The camera opening module 21 is configured to receive a shooting instruction, and open the camera in response to the shooting instruction;
画面显示模块22,用于显示所述摄像头针对拍摄对象采集的所述第一图像;A picture display module 22, configured to display the first image collected by the camera for the subject;
图像旋转模块23,用于将所述第一图像分别按照不同的指定角度进行旋转得到第二图像、第三图像以及第四图像,其中,所述第一图像、所述第二图像、所述第三图像以及所述第四图像中包括一张正向目标物体图像;An image rotation module 23, configured to rotate the first image according to different specified angles to obtain a second image, a third image and a fourth image, wherein the first image, the second image, the The third image and the fourth image include a forward target object image;
概率值确定模块24,用于输出采用预先训练的物体检测模型分别获取的所述第一图像、所述第二图像、所述第三图像以及所述第四图像对应的物体概率值,所述物体检测模型基于正向目标物体样本图像以及非正向目标物体样本图像训练得到;A probability value determination module 24, configured to output the object probability values corresponding to the first image, the second image, the third image, and the fourth image respectively obtained by using a pre-trained object detection model, the The object detection model is trained based on the sample image of the forward target object and the sample image of the non-positive target object;
方向调整模块25,用于确定所述物体概率值中的最大概率值,并识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向,并显示调整后的所述第一图像。a direction adjustment module 25, configured to determine the maximum probability value among the object probability values, and identify the rotation angle of the target image indicated by the maximum probability value, adjust the display direction of the first image based on the rotation angle, and and displaying the adjusted first image.
可选的,如图16所示,所述装置2还包括:Optionally, as shown in Figure 16, the device 2 further includes:
检测提示显示模块26,用于显示是否开启对目标物体进行方向检测的提示信息;The detection prompt display module 26 is used to display whether to open the prompt information for direction detection of the target object;
检测开启模块27,用于接收针对所述提示信息的确认指令,响应于所述确认指令,开启对目标物体进行方向检测的功能。The detection and activation module 27 is configured to receive a confirmation instruction for the prompt information, and respond to the confirmation instruction to enable the function of detecting the direction of the target object.
可选的,如图16所述,所述装置2还包括:Optionally, as shown in FIG. 16, the device 2 further includes:
指定值输出模块28,用于当所述最大概率值小于所述概率阈值时,输出指定值,所述指定值指示所述第一图像中不存在目标物体。A specified value output module 28, configured to output a specified value when the maximum probability value is less than the probability threshold, the specified value indicating that there is no target object in the first image.
可选的,所述图像获取模块22,还用于获取所述摄像头针对所述拍摄对象采集的下一帧图像,将所述下一帧图像作为所述第一图像,并触发图像旋转模块23将所述第一图像分别按照不同的指定角度进 行旋转,得到所述第二图像、所述第三图像以及所述第四图像。Optionally, the image acquisition module 22 is also configured to acquire the next frame of image collected by the camera for the subject, use the next frame of image as the first image, and trigger the image rotation module 23 The first image is rotated respectively according to different specified angles to obtain the second image, the third image and the fourth image.
可选的,如图13所示,所述装置还包括信息输出模块29,用于当连续采集的预设帧数的所述第一图像中均不存在目标物体时,输出摄像头故障的提示信息,所述提示信息用于提示用户检查摄像头及其拍摄角度。Optionally, as shown in FIG. 13 , the device further includes an information output module 29, configured to output a prompt message of camera failure when there is no target object in the first images of the preset number of frames collected continuously , the prompt information is used to prompt the user to check the camera and its shooting angle.
可选的,方向调整模块25,具体用于:Optionally, the direction adjustment module 25 is specifically used for:
当最大概率值大于或者等于概率阈值时,识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向。When the maximum probability value is greater than or equal to the probability threshold, identifying the rotation angle of the target image indicated by the maximum probability value, and adjusting the display direction of the first image based on the rotation angle.
可选的,如图17所示,所述角度调整单元25,包括:Optionally, as shown in Figure 17, the angle adjustment unit 25 includes:
图像确定单元251,用于确定所述最大概率值指示的目标图像;An image determining unit 251, configured to determine the target image indicated by the maximum probability value;
方向调整单元252,用于若所述目标图像为所述第一图像,则保持所述第一图像的显示方向不变,并显示所述第一图像;a direction adjustment unit 252, configured to keep the display direction of the first image unchanged and display the first image if the target image is the first image;
所述方向调整单元252,还用于若所述目标图像为所述第二图像,则按照所述第二图像的旋转角度对所述第一图像的显示方向进行调整,并显示调整后的所述第一图像;The direction adjustment unit 252 is further configured to adjust the display direction of the first image according to the rotation angle of the second image if the target image is the second image, and display the adjusted the first image;
所述方向调整单元252,还用于若所述目标图像为所述第三图像,则按照所述第三图像的旋转角度对所述第一图像的显示方向进行调整,并显示调整后的所述第一图像;The direction adjusting unit 252 is further configured to adjust the display direction of the first image according to the rotation angle of the third image if the target image is the third image, and display the adjusted the first image;
所述方向调整单元252,还用于若所述目标图像为所述第四图像,则按照所述第四图像的旋转角度对所述第一图像的显示方向进行调整,并显示调整后的所述第一图像。The direction adjustment unit 252 is further configured to adjust the display direction of the first image according to the rotation angle of the fourth image if the target image is the fourth image, and display the adjusted Describe the first image.
在本申请实施例中,在用户触发摄像头开启功能后,学习机开启摄像头获取第一图像并显示处理,当用户开启检测功能时,弹出弹窗提示用户确定开启检测,接收到确认指令后开启检测功能,通过物体检测模型得到第一图像按指定角度旋转得到的第二图像、第三图像以及第四图像的物体概率值,当最大概率值大于或者等于概率阈值时,基于最大概率值识别目标图像的旋转角度,并调整第一图像的显示方向后显示调整后的第一图像;当最大概率值小于概率阈值时,即说明第一图像中不存在目标物体,则重新获取下一帧图像作为第一图像进行识别,若连续采集的第一图像不包括目标物体,则提示用户检查摄像头及其拍摄角度,并再次获取图像进行检测,从而最终得到显示方向为正向的第一图像,本申请实施例提供的技术方案是基于图像内容进行分析并调整图像方向,可以不需要额外增加重力传感器就可以将图像方向调整为正向,节省了图像方向调整的成本。In the embodiment of the present application, after the user triggers the function of turning on the camera, the learning machine turns on the camera to obtain the first image and displays it for processing. When the user turns on the detection function, a pop-up window prompts the user to confirm to turn on the detection, and turns on the detection after receiving the confirmation command Function, through the object detection model to obtain the object probability values of the second image, the third image and the fourth image obtained by rotating the first image at a specified angle, when the maximum probability value is greater than or equal to the probability threshold, identify the target image based on the maximum probability value Rotation angle of the first image, and adjust the display direction of the first image to display the adjusted first image; when the maximum probability value is less than the probability threshold, it means that there is no target object in the first image, then re-acquire the next frame of image as the first image One image is recognized. If the first image collected continuously does not include the target object, the user is prompted to check the camera and its shooting angle, and the image is acquired again for detection, so as to finally obtain the first image whose display direction is positive. This application implements The technical solution provided by the example is to analyze and adjust the image direction based on the image content, and the image direction can be adjusted to the positive direction without adding an additional gravity sensor, which saves the cost of image direction adjustment.
需要说明的是,上述实施例提供的图像方向调整装置在执行图像方向调整方法时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将设备的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的图像方向调整装置与图像方向调整方法实施例属于同一构思,其体现实现过程详见方法实施例,这里不再赘述。It should be noted that, when the image orientation adjustment device provided in the above-mentioned embodiments executes the image orientation adjustment method, the division of the above-mentioned functional modules is used as an example for illustration. In practical applications, the above-mentioned functions can be assigned to different function modules as required Module completion means that the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the image orientation adjustment device and the image orientation adjustment method embodiment provided by the above embodiment belong to the same idea, and the implementation process thereof is detailed in the method embodiment, and will not be repeated here.
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the above embodiments of the present application are for description only, and do not represent the advantages and disadvantages of the embodiments.
本申请实施例还提供了一种计算机存储介质,所述计算机存储介质可以存储有多条指令,所述指令适于由处理器加载并执行如上述图1-图11所示实施例的方法步骤,具体执行过程可以参见图1-图11所示实施例的具体说明,在此不进行赘述。The embodiment of the present application also provides a computer storage medium, the computer storage medium can store a plurality of instructions, and the instructions are suitable for being loaded by the processor and executing the method steps of the above-mentioned embodiments shown in Figures 1-11 For the specific execution process, refer to the specific description of the embodiments shown in FIGS. 1-11 , and details are not repeated here.
本申请还提供了一种计算机程序产品,该计算机程序产品存储有至少一条指令,所述至少一条指令由所述处理器加载并执行上述图1-图11所示实施例的具体说明,在此不进行赘述。The present application also provides a computer program product, the computer program product stores at least one instruction, and the at least one instruction is loaded by the processor and executes the specific descriptions of the embodiments shown in FIGS. 1-11 above. Herein No further elaboration.
请参见图18,为本申请实施例提供了一种电子设备的结构示意图。如图18所示,所述移动终端1000可以包括:至少一个处理器1001,至少一个网络接口1004,用户接口1003,存储器1005,至少一个通信总线1002。Please refer to FIG. 18 , which provides a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in FIG. 18 , the mobile terminal 1000 may include: at least one processor 1001 , at least one network interface 1004 , a user interface 1003 , a memory 1005 , and at least one communication bus 1002 .
其中,通信总线1002用于实现这些组件之间的连接通信。Wherein, the communication bus 1002 is used to realize connection and communication between these components.
其中,用户接口1003可以包括显示屏(Display)、摄像头(Camera),可选用户接口1003还可以包括标准的有线接口、无线接口。Wherein, the user interface 1003 may include a display screen (Display) and a camera (Camera), and the optional user interface 1003 may also include a standard wired interface and a wireless interface.
其中,网络接口1004可选的可以包括标准的有线接口、无线接口(如WI-FI接口)。Wherein, the network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).
其中,处理器1001可以包括一个或者多个处理核心。处理器1001利用各种借口和线路连接整个电子设备1000内的各个部分,通过运行或执行存储在存储器1005内的指令、程序、代码集或指令集,以及调用存储在存储器1005内的数据,执行电子设备1000的各种功能和处理数据。可选的,处理器1001可以采用数字信号处理(Digital Signal Processing,DSP)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)、可编程逻辑阵列(Programmable Logic Array,PLA)中的至少一种硬件形式来实现。处理器1001可集成中央处理器(Central Processing Unit,CPU)、图像处理器(Graphics Processing Unit,GPU)和调制解调器等中的一种或几种的组合。其中,CPU主要处理操作系统、用户界面和应用程序等;GPU用于负责显示屏所需要显示的内容的渲染和绘制;调制解调器用于处理无线通信。可以理解的是,上述调制解调器也可以不集成到处理器1001中,单独通过一块芯片进行实现。Wherein, the processor 1001 may include one or more processing cores. The processor 1001 uses various interfaces and lines to connect various parts of the entire electronic device 1000, and by running or executing instructions, programs, code sets or instruction sets stored in the memory 1005, and calling data stored in the memory 1005, execute Various functions of the electronic device 1000 and processing data. Optionally, the processor 1001 may use at least one of Digital Signal Processing (Digital Signal Processing, DSP), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA), and Programmable Logic Array (Programmable Logic Array, PLA). implemented in the form of hardware. The processor 1001 may integrate one or a combination of a central processing unit (Central Processing Unit, CPU), an image processor (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly handles the operating system, user interface and application programs, etc.; the GPU is used to render and draw the content that needs to be displayed on the display screen; the modem is used to handle wireless communication. It can be understood that the above modem may also not be integrated into the processor 1001, but implemented by a single chip.
其中,存储器1005可以包括随机存储器(Random Access Memory,RAM),也可以包括只读存储器(Read-Only Memory)。可选的,该存储器1005包括非瞬时性计算机可读介质(non-transitory computer-readable storage medium)。存储器1005可用于存储指令、程序、代码、代码集或指令集。存储器1005可包括存储程序区和存储数据区,其中,存储程序区可存储用于实现操作系统的指令、用于至少一个功能的指令(比如触控功能、声音播放功能、图像播放功能等)、用于实现上述各个方法实施例的指令等;存储数据区可存储上面各个方法实施例中涉及到的数据等。存储器1005可选的还可以是至少一个位于远离前述处理器1001的存储装置。如图18所示,作为一种计算机存储介质的存储器1005中可以包括操作系统、网络通信模块、用户接口模块以及图像方向调整应用程序。Wherein, the memory 1005 may include a random access memory (Random Access Memory, RAM), and may also include a read-only memory (Read-Only Memory). Optionally, the memory 1005 includes a non-transitory computer-readable storage medium (non-transitory computer-readable storage medium). The memory 1005 may be used to store instructions, programs, codes, sets of codes or sets of instructions. The memory 1005 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), Instructions and the like for implementing the above method embodiments; the storage data area can store the data and the like involved in the above method embodiments. Optionally, the memory 1005 may also be at least one storage device located away from the aforementioned processor 1001 . As shown in FIG. 18 , the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and an image orientation adjustment application program.
在图18所示的移动终端1000中,用户接口1003主要用于为用户提供输入的接口,获取用户输入的数据;而处理器1001可以用于调用存储器1005中存储的生成图像方向调整应用程序,并具体执行以下操作:In the mobile terminal 1000 shown in FIG. 18 , the user interface 1003 is mainly used to provide the user with an input interface to obtain the data input by the user; and the processor 1001 can be used to call the generated image orientation adjustment application program stored in the memory 1005, And specifically do the following:
获取摄像头针对拍摄对象采集的第一图像;Obtaining the first image collected by the camera for the subject;
将所述第一图像分别按照不同的指定角度进行旋转,得到第二图像、第三图像以及第四图像,其中,所述第一图像、所述第二图像、所述第三图像以及所述第四图像中包括一张正向目标物体图像;Rotating the first image according to different specified angles to obtain a second image, a third image and a fourth image, wherein the first image, the second image, the third image and the The fourth image includes a forward target object image;
采用预先训练的物体检测模型分别获取所述第一图像、所述第二图像、所述第三图像以及所述第四图像对应的物体概率值,确定所述物体概率值中的最大概率值,所述物体检测模型基于正向目标物体样本图像以及非正向目标物体样本图像训练得到;Obtaining object probability values corresponding to the first image, the second image, the third image, and the fourth image respectively by using a pre-trained object detection model, and determining a maximum probability value among the object probability values, The object detection model is obtained by training based on forward target object sample images and non-positive target object sample images;
识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向。Identifying the rotation angle of the target image indicated by the maximum probability value, and adjusting the display direction of the first image based on the rotation angle.
在一个实施例中,所述处理器1001在执行获取摄像头针对拍摄对象采集的第一图像之前,还执行以下操作:In one embodiment, before the processor 1001 executes acquiring the first image captured by the camera for the subject, the following operations are further performed:
采集正向目标物体样本图像以及非正向目标物体样本图像;Collect sample images of positive target objects and sample images of non-positive target objects;
创建初始物体检测模型,基于所述正向目标物体样本图像以及所述非正向目标物体样本图像对所述初始物体检测模型进行训练,得到训练完成的物体检测模型。An initial object detection model is created, and the initial object detection model is trained based on the sample image of the forward target object and the sample image of the non-positive target object to obtain a trained object detection model.
在一个实施例中,所述处理器1001在执行识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度确定所述第一图像的目标方向,基于所述第一图像的目标方向调整所述第一图像的显示方向时,具体执行以下操作:In one embodiment, the processor 1001 identifies the rotation angle of the target image indicated by the maximum probability value, determines the target direction of the first image based on the rotation angle, and determines the target direction of the first image based on the rotation angle of the target image indicated by the maximum probability value. When adjusting the display direction of the first image, specifically perform the following operations:
当所述最大概率值大于或者等于概率阈值时,识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向。When the maximum probability value is greater than or equal to a probability threshold, identifying a rotation angle of the target image indicated by the maximum probability value, and adjusting a display direction of the first image based on the rotation angle.
在一个实施例中,所述处理器1001在执行识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向时,具体执行以下操作:In one embodiment, when the processor 1001 identifies the rotation angle of the target image indicated by the maximum probability value, and adjusts the display direction of the first image based on the rotation angle, specifically perform the following operations:
确定所述最大概率值指示的目标图像;determining the target image indicated by the maximum probability value;
若所述目标图像为所述第一图像,则确定所述旋转角度为0°,保持所述第一图像的显示方向不变;If the target image is the first image, then determine that the rotation angle is 0°, and keep the display direction of the first image unchanged;
若所述目标图像为所述第二图像,则确定所述旋转角度为所述第二图像的旋转角度,按照所述第二图像的旋转角度对所述第一图像的显示方向进行调整;If the target image is the second image, determining that the rotation angle is the rotation angle of the second image, and adjusting the display direction of the first image according to the rotation angle of the second image;
若所述目标图像为所述第三图像,则确定所述旋转角度为所述第三图像的旋转角度,按照所述第三图像的旋转角度对所述第一图像的显示方向进行调整;If the target image is the third image, determining that the rotation angle is the rotation angle of the third image, and adjusting the display direction of the first image according to the rotation angle of the third image;
若所述目标图像为所述第四图像,则确定所述旋转角度为所述第四图像的旋转角度,按照所述第四图像的旋转角度对所述第一图像的显示方向进行调整。If the target image is the fourth image, determine that the rotation angle is the rotation angle of the fourth image, and adjust the display direction of the first image according to the rotation angle of the fourth image.
在一个实施例中,所述处理器1001在还执行以下操作:In one embodiment, the processor 1001 also performs the following operations:
当所述最大概率值小于所述概率阈值时,输出指定值,所述指定值指示所述第一图像中不存在目标物体;When the maximum probability value is less than the probability threshold, outputting a specified value, the specified value indicating that there is no target object in the first image;
在一个实施例中,所述处理器1001在执行当所述最大概率值小于所述概率阈值时,输出指定值,所述指定值指示所述第一图像中不存在目标物体时,所述处理器1001还执行以下操作:In one embodiment, the processor 1001 outputs a specified value when the maximum probability value is smaller than the probability threshold, and the specified value indicates that there is no target object in the first image, the processing The device 1001 also performs the following operations:
获取所述摄像头针对所述拍摄对象采集的下一帧图像,将所述下一帧图像作为所述第一图像,并执行所述将所述第一图像分别按照不同的指定角度进行旋转,得到所述第二图像、所述第三图像以及所述第四图像的步骤。Acquiring the next frame of image collected by the camera for the subject, using the next frame of image as the first image, and executing the step of rotating the first image according to different specified angles, to obtain The steps of the second image, the third image and the fourth image.
在一个实施例中,所述处理器1001在执行获取所述摄像头针对所述拍摄对象采集的下一帧图像,将所述下一帧图像作为所述第一图像,并执行所述将所述第一图像分别按照不同的指定角度进行旋转,得到所述第二图像、所述第三图像以及所述第四图像的步骤时,所述处理器1001还执行以下操作:In one embodiment, when the processor 1001 executes acquiring the next frame of image captured by the camera for the subject, using the next frame of image as the first image, and executing the When the first image is rotated according to different specified angles to obtain the second image, the third image and the fourth image, the processor 1001 further performs the following operations:
当连续采集的预设帧数的所述第一图像中均不存在目标物体时,输出摄像头故障的提示信息,所述提示信息用于提示用户调整所述摄像头的拍摄角度。When there is no target object in the first images of the preset number of frames continuously collected, a prompt message of camera failure is output, and the prompt message is used to prompt the user to adjust the shooting angle of the camera.
可选的,所述处理器1001还执行以下操作:Optionally, the processor 1001 also performs the following operations:
接收拍摄指令,响应于所述拍摄指令,开启摄像头;receiving a shooting instruction, and turning on the camera in response to the shooting instruction;
显示所述摄像头针对拍摄对象采集的第一图像;displaying the first image collected by the camera for the subject;
将所述第一图像分别按照不同的指定角度进行旋转得到第二图像、第三图像以及第四图像,其中,所述第一图像、所述第二图像、所述第三图像以及所述第四图像中包括一张正向目标物体图像;Rotating the first image according to different specified angles to obtain a second image, a third image and a fourth image, wherein the first image, the second image, the third image and the first The four images include a forward target object image;
输出采用预先训练的物体检测模型分别获取的所述第一图像、所述第二图像、所述第三图像以及所述第四图像对应的物体概率值,所述物体检测模型基于正向目标物体样本图像以及非正向目标物体样本图像训练得到;Outputting the object probability values corresponding to the first image, the second image, the third image, and the fourth image respectively obtained by using a pre-trained object detection model, the object detection model is based on the forward target object The sample image and the sample image of the non-positive target object are trained;
确定所述物体概率值中的最大概率值,识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向。Determine the maximum probability value among the object probability values, identify the rotation angle of the target image indicated by the maximum probability value, and adjust the display direction of the first image based on the rotation angle.
在一个实施例中,所述处理器1001还执行以下操作:In one embodiment, the processor 1001 also performs the following operations:
显示是否开启对目标物体进行方向检测的提示信息;Display whether to open the prompt information for the direction detection of the target object;
接收针对所述提示信息的确认指令,响应于所述确认指令,开启对目标物体进行方向检测的功能。A confirmation instruction for the prompt information is received, and a function of detecting the direction of the target object is turned on in response to the confirmation instruction.
在一个实施例中,所述处理器1001在执行基于所述最大概率值确定所述第一图像的目标方向时,具体执行以下操作:In one embodiment, when the processor 1001 determines the target direction of the first image based on the maximum probability value, it specifically performs the following operations:
当所述最大概率值大于或者等于概率阈值时,识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度确定所述第一图像的目标方向。When the maximum probability value is greater than or equal to a probability threshold, identifying the rotation angle of the target image indicated by the maximum probability value, and determining the target direction of the first image based on the rotation angle.
在一个实施例中,所述处理器1001还执行以下操作:In one embodiment, the processor 1001 also performs the following operations:
当所述最大概率值小于所述概率阈值时,输出指定值,所述指定值指示所述第一图像中不存在目标物体。When the maximum probability value is less than the probability threshold, output a specified value indicating that there is no target object in the first image.
在一个实施例中,所述处理器1001在执行当所述最大概率值小于所述概率阈值时,输出指定值,所述指定值指示所述第一图像中不存在目标物体时,所述处理器1001还执行以下操作:In one embodiment, the processor 1001 outputs a specified value when the maximum probability value is smaller than the probability threshold, and the specified value indicates that there is no target object in the first image, the processing The device 1001 also performs the following operations:
获取所述摄像头针对所述拍摄对象采集的下一帧图像,将所述下一帧图像作为所述第一图像,并执行所述将所述第一图像分别按照不同的指定角度进行旋转,得到所述第二图像、所述第三图像以及所述第四图像的步骤。Acquiring the next frame of image collected by the camera for the subject, using the next frame of image as the first image, and executing the step of rotating the first image according to different specified angles, to obtain The steps of the second image, the third image and the fourth image.
在一个实施例中,所述处理器1001在执行获取所述摄像头针对所述拍摄对象采集的下一帧图像,将所述下一帧图像作为所述第一图像,并执行所述将所述第一图像分别按照不同的指定角度进行旋转,得到所述第二图像、所述第三图像以及所述第四图像的步骤时,所述处理器1001还执行以下操作:In one embodiment, when the processor 1001 executes acquiring the next frame of image captured by the camera for the subject, using the next frame of image as the first image, and executing the When the first image is rotated according to different specified angles to obtain the second image, the third image and the fourth image, the processor 1001 further performs the following operations:
当连续采集的预设帧数的所述第一图像中均不存在目标物体时,输出摄像头故障的提示信息,所述提示信息用于提示用户调整所述摄像头的拍摄角度。When there is no target object in the first images of the preset number of frames continuously collected, a prompt message of camera failure is output, and the prompt message is used to prompt the user to adjust the shooting angle of the camera.
在一个实施例中,所述处理器1001在执行识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向,并显示调整后的所述第一图像时,具体执行以下操作:In one embodiment, the processor 1001 performs identifying the rotation angle of the target image indicated by the maximum probability value, adjusts the display direction of the first image based on the rotation angle, and displays the adjusted first image. For an image, perform the following operations:
若所述目标图像为所述第一图像,则保持所述第一图像的显示方向不变,并显示所述第一图像;If the target image is the first image, keeping the display direction of the first image unchanged and displaying the first image;
若所述目标图像为所述第二图像,则按照所述第二图像的旋转角度对所述第一图像的显示方向进行调整,并显示调整后的所述第一图像;If the target image is the second image, adjusting the display direction of the first image according to the rotation angle of the second image, and displaying the adjusted first image;
若所述目标图像为所述第三图像,则按照所述第三图像的旋转角度对所述第一图像的显示方向进行调整,并显示调整后的所述第一图像;If the target image is the third image, adjusting the display direction of the first image according to the rotation angle of the third image, and displaying the adjusted first image;
若所述目标图像为所述第四图像,则按照所述第四图像的旋转角度对所述第一图像的显示方向进行调整,并显示调整后的所述第一图像。If the target image is the fourth image, adjusting the display direction of the first image according to the rotation angle of the fourth image, and displaying the adjusted first image.
在本申请实施例中,在用户触发摄像头开启功能后,学习机开启摄像头获取第一图像并显示处理,当用户开启检测功能时,弹出弹窗提示用户确定开启检测,接收到确认指令后开启检测功能,通过物体检测模型得到第一图像按指定角度旋转得到的第二图像、第三图像以及第四图像的物体概率值,当最大概率值大于或者等于概率阈值时,基于最大概率值识别目标图像的旋转角度,并调整第一图像的显示方向;当最大概率值小于概率阈值时,即说明第一图像中不存在目标物体,则重新获取下一帧图像作为第一图像进行识别,若连续采集的第一图像不包括目标物体,则提示用户检查摄像头及其拍摄角度,并再次获取图像进行检测,从而最终得到显示方向为正向的第一图像,本申请实施例提供的技术方案是基于图像内容进行分析并调整图像方向,可以不需要额外增加重力传感器就可以将图像方向调整为正向,节省了图像方向调整的成本。In the embodiment of the present application, after the user triggers the function of turning on the camera, the learning machine turns on the camera to obtain the first image and displays it for processing. When the user turns on the detection function, a pop-up window prompts the user to confirm to turn on the detection, and turns on the detection after receiving the confirmation command Function, through the object detection model to obtain the object probability values of the second image, the third image and the fourth image obtained by rotating the first image at a specified angle, when the maximum probability value is greater than or equal to the probability threshold, identify the target image based on the maximum probability value rotation angle of the first image, and adjust the display direction of the first image; when the maximum probability value is less than the probability threshold, it means that there is no target object in the first image, and then re-acquire the next frame image as the first image for identification. If the first image does not include the target object, the user is prompted to check the camera and its shooting angle, and the image is acquired again for detection, so as to finally obtain the first image whose display direction is positive. The technical solution provided by the embodiment of this application is based on the image The content is analyzed and the image direction is adjusted, and the image direction can be adjusted to positive without adding an additional gravity sensor, which saves the cost of image direction adjustment.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体或随机存储记忆体等。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented through computer programs to instruct related hardware, and the programs can be stored in a computer-readable storage medium. During execution, it may include the processes of the embodiments of the above-mentioned methods. Wherein, the storage medium may be a magnetic disk, an optical disk, a read-only memory or a random access memory, and the like.
以上所揭露的仅为本申请较佳实施例而已,当然不能以此来限定本申请之权利范围,因此依本申请权利要求所作的等同变化,仍属本申请所涵盖的范围。The above disclosures are only preferred embodiments of the present application, which certainly cannot limit the scope of the present application. Therefore, equivalent changes made according to the claims of the present application still fall within the scope of the present application.

Claims (18)

  1. 一种图像方向调整方法,其特征在于,包括:A method for adjusting an image direction, comprising:
    获取摄像头针对拍摄对象采集的第一图像;Obtaining the first image collected by the camera for the subject;
    将所述第一图像分别按照不同的指定角度进行旋转,得到第二图像、第三图像以及第四图像,其中,所述第一图像、所述第二图像、所述第三图像以及所述第四图像中包括一张正向目标物体图像;Rotating the first image according to different specified angles to obtain a second image, a third image and a fourth image, wherein the first image, the second image, the third image and the The fourth image includes a forward target object image;
    采用预先训练的物体检测模型分别获取所述第一图像、所述第二图像、所述第三图像以及所述第四图像对应的物体概率值,确定所述物体概率值中的最大概率值,所述物体检测模型基于正向目标物体样本图像以及非正向目标物体样本图像训练得到;Obtaining object probability values corresponding to the first image, the second image, the third image, and the fourth image respectively by using a pre-trained object detection model, and determining a maximum probability value among the object probability values, The object detection model is obtained by training based on forward target object sample images and non-positive target object sample images;
    识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向。Identifying the rotation angle of the target image indicated by the maximum probability value, and adjusting the display direction of the first image based on the rotation angle.
  2. 根据权利要求1所述的方法,其特征在于,所述获取摄像头针对拍摄对象采集的第一图像之前,还包括:The method according to claim 1, wherein, before the acquisition of the first image collected by the camera for the object to be photographed, further comprising:
    采集正向目标物体样本图像以及非正向目标物体样本图像;Collect sample images of positive target objects and sample images of non-positive target objects;
    创建初始物体检测模型,基于所述正向目标物体样本图像以及所述非正向目标物体样本图像对所述初始物体检测模型进行训练,得到训练完成的物体检测模型。An initial object detection model is created, and the initial object detection model is trained based on the sample image of the forward target object and the sample image of the non-positive target object to obtain a trained object detection model.
  3. 根据权利要求1所述的方法,其特征在于,所述识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向,包括:The method according to claim 1, wherein the identifying the rotation angle of the target image indicated by the maximum probability value, and adjusting the display direction of the first image based on the rotation angle comprises:
    当所述最大概率值大于或者等于概率阈值时,识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向。When the maximum probability value is greater than or equal to a probability threshold, identifying a rotation angle of the target image indicated by the maximum probability value, and adjusting a display direction of the first image based on the rotation angle.
  4. 根据权利要求1或3所述的方法,其特征在于,所述识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向,包括:The method according to claim 1 or 3, wherein the identifying the rotation angle of the target image indicated by the maximum probability value, and adjusting the display direction of the first image based on the rotation angle comprises:
    确定所述最大概率值指示的目标图像;determining the target image indicated by the maximum probability value;
    若所述目标图像为所述第一图像,则确定所述旋转角度为0°,保持所述第一图像的显示方向不变;If the target image is the first image, then determine that the rotation angle is 0°, and keep the display direction of the first image unchanged;
    若所述目标图像为所述第二图像,则确定所述旋转角度为所述第二图像的旋转角度,按照所述第二图像的旋转角度对所述第一图像的显示方向进行调整;If the target image is the second image, determining that the rotation angle is the rotation angle of the second image, and adjusting the display direction of the first image according to the rotation angle of the second image;
    若所述目标图像为所述第三图像,则确定所述旋转角度为所述第三图像的旋转角度,按照所述第三图像的旋转角度对所述第一图像的显示方向进行调整;If the target image is the third image, determining that the rotation angle is the rotation angle of the third image, and adjusting the display direction of the first image according to the rotation angle of the third image;
    若所述目标图像为所述第四图像,则确定所述旋转角度为所述第四图像的旋转角度,按照所述第四图像的旋转角度对所述第一图像的显示方向进行调整。If the target image is the fourth image, determine that the rotation angle is the rotation angle of the fourth image, and adjust the display direction of the first image according to the rotation angle of the fourth image.
  5. 根据权利要求3所述的方法,其特征在于,所述方法还包括:The method according to claim 3, further comprising:
    当所述最大概率值小于所述概率阈值时,输出指定值,所述指定值指示所述第一图像中不存在目标物体。When the maximum probability value is less than the probability threshold, output a specified value indicating that there is no target object in the first image.
  6. 根据权利要求5所述的方法,其特征在于,所述方法还包括:The method according to claim 5, wherein the method further comprises:
    获取所述摄像头针对所述拍摄对象采集的下一帧图像,将所述下一帧图像作为所述第一图像,并执行所述将所述第一图像分别按照不同的指定角度进行旋转,得到所述第二图像、所述第三图像以及所述第四图像的步骤。Acquiring the next frame of image collected by the camera for the subject, using the next frame of image as the first image, and executing the step of rotating the first image according to different specified angles, to obtain The steps of the second image, the third image and the fourth image.
  7. 根据权利要求6所述的方法,其特征在于,所述方法还包括:The method according to claim 6, further comprising:
    当连续采集的预设帧数的所述第一图像中均不存在目标物体时,输出摄像头故障的提示信息,所述 提示信息用于提示用户调整所述摄像头的拍摄角度。When there is no target object in the first image of the preset number of frames collected continuously, a prompt message of camera failure is output, and the prompt message is used to prompt the user to adjust the shooting angle of the camera.
  8. 一种图像方向调整方法,其特征在于,所述方法包括:A method for adjusting image direction, characterized in that the method comprises:
    接收拍摄指令,响应于所述拍摄指令,开启摄像头;receiving a shooting instruction, and turning on the camera in response to the shooting instruction;
    显示所述摄像头针对拍摄对象采集的第一图像;displaying the first image collected by the camera for the subject;
    将所述第一图像分别按照不同的指定角度进行旋转得到第二图像、第三图像以及第四图像,其中,所述第一图像、所述第二图像、所述第三图像以及所述第四图像中包括一张正向目标物体图像;Rotating the first image according to different specified angles to obtain a second image, a third image and a fourth image, wherein the first image, the second image, the third image and the first The four images include a forward target object image;
    输出采用预先训练的物体检测模型分别获取的所述第一图像、所述第二图像、所述第三图像以及所述第四图像对应的物体概率值,所述物体检测模型基于正向目标物体样本图像以及非正向目标物体样本图像训练得到;Outputting the object probability values corresponding to the first image, the second image, the third image, and the fourth image respectively obtained by using a pre-trained object detection model, the object detection model is based on the forward target object The sample image and the sample image of the non-positive target object are trained;
    确定所述物体概率值中的最大概率值,识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向,并显示调整后的所述第一图像。determining the maximum probability value among the object probability values, identifying the rotation angle of the target image indicated by the maximum probability value, adjusting the display direction of the first image based on the rotation angle, and displaying the adjusted first image image.
  9. 根据权利要求8所述的方法,其特征在于,所述开启摄像头之后,还包括:The method according to claim 8, wherein after the camera is turned on, further comprising:
    显示是否开启对目标物体进行方向检测的提示信息;Display whether to open the prompt information for the direction detection of the target object;
    接收针对所述提示信息的确认指令,响应于所述确认指令,开启对目标物体方向检测的功能。A confirmation instruction for the prompt information is received, and the function of detecting the direction of the target object is turned on in response to the confirmation instruction.
  10. 根据权利要求8所述的方法,其特征在于,所述基于所述最大概率值确定所述第一图像的目标方向,包括:The method according to claim 8, wherein the determining the target direction of the first image based on the maximum probability value comprises:
    当所述最大概率值大于或者等于概率阈值时,识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度确定所述第一图像的目标方向。When the maximum probability value is greater than or equal to a probability threshold, identifying the rotation angle of the target image indicated by the maximum probability value, and determining the target direction of the first image based on the rotation angle.
  11. 根据权利要求10所述的方法,其特征在于,所述方法还包括:The method according to claim 10, characterized in that the method further comprises:
    当所述最大概率值小于所述概率阈值时,输出指定值,所述指定值指示所述第一图像中不存在目标物体。When the maximum probability value is less than the probability threshold, output a specified value indicating that there is no target object in the first image.
  12. 根据权利要求11所述的方法,其特征在于,所述方法还包括:The method according to claim 11, characterized in that the method further comprises:
    获取所述摄像头针对所述拍摄对象采集的下一帧图像,将所述下一帧图像作为所述第一图像,并执行所述将所述第一图像分别按照不同的指定角度进行旋转,得到所述第二图像、所述第三图像以及所述第四图像的步骤。Acquiring the next frame of image collected by the camera for the subject, using the next frame of image as the first image, and executing the step of rotating the first image according to different specified angles, to obtain The steps of the second image, the third image and the fourth image.
  13. 根据权利要求12所述的方法,其特征在于,所述方法还包括:The method according to claim 12, characterized in that the method further comprises:
    当连续采集的预设帧数的所述第一图像中均不存在目标物体时,输出摄像头故障的提示信息,所述提示信息用于提示用户调整所述摄像头的拍摄角度。When there is no target object in the first images of the preset number of frames continuously collected, a prompt message of camera failure is output, and the prompt message is used to prompt the user to adjust the shooting angle of the camera.
  14. 根据权利要求8所述的方法,其特征在于,所述识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向,并显示调整后的所述第一图像,包括:The method according to claim 8, characterized in that identifying the rotation angle of the target image indicated by the maximum probability value, adjusting the display direction of the first image based on the rotation angle, and displaying the adjusted The first image, including:
    确定所述最大概率值指示的目标图像;determining the target image indicated by the maximum probability value;
    若所述目标图像为所述第一图像,则保持所述第一图像的显示方向不变,并显示所述第一图像;If the target image is the first image, keeping the display direction of the first image unchanged and displaying the first image;
    若所述目标图像为所述第二图像,则按照所述第二图像的旋转角度对所述第一图像的显示方向进行调整,并显示调整后的所述第一图像;If the target image is the second image, adjusting the display direction of the first image according to the rotation angle of the second image, and displaying the adjusted first image;
    若所述目标图像为所述第三图像,则按照所述第三图像的旋转角度对所述第一图像的显示方向进行调整,并显示调整后的所述第一图像;If the target image is the third image, adjusting the display direction of the first image according to the rotation angle of the third image, and displaying the adjusted first image;
    若所述目标图像为所述第四图像,则按照所述第四图像的旋转角度对所述第一图像的显示方向进行 调整,并显示调整后的所述第一图像。If the target image is the fourth image, adjusting the display direction of the first image according to the rotation angle of the fourth image, and displaying the adjusted first image.
  15. 一种图像方向调整装置,其特征在于,包括:An image orientation adjustment device, characterized in that it comprises:
    图像获取模块,用于获取摄像头针对拍摄对象采集的第一图像;An image acquisition module, configured to acquire the first image collected by the camera for the subject;
    图像旋转模块,用于将所述第一图像分别按照不同的指定角度进行旋转,得到第二图像、第三图像以及第四图像,其中,所述第一图像、所述第二图像、所述第三图像以及所述第四图像中包括一张正向目标物体图像;An image rotation module, configured to rotate the first image according to different specified angles to obtain a second image, a third image and a fourth image, wherein the first image, the second image, the The third image and the fourth image include a forward target object image;
    概率值确定模块,用于采用预先训练的物体检测模型分别获取所述第一图像、所述第二图像、所述第三图像以及所述第四图像对应的物体概率值,确定所述物体概率值中的最大概率值,所述物体检测模型基于正向目标物体样本图像以及非正向目标物体样本图像训练得到;A probability value determination module, configured to obtain object probability values corresponding to the first image, the second image, the third image, and the fourth image by using a pre-trained object detection model, and determine the object probability The maximum probability value in the value, the object detection model is obtained based on the training of the forward target object sample image and the non-positive target object sample image;
    方向调整模块,用于识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向。A direction adjustment module, configured to identify the rotation angle of the target image indicated by the maximum probability value, and adjust the display direction of the first image based on the rotation angle.
  16. 一种图像方向调整装置,其特征在于,所述装置包括:An image orientation adjustment device, characterized in that the device comprises:
    摄像头开启模块,用于接收拍摄指令,响应于所述拍摄指令,开启摄像头;A camera opening module, configured to receive a shooting instruction, and turn on the camera in response to the shooting instruction;
    画面显示模块,用于显示所述摄像头针对拍摄对象采集的所述第一图像;A picture display module, configured to display the first image collected by the camera for the shooting object;
    图像旋转模块,用于将所述第一图像分别按照不同的指定角度进行旋转得到第二图像、第三图像以及第四图像,其中,所述第一图像、所述第二图像、所述第三图像以及所述第四图像中包括一张正向目标物体图像;An image rotation module, configured to rotate the first image according to different specified angles to obtain a second image, a third image, and a fourth image, wherein the first image, the second image, and the first image The three images and the fourth image include a forward target object image;
    概率值确定模块,用于输出采用预先训练的物体检测模型分别获取的所述第一图像、所述第二图像、所述第三图像以及所述第四图像对应的物体概率值,所述物体检测模型基于正向目标物体样本图像以及非正向目标物体样本图像训练得到;A probability value determination module, configured to output object probability values corresponding to the first image, the second image, the third image, and the fourth image respectively obtained by using a pre-trained object detection model, the object The detection model is trained based on the sample image of the forward target object and the sample image of the non-positive target object;
    方向调整模块,用于确定所述物体概率值中的最大概率值,识别所述最大概率值指示的目标图像的旋转角度,基于所述旋转角度调整所述第一图像的显示方向,并显示调整后的所述第一图像。A direction adjustment module, configured to determine the maximum probability value among the object probability values, identify the rotation angle of the target image indicated by the maximum probability value, adjust the display direction of the first image based on the rotation angle, and display the adjusted after the first image.
  17. 一种计算机存储介质,其特征在于,所述计算机存储介质有多条指令,所述指令适于由处理器加载并执行如权利要求1~7或8~14任意一项的方法步骤。A computer storage medium, characterized in that the computer storage medium has a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the method steps according to any one of claims 1-7 or 8-14.
  18. 一种电子设备,其特征在于,包括:处理器和存储器;其中,所述存储器存储有计算机程序,所述计算机程序适于由所述处理器加载并执行如权利要求1~7或8~14任意一项的方法步骤。An electronic device, characterized by comprising: a processor and a memory; wherein, the memory stores a computer program, and the computer program is suitable for being loaded and executed by the processor according to claims 1-7 or 8-14 Any one of the method steps.
PCT/CN2022/111133 2021-08-16 2022-08-09 Image direction adjustment method and apparatus, and storage medium and electronic device WO2023020334A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110940091.7 2021-08-16
CN202110940091.7A CN115941859A (en) 2021-08-16 2021-08-16 Image direction adjusting method and device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
WO2023020334A1 true WO2023020334A1 (en) 2023-02-23

Family

ID=85240018

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/111133 WO2023020334A1 (en) 2021-08-16 2022-08-09 Image direction adjustment method and apparatus, and storage medium and electronic device

Country Status (2)

Country Link
CN (1) CN115941859A (en)
WO (1) WO2023020334A1 (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010224681A (en) * 2009-03-19 2010-10-07 Glory Ltd Image detection device, image detection method, and image detection program
CN101917548A (en) * 2010-08-11 2010-12-15 无锡中星微电子有限公司 Image pickup device and method for adaptively adjusting picture
CN108319937A (en) * 2018-03-28 2018-07-24 北京市商汤科技开发有限公司 Method for detecting human face and device
CN109345460A (en) * 2018-09-28 2019-02-15 百度在线网络技术(北京)有限公司 Method and apparatus for correcting image
CN110213605A (en) * 2019-05-28 2019-09-06 广州华多网络科技有限公司 Image rectification method, device and equipment
CN110399872A (en) * 2019-06-20 2019-11-01 阿里巴巴集团控股有限公司 Image processing method and device
CN110796029A (en) * 2019-10-11 2020-02-14 北京达佳互联信息技术有限公司 Face correction and model training method and device, electronic equipment and storage medium
CN112784858A (en) * 2019-11-01 2021-05-11 搜狗(杭州)智能科技有限公司 Image data processing method and device and electronic equipment

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010224681A (en) * 2009-03-19 2010-10-07 Glory Ltd Image detection device, image detection method, and image detection program
CN101917548A (en) * 2010-08-11 2010-12-15 无锡中星微电子有限公司 Image pickup device and method for adaptively adjusting picture
CN108319937A (en) * 2018-03-28 2018-07-24 北京市商汤科技开发有限公司 Method for detecting human face and device
CN109345460A (en) * 2018-09-28 2019-02-15 百度在线网络技术(北京)有限公司 Method and apparatus for correcting image
CN110213605A (en) * 2019-05-28 2019-09-06 广州华多网络科技有限公司 Image rectification method, device and equipment
CN110399872A (en) * 2019-06-20 2019-11-01 阿里巴巴集团控股有限公司 Image processing method and device
CN110796029A (en) * 2019-10-11 2020-02-14 北京达佳互联信息技术有限公司 Face correction and model training method and device, electronic equipment and storage medium
CN112784858A (en) * 2019-11-01 2021-05-11 搜狗(杭州)智能科技有限公司 Image data processing method and device and electronic equipment

Also Published As

Publication number Publication date
CN115941859A (en) 2023-04-07

Similar Documents

Publication Publication Date Title
CN103824481B (en) Method and device for detecting user recitation
US8379059B2 (en) Portable electronic device and method for adjusting display orientation of the portable electronic device
CN109684980B (en) Automatic scoring method and device
US20150149925A1 (en) Emoticon generation using user images and gestures
CN109639969B (en) Image processing method, terminal and server
US20220050565A1 (en) Screenshot method and terminal device
TW202105239A (en) Image processing methods, electronic devices and storage medium
WO2021169616A1 (en) Method and apparatus for detecting face of non-living body, and computer device and storage medium
EP3975046B1 (en) Method and apparatus for detecting occluded image and medium
WO2020249038A1 (en) Audio stream processing method and apparatus, mobile terminal, and storage medium
WO2019184947A1 (en) Image viewing method and mobile terminal
WO2019105457A1 (en) Image processing method, computer device and computer readable storage medium
WO2021159729A1 (en) Method for broadcasting text in image and device thereof, electronic circuit and storage medium
WO2018184260A1 (en) Correcting method and device for document image
WO2017173585A1 (en) Photographing method and terminal
WO2023005813A1 (en) Image direction adjustment method and apparatus, and storage medium and electronic device
CN108538284A (en) Simultaneous interpretation result shows method and device, simultaneous interpreting method and device
CN105871696B (en) Information sending and receiving method and mobile terminal
WO2021104159A1 (en) Display control method and electronic device
WO2019056659A1 (en) Status detection method and device, and storage medium
CN111464746B (en) Photographing method and electronic equipment
CN110308769B (en) Information display method and terminal
WO2021184966A1 (en) Identification photograph checking method and apparatus, electronic device, and storage medium
US20230368177A1 (en) Graphic code display method, terminal and storage medium
WO2023020334A1 (en) Image direction adjustment method and apparatus, and storage medium and electronic device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22857646

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 22857646

Country of ref document: EP

Kind code of ref document: A1