WO2021189854A1 - 照片处理方法、装置、电子设备及可读存储介质 - Google Patents
照片处理方法、装置、电子设备及可读存储介质 Download PDFInfo
- Publication number
- WO2021189854A1 WO2021189854A1 PCT/CN2020/125453 CN2020125453W WO2021189854A1 WO 2021189854 A1 WO2021189854 A1 WO 2021189854A1 CN 2020125453 W CN2020125453 W CN 2020125453W WO 2021189854 A1 WO2021189854 A1 WO 2021189854A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- straight line
- initial
- target object
- photo
- target
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/13—Edge detection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/70—Determining position or orientation of objects or cameras
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/10—Image acquisition modality
- G06T2207/10004—Still image; Photographic image
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Definitions
- This application relates to the field of data processing, and in particular to a photo processing method, device, electronic equipment, and readable storage medium.
- the photo processing methods provided in this application include:
- Two adjacent photos of the multiple photos are taken as a photo group to obtain multiple photo groups, and the absolute value of the difference between the center point coordinates of the target object in each photo group is calculated, and the absolute value of the difference is greater than the preset threshold.
- the second photo in the photo group is removed from the multiple photos to obtain the target photo.
- This application also provides a photo processing device, which includes:
- the request module is used to parse the photo processing request sent by the user based on the client, and obtain multiple photos carried in the photo processing request, and the multiple photos are photos taken continuously;
- the input module is used to input the multiple photos into the trained edge detection model to obtain the initial line function corresponding to each edge of the target object in each photo, and obtain the value of the target object in each photo based on the initial line function.
- Initial vertex coordinates
- the determining module is configured to obtain the initial area corresponding to each edge of the target object according to the initial vertex coordinates, determine the target straight line function corresponding to each edge of the target object based on the initial area, and according to the target straight line The function determines the coordinates of the center point of the target object;
- the culling module is used to take two adjacent photos of the multiple photos as a photo group to obtain multiple photo groups, calculate the absolute value of the difference between the center point coordinates of the target object in each photo group, and calculate the absolute value of the difference
- the second photo in the photo group larger than the preset threshold is removed from the multiple photos to obtain the target photo.
- This application also provides an electronic device, which includes:
- At least one processor and,
- a memory communicatively connected with the at least one processor; wherein,
- the memory stores a photo processing program executable by the at least one processor, and the photo processing program is executed by the at least one processor, so that the at least one processor can execute the following steps:
- Two adjacent photos of the multiple photos are taken as a photo group to obtain multiple photo groups, and the absolute value of the difference between the center point coordinates of the target object in each photo group is calculated, and the absolute value of the difference is greater than the preset threshold.
- the second photo in the photo group is removed from the multiple photos to obtain the target photo.
- the present application also provides a computer-readable storage medium having a photo processing program stored on the computer-readable storage medium, and the photo processing program can be executed by one or more processors to implement the following steps:
- Two adjacent photos of the multiple photos are taken as a photo group to obtain multiple photo groups, and the absolute value of the difference between the center point coordinates of the target object in each photo group is calculated, and the absolute value of the difference is greater than the preset threshold.
- the second photo in the photo group is removed from the multiple photos to obtain the target photo.
- FIG. 1 is a schematic flowchart of a photo processing method provided by an embodiment of this application
- FIG. 2 is a schematic diagram of modules of a photo processing device provided by an embodiment of the application.
- FIG. 3 is a schematic structural diagram of an electronic device for implementing a photo processing method provided by an embodiment of the application
- This application provides a photo processing method.
- FIG. 1 it is a schematic flowchart of a photo processing method provided by an embodiment of this application.
- the method can be executed by an electronic device, and the electronic device can be implemented by software and/or hardware.
- the photo processing method includes:
- Photo blur is usually divided into focus blur and motion blur. At present, more blurry photos are caused by motion blur. For example, a hand-held camera device shakes when taking a picture will produce a motion-blurred picture.
- the purpose of this application is to restrict the hand-held camera device’s Move the distance to reduce the possibility of blurry photos, so first take multiple photos (greater than or equal to two) continuously, and eliminate the blurry photos by judging the moving distance of the target object in the photo.
- the edge of the target object needs to have white space.
- the target object can be an ID card, a driver’s license, a passport, a degree certificate, a medical insurance card, a bank card, a household registration book, or a white space on the edge. Books, this embodiment defaults that there is only one target object in each photo.
- the method before inputting the multiple photos into the trained edge detection model, the method further includes:
- each photo when the size is normalized, each photo is scaled to a size of 128*256; the grayscale normalization process is performed on the photos through the floating point algorithm, and the photos after the grayscale normalization are displayed from the darkest black To the brightest white gray, the gray value ranges from 0 to 255; meanwhile, each photo is filtered through a Gaussian filter.
- the edge detection model is a neural network model, used to detect the initial line function corresponding to each edge of the target object in each photo, that is, to determine the line equation corresponding to each edge of the target object, for example, the model outputs the left side of the target object
- the training process of the edge detection model includes:
- q mn is the predicted line function corresponding to the n-th side of the target object in the m-th photo sample
- p mn is the real line function corresponding to the n-th side of the target object in the m-th photo sample
- loss(q mn ,p mn ) is the loss value between the predicted line function and the true line function corresponding to the n-th edge of the target object in the m-th photo sample
- c is the total number of photo samples
- t is the edge of the target object Total number (in this embodiment, t is 4).
- Input multiple photos taken continuously into the trained edge detection model, output the initial line function corresponding to each side of the target object in each photo, and obtain the initial vertex of the target object in each photo based on the initial line function Coordinates include:
- intersection point coordinates of the initial straight line functions corresponding to the two adjacent sides of the target object in each photo are solved, and the intersection point coordinates are used as the initial vertex coordinates.
- acquiring the initial area corresponding to each edge of the target object according to the initial vertex coordinates includes:
- this embodiment uses the initial straight line as the axis of symmetry to expand each edge to obtain the initial area of each edge, which expands the range of the edge detection of the target object, and then The target straight line function is calculated in the initial area, so that the obtained target straight line function is more accurate.
- the determining the target straight line function corresponding to each side of the target object based on the initial area includes:
- the preset convolution kernel includes a first convolution kernel and a second convolution kernel.
- the first convolution kernel is
- the second convolution kernel is
- the performing a convolution operation on the initial region with a preset convolution check includes:
- Convolution operation is to weight the adjacent pixels of pixels to highlight the edges in the image.
- the adaptive binarization method of Otsu method OTSU is used to perform binarization processing on the first area.
- the image after binarization processing is only black and white, and the gray value is 0 or 255, so that the color in the image is obtained.
- the contrast is sharper.
- the first area is divided into multiple second areas evenly along the direction of the initial straight line.
- the initial area corresponding to the left side of the target object is divided into a preset number (for example, 20) along the Y axis. ) Of the second area.
- the determining the end point coordinates of the straight line corresponding to each second area includes:
- the Hough transform algorithm is used to detect the straight lines in the respective second regions, and the endpoint coordinates of the straight line closest to the center of the target object in the detected straight lines are taken as the straight line endpoint coordinates corresponding to the respective second regions.
- this embodiment eliminates interference outside the target object in the photo, and uses the line that is closest to the center of the target object among the detected straight lines as the straight line where the edge of the target object is located.
- the determining the target straight line function corresponding to each side of the target object based on the end point coordinates of the straight line includes:
- Two coordinate points can determine a linear function, calculate the number of coordinates that fall on each linear function, and use the linear function with the largest number of coordinates as the target linear function corresponding to each side.
- the determining the center point coordinates of the target object according to the target straight line function includes:
- the target straight line functions corresponding to the two adjacent sides of the target object are taken as a straight line function group, the intersection point coordinates of each straight line function group are solved, and the intersection point coordinates are taken as the target vertex coordinates;
- G2 Determine the center point coordinates of the target object based on the target vertex coordinates.
- the three-point center coordinates of ACD are:
- ACD area of ACD
- Two adjacent photos of the multiple photos are taken as a photo group to obtain multiple photo groups, and the absolute value of the difference between the center point coordinates of the target object in each photo group is calculated, and the absolute value of the difference is greater than a preset
- the second photo in the threshold photo group is removed from the multiple photos to obtain the target photo.
- each photo will form a photo group with the previous photo, and the difference in the center point coordinates of the target object in the two photos in each photo group will be judged.
- the purpose of whether the absolute value of the value is greater than the preset threshold is to determine whether the moving distance of the second photo in each photo group relative to the first photo is too large, so as to determine whether the second photo will have motion blur.
- the photo processing method proposed in this application firstly inputs multiple continuously taken photos into the trained edge detection model to obtain the initial straight line function corresponding to each side of the target object in each photo, which is based on the initial straight line
- the function obtains the initial vertex coordinates of the target object in each photo.
- This step can quickly obtain the initial vertex coordinates of the target object in each photo; then, according to the initial vertex coordinates, obtain the initial area corresponding to each edge of the target object in each photo , Determine the target straight line function corresponding to each side of the target object based on the initial area, and determine the center point coordinates of the target object based on the target straight line function.
- This step obtains the initial area corresponding to each side according to the initial vertex coordinates, which expands the edge detection of the target object Range, avoiding the missed detection of the real edge, and improving the accuracy of the edge detection of the target object; finally, two adjacent photos are regarded as a photo group to obtain multiple photo groups, and the center of the target object in each photo group is calculated The absolute value of the difference of the point coordinates, the second photo in the photo group whose absolute value of the difference is greater than the preset threshold is removed from the multiple photos to obtain the target photo. This step determines the second photo in each photo group. When the photo is taken, whether the moving distance relative to the first photo is too large, so as to determine whether the second photo will appear blurred, and delete the blurred photo to ensure that the target photo is a clear photo.
- FIG. 2 it is a schematic diagram of modules of a photo processing apparatus provided by an embodiment of this application.
- the photo processing apparatus 100 described in this application can be installed in an electronic device. According to the realized functions, the photo processing device 100 may include a request module 110, an input module 120, a determination module 130, and a rejection module 140.
- the module described in this application can also be called a unit, which refers to a series of computer program segments that can be executed by the processor of an electronic device and can complete fixed functions, and are stored in the memory of the electronic device.
- each module/unit is as follows:
- the request module 110 is configured to parse the photo processing request sent by the user based on the client, and obtain multiple photos carried in the request, and the multiple photos are photos taken continuously.
- Photo blur is usually divided into focus blur and motion blur. At present, more blurry photos are caused by motion blur. For example, a hand-held camera device shakes when taking a picture will produce a motion-blurred picture.
- the purpose of this application is to restrict the hand-held camera device’s Move the distance to reduce the possibility of blurry photos, so first take multiple photos (greater than or equal to two) continuously, and eliminate the blurry photos by judging the moving distance of the target object in the photo.
- the edge of the target object needs to have white space.
- the target object can be an ID card, a driver’s license, a passport, a degree certificate, a medical insurance card, a bank card, a household registration book, or a white space on the edge. Books, this embodiment defaults that there is only one target object in each photo.
- the input module 120 is configured to input the multiple photos into the trained edge detection model to obtain the initial line function corresponding to each edge of the target object in each photo, and obtain the target object in each photo based on the initial line function The initial vertex coordinates.
- the method before inputting the multiple photos into the trained edge detection model, the method further includes:
- each photo when the size is normalized, each photo is scaled to a size of 128*256; the grayscale normalization process is performed on the photos through the floating point algorithm, and the photos after the grayscale normalization are displayed from the darkest black To the brightest white gray, the gray value ranges from 0 to 255; meanwhile, each photo is filtered through a Gaussian filter.
- the edge detection model is a neural network model, used to detect the initial line function corresponding to each edge of the target object in each photo, that is, to determine the line equation corresponding to each edge of the target object, for example, the model outputs the left side of the target object
- the training process of the edge detection model includes:
- q mn is the predicted line function corresponding to the n-th side of the target object in the m-th photo sample
- p mn is the real line function corresponding to the n-th side of the target object in the m-th photo sample
- loss(q nn ,p mn ) is the loss value between the predicted line function and the true line function corresponding to the n-th edge of the target object in the m-th photo sample
- c is the total number of photo samples
- t is the edge of the target object Total number (in this embodiment, t is 4).
- Input multiple photos taken continuously into the trained edge detection model, output the initial line function corresponding to each side of the target object in each photo, and obtain the initial vertex of the target object in each photo based on the initial line function Coordinates include:
- intersection point coordinates of the initial straight line functions corresponding to the two adjacent sides of the target object in each photo are solved, and the intersection point coordinates are used as the initial vertex coordinates.
- the determining module 130 is configured to obtain the initial area corresponding to each edge of the target object according to the initial vertex coordinates, determine the target straight line function corresponding to each edge of the target object based on the initial area, and according to the target The straight line function determines the coordinates of the center point of the target object.
- acquiring the initial area corresponding to each edge of the target object according to the initial vertex coordinates includes:
- this embodiment uses the initial straight line as the axis of symmetry to expand each edge to obtain the initial area of each edge, which expands the range of the edge detection of the target object, and then The target straight line function is calculated in the initial area, so that the obtained target straight line function is more accurate.
- the determining the target straight line function corresponding to each side of the target object based on the initial area includes:
- the preset convolution kernel includes a first convolution kernel and a second convolution kernel.
- the first convolution kernel is
- the second convolution kernel is
- the performing a convolution operation on the initial region with a preset convolution check includes:
- Convolution operation is to weight the adjacent pixels of pixels to highlight the edges in the image.
- the adaptive binarization method of Otsu method OTSU is used to perform binarization processing on the first area.
- the image after binarization processing is only black and white, and the gray value is 0 or 255, so that the color in the image is obtained.
- the contrast is sharper.
- the first area is divided into multiple second areas evenly along the direction of the initial straight line.
- the initial area corresponding to the left side of the target object is divided into a preset number (for example, 20) along the Y axis. ) Of the second area.
- the determining the end point coordinates of the straight line corresponding to each second area includes:
- the Hough transform algorithm is used to detect the straight lines in the respective second regions, and the endpoint coordinates of the straight line closest to the center of the target object in the detected straight lines are taken as the straight line endpoint coordinates corresponding to the respective second regions.
- this embodiment eliminates interference outside the target object in the photo, and uses the line that is closest to the center of the target object among the detected straight lines as the straight line where the edge of the target object is located.
- the determining the target straight line function corresponding to each side of the target object based on the end point coordinates of the straight line includes:
- Two coordinate points can determine a linear function, calculate the number of coordinates that fall on each linear function, and use the linear function with the largest number of coordinates as the target linear function corresponding to each side.
- the determining the center point coordinates of the target object according to the target straight line function includes:
- the target straight line functions corresponding to the two adjacent sides of the target object are taken as a straight line function group, the intersection point coordinates of each straight line function group are solved, and the intersection point coordinates are taken as the target vertex coordinates;
- G2 Determine the center point coordinates of the target object based on the target vertex coordinates.
- the three-point center coordinates of ACD are:
- ACD area of ACD
- the culling module 140 is configured to use two adjacent photos in the multiple photos as a photo group to obtain multiple photo groups, calculate the absolute value of the difference between the center point coordinates of the target object in each photo group, and calculate the absolute value of the difference.
- the second photo in the photo group whose value is greater than the preset threshold is removed from the multiple photos to obtain the target photo.
- each photo will form a photo group with the previous photo, and the difference in the center point coordinates of the target object in the two photos in each photo group will be judged.
- the purpose of whether the absolute value of the value is greater than the preset threshold is to determine whether the moving distance of the second photo in each photo group relative to the first photo is too large, so as to determine whether the second photo will have motion blur.
- FIG. 3 it is a schematic structural diagram of an electronic device for implementing a photo processing method provided by an embodiment of this application.
- the electronic device 1 is a device that can automatically perform numerical calculation and/or information processing in accordance with pre-set or stored instructions.
- the electronic device 1 may be a computer, a single web server, a server group composed of multiple web servers, or a cloud composed of a large number of hosts or web servers based on cloud computing, where cloud computing is a type of distributed computing, A super virtual computer composed of a group of loosely coupled computer sets.
- the electronic device 1 includes, but is not limited to, a memory 11, a processor 12, and a network interface 13 that can be communicably connected to each other through a system bus.
- the memory 11 stores a photo processing program 10, and the photo processing program 10 can be executed by the processor 12.
- FIG. 3 only shows the electronic device 1 with the components 11-13 and the photo processing program 10. Those skilled in the art can understand that the structure shown in FIG. 3 does not constitute a limitation on the electronic device 1, and may include a diagram Show fewer or more components, or combine certain components, or different component arrangements.
- the memory 11 includes a memory and at least one type of readable storage medium.
- the memory provides a cache for the operation of the electronic device 1;
- the readable storage medium can be, for example, flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM) ), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disks, optical disks and other non-volatile storage media.
- the readable storage medium may be an internal storage unit of the electronic device 1, such as the hard disk of the electronic device 1.
- the non-volatile storage medium may also be an external storage unit of the electronic device 1.
- Storage devices such as plug-in hard disks, Smart Media Card (SMC), Secure Digital (SD) cards, flash memory cards (Flash Card), etc., equipped on the electronic device 1.
- the readable storage medium of the memory 11 is generally used to store the operating system and various application software installed in the electronic device 1, for example, to store the code of the photo processing program 10 in an embodiment of the present application.
- the memory 11 can also be used to temporarily store various types of data that have been output or will be output.
- the processor 12 may be a central processing unit (Central Processing Unit, CPU), a controller, a microcontroller, a microprocessor, or other data processing chips.
- the processor 12 is generally used to control the overall operation of the electronic device 1, such as performing data interaction or communication-related control and processing with other devices.
- the processor 12 is used to run the program code or processing data stored in the memory 11, for example, to run the photo processing program 10 and so on.
- the network interface 13 may include a wireless network interface or a wired network interface, and the network interface 13 is used to establish a communication connection between the electronic device 1 and a client (not shown in the figure).
- the electronic device 1 may further include a user interface.
- the user interface may include a display (Display) and an input unit such as a keyboard (Keyboard).
- the optional user interface may also include a standard wired interface and a wireless interface.
- the display may be an LED display, a liquid crystal display, a touch liquid crystal display, an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, etc.
- the display can also be appropriately called a display screen or a display unit, which is used to display the information processed in the electronic device 1 and to display a visualized user interface.
- the photo processing program 10 stored in the memory 11 in the electronic device 1 is a combination of multiple instructions. When running in the processor 12, it can realize:
- Two adjacent photos of the multiple photos are taken as a photo group to obtain multiple photo groups, and the absolute value of the difference between the center point coordinates of the target object in each photo group is calculated, and the absolute value of the difference is greater than the preset threshold.
- the second photo in the photo group is removed from the multiple photos to obtain the target photo.
- the above-mentioned photos can also be stored in a node of a blockchain.
- the integrated module/unit of the electronic device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium.
- the computer-readable medium may be non-volatile or non-volatile.
- the computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory) .
- the computer-readable storage medium stores a photo processing program 10, and the photo processing program 10 can be executed by one or more processors. The same is not repeated here.
- modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
- the functional modules in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
- the above-mentioned integrated unit may be implemented in the form of hardware, or may be implemented in the form of hardware plus software functional modules.
- the blockchain referred to in this application is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
- Blockchain essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information for verification. The validity of the information (anti-counterfeiting) and the generation of the next block.
- the blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.
Landscapes
- Engineering & Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Image Analysis (AREA)
- Image Processing (AREA)
Abstract
一种照片处理方法、照片处理装置、电子设备及可读存储介质,包括:将多张连续拍摄的照片输入训练好的边缘检测模型得到每张照片中目标物体的各条边对应的初始直线函数和目标物体的初始顶点坐标;根据初始顶点坐标确定目标物体的各条边对应的目标直线函数和目标物体的中心点坐标;将相邻两张照片作为一个照片组,计算各个照片组中目标物体的中心点坐标的差值绝对值,将差值绝对值大于预设阈值的照片组中的第二张照片从所述多张连续拍摄的照片中剔除,得到目标照片。该方案确保了得到的目标照片为清晰照片。
Description
本申请要求于2020年9月24日提交中国专利局、申请号为CN202011019196.0、名称为“照片处理方法、装置、电子设备及可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及数据处理领域,尤其涉及一种照片处理方法、装置、电子设备及可读存储介质。
随着科技的发展,手持设备在人们生活中的应用越来越广泛,例如,采用手持摄像设备(例如,手机、平板、手持相机)拍摄照片方便、快捷,然而,当手持摄像设备抖动时会产生模糊照片,发明人意识到当前通常通过模糊筛选算法过滤模糊照片,然而模糊筛选算法是基于规则的筛选,当选择的指标不同时,得出的结果差别较大,从而使得得到的照片的清晰度无法保证。因此,亟需一种照片处理方法,以确保得到的照片为清晰照片。
发明内容
本申请提供的照片处理方法,包括:
解析用户基于客户端发出的照片处理请求,获取所述照片处理请求携带的多张照片,所述多张照片为连续拍摄的照片;
将所述多张照片输入训练好的边缘检测模型,得到每张照片中目标物体的各条边对应的初始直线函数,基于所述初始直线函数得到每张照片中目标物体的初始顶点坐标;
根据所述初始顶点坐标获取所述目标物体的各条边对应的初始区域,基于所述初始区域确定所述目标物体的各条边对应的目标直线函数,根据所述目标直线函数确定所述目标物体的中心点坐标;
将所述多张照片中相邻两张照片作为一个照片组,得到多个照片组,计算各个照片组中目标物体的中心点坐标的差值绝对值,将差值绝对值大于预设阈值的照片组中的第二张照片从所述多张照片中剔除,得到目标照片。
本申请还提供一种照片处理装置,所述装置包括:
请求模块,用于解析用户基于客户端发出的照片处理请求,获取所述照片处理请求携带的多张照片,所述多张照片为连续拍摄的照片;
输入模块,用于将所述多张照片输入训练好的边缘检测模型,得到每张照片中目标物体的各条边对应的初始直线函数,基于所述初始直线函数得到每张照片中目标物体的初始顶点坐标;
确定模块,用于根据所述初始顶点坐标获取所述目标物体的各条边对应的初始区域,基于所述初始区域确定所述目标物体的各条边对应的目标直线函数,根据所述目标直线函数确定所述目标物体的中心点坐标;
剔除模块,用于将所述多张照片中相邻两张照片作为一个照片组,得到多个照片组,计算各个照片组中目标物体的中心点坐标的差值绝对值,将差值绝对值大于预设阈值的照片组中的第二张照片从所述多张照片中剔除,得到目标照片。
本申请还提供一种电子设备,所述电子设备包括:
至少一个处理器;以及,
与所述至少一个处理器通信连接的存储器;其中,
所述存储器存储有可被所述至少一个处理器执行的照片处理程序,所述照片处理程序被所述至少一个处理器执行,以使所述至少一个处理器能够执行如下步骤:
解析用户基于客户端发出的照片处理请求,获取所述照片处理请求携带的多张照片,所述多张照片为连续拍摄的照片;
将所述多张照片输入训练好的边缘检测模型,得到每张照片中目标物体的各条边对应的初始直线函数,基于所述初始直线函数得到每张照片中目标物体的初始顶点坐标;
根据所述初始顶点坐标获取所述目标物体的各条边对应的初始区域,基于所述初始区域确定所述目标物体的各条边对应的目标直线函数,根据所述目标直线函数确定所述目标物体的中心点坐标;
将所述多张照片中相邻两张照片作为一个照片组,得到多个照片组,计算各个照片组中目标物体的中心点坐标的差值绝对值,将差值绝对值大于预设阈值的照片组中的第二张照片从所述多张照片中剔除,得到目标照片。
本申请还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有照片处理程序,所述照片处理程序可被一个或者多个处理器执行,以实现如下步骤:
解析用户基于客户端发出的照片处理请求,获取所述照片处理请求携带的多张照片,所述多张照片为连续拍摄的照片;
将所述多张照片输入训练好的边缘检测模型,得到每张照片中目标物体的各条边对应的初始直线函数,基于所述初始直线函数得到每张照片中目标物体的初始顶点坐标;
根据所述初始顶点坐标获取所述目标物体的各条边对应的初始区域,基于所述初始区域确定所述目标物体的各条边对应的目标直线函数,根据所述目标直线函数确定所述目标物体的中心点坐标;
将所述多张照片中相邻两张照片作为一个照片组,得到多个照片组,计算各个照片组中目标物体的中心点坐标的差值绝对值,将差值绝对值大于预设阈值的照片组中的第二张照片从所述多张照片中剔除,得到目标照片。
图1为本申请一实施例提供的照片处理方法的流程示意图;
图2为本申请一实施例提供的照片处理装置的模块示意图;
图3为本申请一实施例提供的实现照片处理方法的电子设备的结构示意图;
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
需要说明的是,在本申请中涉及“第一”、“第二”等的描述仅用于描述目的,而不能理解为指示或暗示其相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括至少一个该特征。另外,各个实施例之间的技术方案可以相互结合,但是必须是以本领域普通技术人员能够实现为基础,当技术方案的结合出现相互矛盾或无法实现时应当认为这种技术方案的结合不存在,也不在本申请要求的保护范围之内。
本申请提供一种照片处理方法。参照图1所示,为本申请一实施例提供的照片处理方法的流程示意图。该方法可以由一个电子设备执行,该电子设备可以由软件和/或硬件实现。
本实施例中,照片处理方法包括:
S1、解析用户基于客户端发出的照片处理请求,获取所述照片处理请求携带的多张照片,所述多张照片为连续拍摄的照片。
照片模糊通常分为对焦模糊和运动模糊,当前更多的模糊照片是由运动模糊造成的, 例如,拍照时手持摄像设备有抖动会产生运动模糊照片,本申请的目的在于通过限制手持摄像设备的移动距离来减少产生模糊照片的可能性,故而先连续拍摄多张照片(大于或等于两张),通过判断照片中目标物体的移动距离来剔除模糊照片。
本实施例中,所述目标物体的边缘需要有留白,所述目标物体可以是身份证、驾驶证、护照、学位证、医保卡、银行卡、户口本,也可以是边缘有留白的书籍,本实施例默认每张照片中只有一个目标物体。
S2、将所述多张照片输入训练好的边缘检测模型,得到每张照片中目标物体的各条边对应的初始直线函数,基于所述初始直线函数得到每张照片中目标物体的初始顶点坐标。
本实施例中,在将所述多张照片输入训练好的边缘检测模型之前,所述方法还包括:
A1、对所述多张照片中的每张照片执行尺寸归一化处理;
A2、对所述每张照片执行灰度归一化处理;
A3、对所述每张照片执行滤波处理。
本实施例中,尺寸归一化时将每张照片缩放到128*256的尺寸;通过浮点算法对照片执行灰度归一化处理,灰度归一化后的照片显示为从最暗黑色到最亮白色的灰度,灰度值范围为0~255;同时通过高斯滤波器对每张照片进行滤波处理。
所述边缘检测模型为神经网络模型,用于检测每张照片中目标物体的各条边对应的初始直线函数,即确定目标物体的各条边对应的直线方程式,例如,模型输出目标物体左侧边对应的直线方程式为y=ax+b,下侧边对应的直线方程式为y=cx+d,其中,a、b、c、d为常数。
所述边缘检测模型的训练过程包括:
B1、将携带标注信息的照片样本输入边缘检测模型得到每张照片样本中目标物体的各条边对应的预测直线函数;
B2、基于标注信息获取每张照片样本中目标物体的各条边对应的真实直线函数,通过最小化预测直线函数与真实直线函数之间的损失值确定所述边缘检测模型的权重参数,得到训练好的边缘检测模型。
所述损失值的计算公式为:
其中,q
mn为第m张照片样本中目标物体的第n条边对应的预测直线函数,p
mn为第m张照片样本中目标物体的第n条边对应的的真实直线函数,loss(q
mn,p
mn)为第m张照片样本中目标物体的第n条边对应的的预测直线函数与真实直线函数之间的损失值,c为照片样本的总数量,t为目标物体的边的总数量(本实施例中,t为4)。
将连续拍摄的多张照片输入训练好的边缘检测模型,输出每张照片中目标物体的各条边对应的初始直线函数,所述基于所述初始直线函数得到每张照片中目标物体的初始顶点坐标包括:
求解每张照片中目标物体的相邻两条边对应的初始直线函数的交点坐标,将所述交点坐标作为初始顶点坐标。
S3、根据所述初始顶点坐标获取所述目标物体的各条边对应的初始区域,基于所述初始区域确定所述目标物体的各条边对应的目标直线函数,根据所述目标直线函数确定所述目标物体的中心点坐标。
本实施例中,所述根据所述初始顶点坐标获取所述目标物体的各条边对应的初始区域包括:
D1、以顺时针方向连接所述目标物体的各个初始顶点坐标得到所述目标物体的各条边对应的初始直线;
D2、以所述初始直线为对称轴,将所述初始直线向所述对称轴的两侧分别移动预设距 离,得到第一直线和第二直线,将所述第一直线和第二直线围成的区域作为所述各条边对应的初始区域。
例如,对于目标物体左侧边的初始直线(由多个坐标组成),沿x轴方向,向左移动预设距离(例如5),即初始直线的各个坐标的x轴坐标分别减5得到第一直线;然后,向右移动预设距离,即初始直线的各个坐标的x轴坐标分别加5得到第二直线;将第一直线与第二直线围成的区域作为左侧边的初始区域。
因通过边缘检测模型得到的初始直线函数并不准确,故而,本实施例以初始直线为对称轴对各条边进行扩展得到各条边的初始区域,扩大了目标物体边缘检测的范围,再对初始区域求目标直线函数,使得得到的目标直线函数更加准确。
所述基于所述初始区域确定所述目标物体的各条边对应的目标直线函数包括:
E1、以预设卷积核对所述初始区域执行卷积操作得到所述目标物体的各条边对应的第一区域;
本实施例中,所述预设卷积核包括第一卷积核和第二卷积核。
所述以预设卷积核对所述初始区域执行卷积操作包括:
将沿X轴伸展的初始直线对应的初始区域与所述第一卷积核执行卷积操作,将沿Y轴伸展的初始直线对应的初始区域与所述第二卷积核执行卷积操作。
卷积操作是对像素点邻点灰度加权,突出图像中的边缘。
E2、对所述第一区域执行二值化处理,将二值化处理后的第一区域平均分成预设数量的第二区域;
本实施例采用大津法OTSU的自适应二值化法对第一区域执行二值化处理,二值化处理后的图像只有黑色和白色,灰度值为0或255,从而得到的图像中颜色对比更加鲜明。
本实施例沿初始直线的方向对第一区域平均切分得到多个第二区域,例如,对于目标物体左侧边对应的初始区域,沿Y轴方向将其分为预设数量(例如20个)的第二区域。
E3、确定各个第二区域对应的直线端点坐标,基于所述直线端点坐标确定所述目标物体的各条边对应的目标直线函数。
本实施例中,所述确定各个第二区域对应的直线端点坐标包括:
采用霍夫变换算法检测所述各个第二区域中的直线,将检测到的直线中距离目标物体中心最近的直线的端点坐标作为所述各个第二区域对应的直线端点坐标。
因目标物体内容距离目标物体的边有留白,本实施例为剔除照片中目标物体外侧的干扰,将检测到的直线中距离目标物体中心最近的直线作为目标物体的边所在的直线。
所述基于所述直线端点坐标确定所述目标物体的各条边对应的目标直线函数包括:
F1、将所述目标物体的各条边对应的直线端点坐标的集合作为一个坐标集,将所述坐标集中的坐标两两组合,得到多个坐标组;
F2、计算所述坐标集中落在每个坐标组确定的直线函数上的坐标数量;
F3、将坐标数量最多的坐标组对应的直线函数作为所述各条边对应的目标直线函数。
两个坐标点可以确定一个直线函数,计算落在每个直线函数上的坐标的数量,将落入的坐标数量最多的直线函数作为各条边对应的目标直线函数。
本实施例中,所述根据所述目标直线函数确定所述目标物体的中心点坐标包括:
G1、将所述目标物体的相邻两条边对应的目标直线函数作为一个直线函数组,求解每 个直线函数组的交点坐标,将所述交点坐标作为目标顶点坐标;
G2、基于所述目标顶点坐标确定所述目标物体的中心点坐标。
假设照片中目标物体的四个目标顶点坐标分别为A(x1,y1)、B(x2,y2)、C(x3,y3)和D(x4,y4),则ABC三点中心坐标为:
cx01=(x1+x2+x3)/3
cy01=(y1+y2+y3)/3
ACD三点中心坐标为:
cx02=(x1+x3+x4)/3
cy02=(y1+y3+y4)/3
ABC面积为:
S1=(x1y2-x1y3+x2y3-x2y1+x3y1-x2y2)
ACD面积为:
S2=(x1y3-x1y4+x3y4-x3y1+x4y1-x3y3)
记d=S2/S1
则目标物体中心点坐标为:
cx=(x01+d*x02)/(1+d)
cy=(y01+d*y02)/(1+d)。
S4、将所述多张照片中相邻两张照片作为一个照片组,得到多个照片组,计算各个照片组中目标物体的中心点坐标的差值绝对值,将差值绝对值大于预设阈值的照片组中的第二张照片从所述多张照片中剔除,得到目标照片。
将多张连续拍摄的照片中相邻两张照片作为一个照片组,则每张照片都会与其前一张照片组成一个照片组,判断各个照片组中两张照片中目标物体的中心点坐标的差值绝对值是否大于预设阈值的目的是判断各个照片组中第二张照片拍摄时相对于第一张照片的移动距离是否过大,从而确定第二张照片是否会出现运动模糊。
由上述实施例可知,本申请提出的照片处理方法,首先,将多张连续拍摄的照片输入训练好的边缘检测模型得到每张照片中目标物体的各条边对应的初始直线函数,基于初始直线函数得到每张照片中目标物体的初始顶点坐标,该步骤可快速得到每张照片中目标物体的初始顶点坐标;接着,根据初始顶点坐标获取每张照片中目标物体的各条边对应的初始区域,基于初始区域确定目标物体的各条边对应的目标直线函数,基于目标直线函数确定目标物体的中心点坐标,本步骤根据初始顶点坐标获取各条边对应的初始区域,扩大了目标物体边缘检测范围,避免了真实边缘被漏检的情况,提高了目标物体边缘检测的准确性;最后,将相邻两张照片作为一个照片组,得到多个照片组,计算各个照片组中目标物体的中心点坐标的差值绝对值,将差值绝对值大于预设阈值的照片组中的第二张照片从所述多张照片中剔除,得到目标照片,该步骤通过判断各个照片组中第二张照片拍摄时相对于第一张照片的移动距离是否过大,从而确定第二张照片是否会出现模糊,并删除模糊照片,确保了目标照片为清晰照片。
如图2所示,为本申请一实施例提供的照片处理装置的模块示意图。
本申请所述照片处理装置100可以安装于电子设备中。根据实现的功能,所述照片处理装置100可以包括请求模块110、输入模块120、确定模块130及剔除模块140。本申请所述模块也可以称之为单元,是指一种能够被电子设备处理器所执行,并且能够完成固定功能的一系列计算机程序段,其存储在电子设备的存储器中。
在本实施例中,关于各模块/单元的功能如下:
请求模块110,用于解析用户基于客户端发出的照片处理请求,获取所述请求携带的多张照片,所述多张照片为连续拍摄的照片。
照片模糊通常分为对焦模糊和运动模糊,当前更多的模糊照片是由运动模糊造成的,例如,拍照时手持摄像设备有抖动会产生运动模糊照片,本申请的目的在于通过限制手持 摄像设备的移动距离来减少产生模糊照片的可能性,故而先连续拍摄多张照片(大于或等于两张),通过判断照片中目标物体的移动距离来剔除模糊照片。
本实施例中,所述目标物体的边缘需要有留白,所述目标物体可以是身份证、驾驶证、护照、学位证、医保卡、银行卡、户口本,也可以是边缘有留白的书籍,本实施例默认每张照片中只有一个目标物体。
输入模块120,用于将所述多张照片输入训练好的边缘检测模型,得到每张照片中目标物体的各条边对应的初始直线函数,基于所述初始直线函数得到每张照片中目标物体的初始顶点坐标。
本实施例中,在将所述多张照片输入训练好的边缘检测模型之前,所述方法还包括:
A1、对所述多张照片中的每张照片执行尺寸归一化处理;
A2、对所述每张照片执行灰度归一化处理;
A3、对所述每张照片执行滤波处理。
本实施例中,尺寸归一化时将每张照片缩放到128*256的尺寸;通过浮点算法对照片执行灰度归一化处理,灰度归一化后的照片显示为从最暗黑色到最亮白色的灰度,灰度值范围为0~255;同时通过高斯滤波器对每张照片进行滤波处理。
所述边缘检测模型为神经网络模型,用于检测每张照片中目标物体的各条边对应的初始直线函数,即确定目标物体的各条边对应的直线方程式,例如,模型输出目标物体左侧边对应的直线方程式为y=ax+b,下侧边对应的直线方程式为y=cx+d,其中,a、b、c、d为常数。
所述边缘检测模型的训练过程包括:
B1、将携带标注信息的照片样本输入边缘检测模型得到每张照片样本中目标物体的各条边对应的预测直线函数;
B2、基于标注信息获取每张照片样本中目标物体的各条边对应的真实直线函数,通过最小化预测直线函数与真实直线函数之间的损失值确定所述边缘检测模型的权重参数,得到训练好的边缘检测模型。
所述损失值的计算公式为:
其中,q
mn为第m张照片样本中目标物体的第n条边对应的预测直线函数,p
mn为第m张照片样本中目标物体的第n条边对应的的真实直线函数,loss(q
nn,p
mn)为第m张照片样本中目标物体的第n条边对应的的预测直线函数与真实直线函数之间的损失值,c为照片样本的总数量,t为目标物体的边的总数量(本实施例中,t为4)。
将连续拍摄的多张照片输入训练好的边缘检测模型,输出每张照片中目标物体的各条边对应的初始直线函数,所述基于所述初始直线函数得到每张照片中目标物体的初始顶点坐标包括:
求解每张照片中目标物体的相邻两条边对应的初始直线函数的交点坐标,将所述交点坐标作为初始顶点坐标。
确定模块130,用于根据所述初始顶点坐标获取所述目标物体的各条边对应的初始区域,基于所述初始区域确定所述目标物体的各条边对应的目标直线函数,根据所述目标直线函数确定所述目标物体的中心点坐标。
本实施例中,所述根据所述初始顶点坐标获取所述目标物体的各条边对应的初始区域包括:
D1、以顺时针方向连接所述目标物体的各个初始顶点坐标得到所述目标物体的各条边对应的初始直线;
D2、以所述初始直线为对称轴,将所述初始直线向所述对称轴的两侧分别移动预设距 离,得到第一直线和第二直线,将所述第一直线和第二直线围成的区域作为所述各条边对应的初始区域。
例如,对于目标物体左侧边的初始直线(由多个坐标组成),沿x轴方向,向左移动预设距离(例如5),即初始直线的各个坐标的x轴坐标分别减5得到第一直线;然后,向右移动预设距离,即初始直线的各个坐标的x轴坐标分别加5得到第二直线;将第一直线与第二直线围成的区域作为左侧边的初始区域。
因通过边缘检测模型得到的初始直线函数并不准确,故而,本实施例以初始直线为对称轴对各条边进行扩展得到各条边的初始区域,扩大了目标物体边缘检测的范围,再对初始区域求目标直线函数,使得得到的目标直线函数更加准确。
所述基于所述初始区域确定所述目标物体的各条边对应的目标直线函数包括:
E1、以预设卷积核对所述初始区域执行卷积操作得到所述目标物体的各条边对应的第一区域;
本实施例中,所述预设卷积核包括第一卷积核和第二卷积核。
所述以预设卷积核对所述初始区域执行卷积操作包括:
将沿X轴伸展的初始直线对应的初始区域与所述第一卷积核执行卷积操作,将沿Y轴伸展的初始直线对应的初始区域与所述第二卷积核执行卷积操作。
卷积操作是对像素点邻点灰度加权,突出图像中的边缘。
E2、对所述第一区域执行二值化处理,将二值化处理后的第一区域平均分成预设数量的第二区域;
本实施例采用大津法OTSU的自适应二值化法对第一区域执行二值化处理,二值化处理后的图像只有黑色和白色,灰度值为0或255,从而得到的图像中颜色对比更加鲜明。
本实施例沿初始直线的方向对第一区域平均切分得到多个第二区域,例如,对于目标物体左侧边对应的初始区域,沿Y轴方向将其分为预设数量(例如20个)的第二区域。
E3、确定各个第二区域对应的直线端点坐标,基于所述直线端点坐标确定所述目标物体的各条边对应的目标直线函数。
本实施例中,所述确定各个第二区域对应的直线端点坐标包括:
采用霍夫变换算法检测所述各个第二区域中的直线,将检测到的直线中距离目标物体中心最近的直线的端点坐标作为所述各个第二区域对应的直线端点坐标。
因目标物体内容距离目标物体的边有留白,本实施例为剔除照片中目标物体外侧的干扰,将检测到的直线中距离目标物体中心最近的直线作为目标物体的边所在的直线。
所述基于所述直线端点坐标确定所述目标物体的各条边对应的目标直线函数包括:
F1、将所述目标物体的各条边对应的直线端点坐标的集合作为一个坐标集,将所述坐标集中的坐标两两组合,得到多个坐标组;
F2、计算所述坐标集中落在每个坐标组确定的直线函数上的坐标数量;
F3、将坐标数量最多的坐标组对应的直线函数作为所述各条边对应的目标直线函数。
两个坐标点可以确定一个直线函数,计算落在每个直线函数上的坐标的数量,将落入的坐标数量最多的直线函数作为各条边对应的目标直线函数。
本实施例中,所述根据所述目标直线函数确定所述目标物体的中心点坐标包括:
G1、将所述目标物体的相邻两条边对应的目标直线函数作为一个直线函数组,求解每 个直线函数组的交点坐标,将所述交点坐标作为目标顶点坐标;
G2、基于所述目标顶点坐标确定所述目标物体的中心点坐标。
假设照片中目标物体的四个目标顶点坐标分别为A(x1,y1)、B(x2,y2)、C(x3,y3)和D(x4,y4),则ABC三点中心坐标为:
cx01=(x1+x2+x3)/3
cy01=(y1+y2+y3)/3
ACD三点中心坐标为:
cx02=(x1+x3+x4)/3
cy02=(y1+y3+y4)/3
ABC面积为:
S1=(x1y2-x1y3+x2y3-x2y1+x3y1-x2y2)
ACD面积为:
S2=(x1y3-x1y4+x3y4-x3y1+x4y1-x3y3)
记d=S2/S1
则目标物体中心点坐标为:
cx=(x01+d*x02)/(1+d)
cy=(y01+d*y02)/(1+d)。
剔除模块140,用于将所述多张照片中相邻两张照片作为一个照片组,得到多个照片组,计算各个照片组中目标物体的中心点坐标的差值绝对值,将差值绝对值大于预设阈值的照片组中的第二张照片从所述多张照片中剔除,得到目标照片。
将多张连续拍摄的照片中相邻两张照片作为一个照片组,则每张照片都会与其前一张照片组成一个照片组,判断各个照片组中两张照片中目标物体的中心点坐标的差值绝对值是否大于预设阈值的目的是判断各个照片组中第二张照片拍摄时相对于第一张照片的移动距离是否过大,从而确定第二张照片是否会出现运动模糊。
如图3所示,为本申请一实施例提供的实现照片处理方法的电子设备的结构示意图。
所述电子设备1是一种能够按照事先设定或者存储的指令,自动进行数值计算和/或信息处理的设备。所述电子设备1可以是计算机、也可以是单个网络服务器、多个网络服务器组成的服务器组或者基于云计算的由大量主机或者网络服务器构成的云,其中云计算是分布式计算的一种,由一群松散耦合的计算机集组成的一个超级虚拟计算机。
在本实施例中,电子设备1包括,但不仅限于,可通过系统总线相互通信连接的存储器11、处理器12、网络接口13,该存储器11中存储有照片处理程序10,所述照片处理程序10可被所述处理器12执行。图3仅示出了具有组件11-13以及照片处理程序10的电子设备1,本领域技术人员可以理解的是,图3示出的结构并不构成对电子设备1的限定,可以包括比图示更少或者更多的部件,或者组合某些部件,或者不同的部件布置。
其中,存储器11包括内存及至少一种类型的可读存储介质。内存为电子设备1的运行提供缓存;可读存储介质可为如闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、随机访问存储器(RAM)、静态随机访问存储器(SRAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、可编程只读存储器(PROM)、磁性存储器、磁盘、光盘等的非易失性存储介质。在一些实施例中,可读存储介质可以是电子设备1的内部存储单元,例如该电子设备1的硬盘;在另一些实施例中,该非易失性存储介质也可以是电子设备1的外部存储设备,例如电子设备1上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。本实施例中,存储器11的可读存储介质通常用于存储安装于电子设备1的操作系统和各类应用软件,例如存储本申请一实施例中的照片处理程序10的代码等。此外,存储器11还可以用于暂时地存储已经输出或者将要输出的各类数据。
处理器12在一些实施例中可以是中央处理器(Central Processing Unit,CPU)、控制 器、微控制器、微处理器、或其他数据处理芯片。该处理器12通常用于控制所述电子设备1的总体操作,例如执行与其他设备进行数据交互或者通信相关的控制和处理等。本实施例中,所述处理器12用于运行所述存储器11中存储的程序代码或者处理数据,例如运行照片处理程序10等。
网络接口13可包括无线网络接口或有线网络接口,该网络接口13用于在所述电子设备1与客户端(图中未画出)之间建立通信连接。
可选的,所述电子设备1还可以包括用户接口,用户接口可以包括显示器(Display)、输入单元比如键盘(Keyboard),可选的用户接口还可以包括标准的有线接口、无线接口。可选的,在一些实施例中,显示器可以是LED显示器、液晶显示器、触控式液晶显示器以及OLED(Organic Light-Emitting Diode,有机发光二极管)触摸器等。其中,显示器也可以适当的称为显示屏或显示单元,用于显示在电子设备1中处理的信息以及用于显示可视化的用户界面。
应该了解,所述实施例仅为说明之用,在专利申请范围上并不受此结构的限制。
所述电子设备1中的所述存储器11存储的照片处理程序10是多个指令的组合,在所述处理器12中运行时,可以实现:
解析用户基于客户端发出的照片处理请求,获取所述照片处理请求携带的多张照片,所述多张照片为连续拍摄的照片;
将所述多张照片输入训练好的边缘检测模型,得到每张照片中目标物体的各条边对应的初始直线函数,基于所述初始直线函数得到每张照片中目标物体的初始顶点坐标;
根据所述初始顶点坐标获取所述目标物体的各条边对应的初始区域,基于所述初始区域确定所述目标物体的各条边对应的目标直线函数,根据所述目标直线函数确定所述目标物体的中心点坐标;
将所述多张照片中相邻两张照片作为一个照片组,得到多个照片组,计算各个照片组中目标物体的中心点坐标的差值绝对值,将差值绝对值大于预设阈值的照片组中的第二张照片从所述多张照片中剔除,得到目标照片。
具体地,所述处理器12对上述照片处理程序10的具体实现方法可参考图1对应实施例中相关步骤的描述,在此不赘述。需要强调的是,为进一步保证上述照片的私密和安全性,上述照片还可以存储于一区块链的节点中。
进一步地,所述电子设备1集成的模块/单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。所述计算机可读介质可以是非易失性的,也可以是非易失性的。所述计算机可读介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)。
所述计算机可读存储介质上存储有照片处理程序10,所述照片处理程序10可被一个或者多个处理器执行,本申请计算机可读存储介质具体实施方式与上述照片处理方法各实施例基本相同,在此不作赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的设备,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能模块的形式实现。
对于本领域技术人员而言,显然本申请不限于上述示范性实施例的细节,而且在不背离本申请的精神或基本特征的情况下,能够以其他的具体形式实现本申请。
因此,无论从哪一点来看,均应将实施例看作是示范性的,而且是非限制性的,本申请的范围由所附权利要求而不是上述说明限定,因此旨在将落在权利要求的等同要件的含义和范围内的所有变化涵括在本申请内。不应将权利要求中的任何附关联图标记视为限制所涉及的权利要求。
本申请所指区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链(Blockchain),本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括区块链底层平台、平台产品服务层以及应用服务层等。
此外,显然“包括”一词不排除其他单元或步骤,单数不排除复数。系统权利要求中陈述的多个单元或装置也可以由一个单元或装置通过软件或者硬件来实现。第二等词语用来表示名称,而并不表示任何特定的顺序。
最后应说明的是,以上实施例仅用以说明本申请的技术方案而非限制,尽管参照较佳实施例对本申请进行了详细说明,本领域的普通技术人员应当理解,可以对本申请的技术方案进行修改或等同替换,而不脱离本申请技术方案的精神和范围。
Claims (20)
- 一种照片处理方法,其中,所述方法包括:解析用户基于客户端发出的照片处理请求,获取所述照片处理请求携带的多张照片,所述多张照片为连续拍摄的照片;将所述多张照片输入训练好的边缘检测模型,得到每张照片中目标物体的各条边对应的初始直线函数,基于所述初始直线函数得到每张照片中目标物体的初始顶点坐标;根据所述初始顶点坐标获取所述目标物体的各条边对应的初始区域,基于所述初始区域确定所述目标物体的各条边对应的目标直线函数,根据所述目标直线函数确定所述目标物体的中心点坐标;将所述多张照片中相邻两张照片作为一个照片组,得到多个照片组,计算各个照片组中目标物体的中心点坐标的差值绝对值,将差值绝对值大于预设阈值的照片组中的第二张照片从所述多张照片中剔除,得到目标照片。
- 如权利要求1所述的照片处理方法,其中,所述根据所述初始顶点坐标获取所述目标物体的各条边对应的初始区域包括:以顺时针方向连接所述目标物体的各个初始顶点坐标得到所述目标物体的各条边对应的初始直线;以所述初始直线为对称轴,将所述初始直线向所述对称轴的两侧分别移动预设距离,得到第一直线和第二直线,将所述第一直线和第二直线围成的区域作为所述各条边对应的初始区域。
- 如权利要求2所述的照片处理方法,其中,所述基于所述初始区域确定所述目标物体的各条边对应的目标直线函数包括:以预设卷积核对所述初始区域执行卷积操作得到所述目标物体的各条边对应的第一区域;对所述第一区域执行二值化处理,将二值化处理后的第一区域平均分成预设数量的第二区域;确定各个第二区域对应的直线端点坐标,基于所述直线端点坐标确定所述目标物体的各条边对应的目标直线函数。
- 如权利要求3所述的照片处理方法,其中,所述预设卷积核包括第一卷积核和第二卷积核,所述以预设卷积核对所述初始区域执行卷积操作包括:将沿X轴伸展的初始直线对应的初始区域与所述第一卷积核执行卷积操作,将沿Y轴伸展的初始直线对应的初始区域与所述第二卷积核执行卷积操作。
- 如权利要求3所述的照片处理方法,其中,所述确定各个第二区域对应的直线端点坐标包括:采用霍夫变换算法检测所述各个第二区域中的直线,将检测到的直线中距离目标物体中心最近的直线的端点坐标作为所述各个第二区域对应的直线端点坐标。
- 如权利要求3所述的照片处理方法,其中,所述基于所述直线端点坐标确定所述目标物体的各条边对应的目标直线函数包括:将所述目标物体的各条边对应的直线端点坐标的集合作为一个坐标集,将所述坐标集中的坐标两两组合,得到多个坐标组;计算所述坐标集中落在每个坐标组确定的直线函数上的坐标数量;将坐标数量最多的坐标组对应的直线函数作为所述各条边对应的目标直线函数。
- 如权利要求1所述的照片处理方法,其中,所述根据所述目标直线函数确定所述目标物体的中心点坐标包括:将所述目标物体的相邻两条边对应的目标直线函数作为一个直线函数组,求解每个直 线函数组的交点坐标,将所述交点坐标作为目标顶点坐标;基于所述目标顶点坐标确定所述目标物体的中心点坐标。
- 一种照片处理装置,其中,所述装置包括:请求模块,用于解析用户基于客户端发出的照片处理请求,获取所述照片处理请求携带的多张照片,所述多张照片为连续拍摄的照片;输入模块,用于将所述多张照片输入训练好的边缘检测模型,得到每张照片中目标物体的各条边对应的初始直线函数,基于所述初始直线函数得到每张照片中目标物体的初始顶点坐标;确定模块,用于根据所述初始顶点坐标获取所述目标物体的各条边对应的初始区域,基于所述初始区域确定所述目标物体的各条边对应的目标直线函数,根据所述目标直线函数确定所述目标物体的中心点坐标;剔除模块,用于将所述多张照片中相邻两张照片作为一个照片组,得到多个照片组,计算各个照片组中目标物体的中心点坐标的差值绝对值,将差值绝对值大于预设阈值的照片组中的第二张照片从所述多张照片中剔除,得到目标照片。
- 一种电子设备,其中,所述电子设备包括:至少一个处理器;以及,与所述至少一个处理器通信连接的存储器;其中,所述存储器存储有可被所述至少一个处理器执行的照片处理程序,所述照片处理程序被所述至少一个处理器执行,以使所述至少一个处理器能够执行如下步骤:解析用户基于客户端发出的照片处理请求,获取所述照片处理请求携带的多张照片,所述多张照片为连续拍摄的照片;将所述多张照片输入训练好的边缘检测模型,得到每张照片中目标物体的各条边对应的初始直线函数,基于所述初始直线函数得到每张照片中目标物体的初始顶点坐标;根据所述初始顶点坐标获取所述目标物体的各条边对应的初始区域,基于所述初始区域确定所述目标物体的各条边对应的目标直线函数,根据所述目标直线函数确定所述目标物体的中心点坐标;将所述多张照片中相邻两张照片作为一个照片组,得到多个照片组,计算各个照片组中目标物体的中心点坐标的差值绝对值,将差值绝对值大于预设阈值的照片组中的第二张照片从所述多张照片中剔除,得到目标照片。
- 如权利要求9所述的电子设备,其中,所述根据所述初始顶点坐标获取所述目标物体的各条边对应的初始区域包括:以顺时针方向连接所述目标物体的各个初始顶点坐标得到所述目标物体的各条边对应的初始直线;以所述初始直线为对称轴,将所述初始直线向所述对称轴的两侧分别移动预设距离,得到第一直线和第二直线,将所述第一直线和第二直线围成的区域作为所述各条边对应的初始区域。
- 如权利要求10所述的电子设备,其中,所述基于所述初始区域确定所述目标物体的各条边对应的目标直线函数包括:以预设卷积核对所述初始区域执行卷积操作得到所述目标物体的各条边对应的第一区域;对所述第一区域执行二值化处理,将二值化处理后的第一区域平均分成预设数量的第二区域;确定各个第二区域对应的直线端点坐标,基于所述直线端点坐标确定所述目标物体的各条边对应的目标直线函数。
- 如权利要求11所述的电子设备,其中,所述预设卷积核包括第一卷积核和第二卷 积核,所述以预设卷积核对所述初始区域执行卷积操作包括:将沿X轴伸展的初始直线对应的初始区域与所述第一卷积核执行卷积操作,将沿Y轴伸展的初始直线对应的初始区域与所述第二卷积核执行卷积操作。
- 如权利要求11所述的电子设备,其中,所述确定各个第二区域对应的直线端点坐标包括:采用霍夫变换算法检测所述各个第二区域中的直线,将检测到的直线中距离目标物体中心最近的直线的端点坐标作为所述各个第二区域对应的直线端点坐标。
- 如权利要求11所述的电子设备,其中,所述基于所述直线端点坐标确定所述目标物体的各条边对应的目标直线函数包括:将所述目标物体的各条边对应的直线端点坐标的集合作为一个坐标集,将所述坐标集中的坐标两两组合,得到多个坐标组;计算所述坐标集中落在每个坐标组确定的直线函数上的坐标数量;将坐标数量最多的坐标组对应的直线函数作为所述各条边对应的目标直线函数。
- 如权利要求9所述的电子设备,其中,所述根据所述目标直线函数确定所述目标物体的中心点坐标包括:将所述目标物体的相邻两条边对应的目标直线函数作为一个直线函数组,求解每个直线函数组的交点坐标,将所述交点坐标作为目标顶点坐标;基于所述目标顶点坐标确定所述目标物体的中心点坐标。
- 一种计算机可读存储介质,其中,所述计算机可读存储介质上存储有照片处理程序,所述照片处理程序可被一个或者多个处理器执行,以实现如下步骤:解析用户基于客户端发出的照片处理请求,获取所述照片处理请求携带的多张照片,所述多张照片为连续拍摄的照片;将所述多张照片输入训练好的边缘检测模型,得到每张照片中目标物体的各条边对应的初始直线函数,基于所述初始直线函数得到每张照片中目标物体的初始顶点坐标;根据所述初始顶点坐标获取所述目标物体的各条边对应的初始区域,基于所述初始区域确定所述目标物体的各条边对应的目标直线函数,根据所述目标直线函数确定所述目标物体的中心点坐标;将所述多张照片中相邻两张照片作为一个照片组,得到多个照片组,计算各个照片组中目标物体的中心点坐标的差值绝对值,将差值绝对值大于预设阈值的照片组中的第二张照片从所述多张照片中剔除,得到目标照片。
- 如权利要求16所述的计算机可读存储介质,其中,所述根据所述初始顶点坐标获取所述目标物体的各条边对应的初始区域包括:以顺时针方向连接所述目标物体的各个初始顶点坐标得到所述目标物体的各条边对应的初始直线;以所述初始直线为对称轴,将所述初始直线向所述对称轴的两侧分别移动预设距离,得到第一直线和第二直线,将所述第一直线和第二直线围成的区域作为所述各条边对应的初始区域。
- 如权利要求17所述的计算机可读存储介质,其中,所述基于所述初始区域确定所述目标物体的各条边对应的目标直线函数包括:以预设卷积核对所述初始区域执行卷积操作得到所述目标物体的各条边对应的第一区域;对所述第一区域执行二值化处理,将二值化处理后的第一区域平均分成预设数量的第二区域;确定各个第二区域对应的直线端点坐标,基于所述直线端点坐标确定所述目标物体的各条边对应的目标直线函数。
- 如权利要求18所述的计算机可读存储介质,其中,所述预设卷积核包括第一卷积核和第二卷积核,所述以预设卷积核对所述初始区域执行卷积操作包括:将沿X轴伸展的初始直线对应的初始区域与所述第一卷积核执行卷积操作,将沿Y轴伸展的初始直线对应的初始区域与所述第二卷积核执行卷积操作。
- 如权利要求18所述的计算机可读存储介质,其中,所述确定各个第二区域对应的直线端点坐标包括:采用霍夫变换算法检测所述各个第二区域中的直线,将检测到的直线中距离目标物体中心最近的直线的端点坐标作为所述各个第二区域对应的直线端点坐标。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011019196.0A CN112150496B (zh) | 2020-09-24 | 2020-09-24 | 照片处理方法、装置、电子设备及可读存储介质 |
CN202011019196.0 | 2020-09-24 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2021189854A1 true WO2021189854A1 (zh) | 2021-09-30 |
Family
ID=73896972
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2020/125453 WO2021189854A1 (zh) | 2020-09-24 | 2020-10-30 | 照片处理方法、装置、电子设备及可读存储介质 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN112150496B (zh) |
WO (1) | WO2021189854A1 (zh) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080107186A1 (en) * | 2006-11-02 | 2008-05-08 | Mikhail Brusnitsyn | Method And Apparatus For Estimating And Compensating For Jitter In Digital Video |
CN102087652A (zh) * | 2009-12-08 | 2011-06-08 | 百度在线网络技术(北京)有限公司 | 图像筛选方法及其系统 |
CN109101963A (zh) * | 2018-08-10 | 2018-12-28 | 深圳市碧海扬帆科技有限公司 | 证件图像自动正向的方法、图像处理装置和可读存储介质 |
US20190019298A1 (en) * | 2017-07-13 | 2019-01-17 | Hanwha Land Systems Co., Ltd. | Real-time image processing system and method |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2019127075A1 (zh) * | 2017-12-27 | 2019-07-04 | 中国科学院深圳先进技术研究院 | 一种识别硬币年份的方法、终端设备及计算机可读存储介质 |
CN110136156B (zh) * | 2018-02-02 | 2020-12-01 | 北京三快在线科技有限公司 | 一种多边形区域检测方法及装置 |
GB2606859B (en) * | 2018-05-31 | 2023-09-06 | Canon Kk | An image processing system and apparatus, imaging apparatus, device, system/control methods, means for storage |
CN111080694A (zh) * | 2019-12-20 | 2020-04-28 | 上海眼控科技股份有限公司 | 定位模型的训练和定位方法、装置、设备以及存储介质 |
CN111563895A (zh) * | 2020-05-21 | 2020-08-21 | 苏州沃柯雷克智能系统有限公司 | 一种图片清晰度确定方法、装置、设备及存储介质 |
-
2020
- 2020-09-24 CN CN202011019196.0A patent/CN112150496B/zh active Active
- 2020-10-30 WO PCT/CN2020/125453 patent/WO2021189854A1/zh active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080107186A1 (en) * | 2006-11-02 | 2008-05-08 | Mikhail Brusnitsyn | Method And Apparatus For Estimating And Compensating For Jitter In Digital Video |
CN102087652A (zh) * | 2009-12-08 | 2011-06-08 | 百度在线网络技术(北京)有限公司 | 图像筛选方法及其系统 |
US20190019298A1 (en) * | 2017-07-13 | 2019-01-17 | Hanwha Land Systems Co., Ltd. | Real-time image processing system and method |
CN109101963A (zh) * | 2018-08-10 | 2018-12-28 | 深圳市碧海扬帆科技有限公司 | 证件图像自动正向的方法、图像处理装置和可读存储介质 |
Also Published As
Publication number | Publication date |
---|---|
CN112150496B (zh) | 2023-06-02 |
CN112150496A (zh) | 2020-12-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2021189853A1 (zh) | 闪光灯光斑位置识别方法、装置、电子设备及存储介质 | |
Chamoso et al. | A hash based image matching algorithm for social networks | |
WO2019174130A1 (zh) | 票据识别方法、服务器及计算机可读存储介质 | |
WO2019205369A1 (zh) | 电子装置、基于人脸图像与声纹信息的身份识别方法及存储介质 | |
WO2021233266A1 (zh) | 边缘检测方法和装置、电子设备和存储介质 | |
WO2020252920A1 (zh) | 图片校正方法、装置、计算机设备及计算机可读存储介质 | |
EP3665645B1 (en) | Reduction of glare in imaging documents | |
CN110427932A (zh) | 一种识别图像中多个票据区域的方法及装置 | |
CN111860489A (zh) | 一种证件图像校正方法、装置、设备及存储介质 | |
CN111595850A (zh) | 切片缺陷检测方法、电子装置及可读存储介质 | |
WO2020082731A1 (zh) | 电子装置、证件识别方法及存储介质 | |
CN110428414B (zh) | 一种识别图像中票据数量的方法及装置 | |
CN110852311A (zh) | 一种三维人手关键点定位方法及装置 | |
US11687886B2 (en) | Method and device for identifying number of bills and multiple bill areas in image | |
WO2021189856A1 (zh) | 证件校验方法、装置、电子设备及介质 | |
CN112434689A (zh) | 识别图片中信息的方法、装置、设备及存储介质 | |
CN108389053B (zh) | 支付方法、装置、电子设备及可读存储介质 | |
CN114494751A (zh) | 证照信息识别方法、装置、设备及介质 | |
CN112149570A (zh) | 多人活体检测方法、装置、电子设备及存储介质 | |
RU2672395C1 (ru) | Способ обучения классификатора, предназначенного для определения категории документа | |
WO2021139169A1 (zh) | 卡片识别方法、装置、设备及存储介质 | |
WO2021189854A1 (zh) | 照片处理方法、装置、电子设备及可读存储介质 | |
CN110689063B (zh) | 一种基于神经网络的证件识别的训练方法及装置 | |
WO2021151274A1 (zh) | 图像文档处理方法、装置、电子设备及计算机可读存储介质 | |
CN113870190B (zh) | 竖直线条检测方法、装置、设备及存储介质 |
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: 20926572 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: 20926572 Country of ref document: EP Kind code of ref document: A1 |