CN117830385A - Material pile volume measurement method, device, electronic equipment and storage medium - Google Patents

Material pile volume measurement method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117830385A
CN117830385A CN202410026700.1A CN202410026700A CN117830385A CN 117830385 A CN117830385 A CN 117830385A CN 202410026700 A CN202410026700 A CN 202410026700A CN 117830385 A CN117830385 A CN 117830385A
Authority
CN
China
Prior art keywords
window
frame image
material pile
image
left corner
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202410026700.1A
Other languages
Chinese (zh)
Inventor
赵英宝
张俊豪
李华伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hebei University of Science and Technology
Original Assignee
Hebei University of Science and Technology
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 Hebei University of Science and Technology filed Critical Hebei University of Science and Technology
Priority to CN202410026700.1A priority Critical patent/CN117830385A/en
Publication of CN117830385A publication Critical patent/CN117830385A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • G06T7/62Analysis of geometric attributes of area, perimeter, diameter or volume
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01BMEASURING LENGTH, THICKNESS OR SIMILAR LINEAR DIMENSIONS; MEASURING ANGLES; MEASURING AREAS; MEASURING IRREGULARITIES OF SURFACES OR CONTOURS
    • G01B11/00Measuring arrangements characterised by the use of optical techniques
    • G01B11/002Measuring arrangements characterised by the use of optical techniques for measuring two or more coordinates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/12Edge-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/194Segmentation; Edge detection involving foreground-background segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/50Depth or shape recovery
    • G06T7/55Depth or shape recovery from multiple images
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/80Analysis of captured images to determine intrinsic or extrinsic camera parameters, i.e. camera calibration
    • G06T7/85Stereo camera calibration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/74Image or video pattern matching; Proximity measures in feature spaces
    • G06V10/75Organisation of the matching processes, e.g. simultaneous or sequential comparisons of image or video features; Coarse-fine approaches, e.g. multi-scale approaches; using context analysis; Selection of dictionaries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10028Range image; Depth image; 3D point clouds

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • Databases & Information Systems (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Software Systems (AREA)
  • Artificial Intelligence (AREA)
  • Multimedia (AREA)
  • Geometry (AREA)
  • Length Measuring Devices By Optical Means (AREA)

Abstract

The invention provides a method and a device for measuring the volume of a material pile, electronic equipment and a storage medium. The method comprises the following steps: respectively acquiring material pile images under different visual angles; respectively carrying out background segmentation on each material pile image to obtain a frame image containing the material pile corresponding to each material pile image; dividing windows of each frame image respectively, and carrying out three-dimensional matching on the frame images based on gray average values and gradient information corresponding to each window to obtain optimal parallax of each corresponding window in each frame image; and determining three-dimensional point cloud data of the material pile based on the optimal parallax, and triangulating the three-dimensional point cloud data to obtain the volume of the material pile. The invention can improve the measurement precision of the volume of the material pile.

Description

物料堆体积测量方法、装置、电子设备及存储介质Material pile volume measurement method, device, electronic equipment and storage medium

技术领域Technical Field

本发明涉及机器视觉技术领域,尤其涉及一种物料堆体积测量方法、装置、电子设备及存储介质。The present invention relates to the field of machine vision technology, and in particular to a material pile volume measurement method, device, electronic equipment and storage medium.

背景技术Background technique

随着世界流通领域的高速发展,货物的流通速度也越来越快,企业对于精准盘库的需求也越来越高。目前火电厂、建筑工地、粮仓及港口等存在着大量的物料堆,需要精准计算物料堆的体积,从而合理的分配空间资源。但物料堆体积庞大且形状不规则,仅凭传统的衡器无法实现精准测量。With the rapid development of the world's circulation field, the circulation speed of goods is getting faster and faster, and enterprises have a higher demand for accurate inventory. At present, there are a large number of material piles in thermal power plants, construction sites, granaries and ports, and it is necessary to accurately calculate the volume of the material piles so as to reasonably allocate space resources. However, the material piles are large in size and irregular in shape, and it is impossible to achieve accurate measurement with traditional scales alone.

目前常见的物料堆体积测量方法有两种,分别为激光测量法和摄影测量法。激光测量法通过发射激光脉冲对物料堆进行测距,进而计算得到物料堆体积。激光测量法的测量精度较高,但测量过程复杂,速度较慢,且要求操作人员具有较高的专业水平,造价也相对昂贵。There are two common methods for measuring the volume of material piles, namely laser measurement and photogrammetry. The laser measurement method measures the distance of the material pile by emitting laser pulses, and then calculates the volume of the material pile. The laser measurement method has high measurement accuracy, but the measurement process is complicated, the speed is slow, and it requires operators to have a high level of professionalism. The cost is also relatively expensive.

摄影测量法则是通过多目相机对物料堆进行拍摄,并基于物料堆图像测量物料堆体积。摄影测量法具有操作简单、高效率及低成本等优点。但物料堆具有弱纹理性,且拍摄过程容易受到光照影响,导致体积测量精度较低。Photogrammetry is a method of photographing a material pile with a multi-camera and measuring the volume of the material pile based on the image of the material pile. Photogrammetry has the advantages of simple operation, high efficiency and low cost. However, the material pile has weak texture, and the shooting process is easily affected by light, resulting in low volume measurement accuracy.

发明内容Summary of the invention

本发明实施例提供了一种物料堆体积测量方法、装置、电子设备及存储介质,以解决基于物料堆图像测量物料堆体积时,体积测量精度较低的问题。Embodiments of the present invention provide a material pile volume measurement method, device, electronic device and storage medium to solve the problem of low volume measurement accuracy when measuring the material pile volume based on a material pile image.

第一方面,本发明实施例提供了一种物料堆体积测量方法,包括:In a first aspect, an embodiment of the present invention provides a method for measuring the volume of a material pile, comprising:

分别获取不同视角下的物料堆图像;Acquire images of the material pile at different viewing angles respectively;

分别对各物料堆图像进行背景分割,得到每一物料堆图像对应的包含物料堆的边框图像;Perform background segmentation on each material pile image respectively to obtain a frame image containing the material pile corresponding to each material pile image;

分别对各边框图像进行窗口划分,并基于各窗口对应的灰度均值和梯度信息对边框图像进行立体匹配,得到各边框图像中各对应窗口的最优视差;Divide each frame image into windows respectively, and perform stereo matching on the frame images based on the grayscale mean and gradient information corresponding to each window to obtain the optimal disparity of each corresponding window in each frame image;

基于所述最优视差,确定所述物料堆的三维点云数据,并对所述三维点云数据进行三角剖分,得到物料堆体积。Based on the optimal parallax, three-dimensional point cloud data of the material pile is determined, and the three-dimensional point cloud data is triangulated to obtain the volume of the material pile.

在一种可能的实现方式中,所述边框图像包括第一边框图像和第二边框图像;In a possible implementation, the frame image includes a first frame image and a second frame image;

所述分别对各边框图像进行窗口划分,并基于各窗口对应的灰度均值和梯度信息对边框图像进行立体匹配,得到各边框图像中各对应窗口的最优视差,包括:The step of dividing each frame image into windows and performing stereo matching on the frame images based on the grayscale mean and gradient information corresponding to each window to obtain the optimal disparity of each corresponding window in each frame image includes:

按照预设的窗口大小,分别将第一边框图像和第二边框图像划分为多个窗口;According to a preset window size, the first frame image and the second frame image are divided into a plurality of windows respectively;

分别计算各窗口对应的灰度均值和梯度信息,并基于各窗口对应的灰度均值和梯度信息,计算第一边框图像中各窗口与第二边框图像中各窗口之间的匹配代价;Calculating the grayscale mean and gradient information corresponding to each window respectively, and calculating the matching cost between each window in the first frame image and each window in the second frame image based on the grayscale mean and gradient information corresponding to each window;

基于所述匹配代价进行代价聚合、视差计算以及视差优化,得到最优视差图;其中,所述最优视差图中包括第一边框图像中各窗口与第二边框图像中对应窗口之间的最优视差。Cost aggregation, disparity calculation and disparity optimization are performed based on the matching cost to obtain an optimal disparity map; wherein the optimal disparity map includes the optimal disparity between each window in the first frame image and the corresponding window in the second frame image.

在一种可能的实现方式中,计算各窗口对应的灰度均值,包括:In a possible implementation, calculating the grayscale mean corresponding to each window includes:

根据计算各窗口对应的灰度均值;according to Calculate the grayscale mean corresponding to each window;

其中,Iavg(x,y)表示左上角顶点坐标为(x,y)的窗口对应的灰度均值,ω1表示窗口的长度,ω2表示窗口的宽度,i表示长度变量,j表示宽度变量,I(x+i,y+j)表示窗口中坐标为(x+i,y+j)的像素点的灰度值;Where, I avg (x, y) represents the grayscale mean corresponding to the window with the coordinates of the upper left corner vertex (x, y), ω 1 represents the length of the window, ω 2 represents the width of the window, i represents the length variable, j represents the width variable, and I(x+i, y+j) represents the grayscale value of the pixel point with coordinates (x+i, y+j) in the window;

所述梯度信息包括:归一化梯度幅值;计算各窗口对应的梯度信息,包括:The gradient information includes: normalized gradient amplitude; calculating the gradient information corresponding to each window, including:

分别获取各窗口对应的水平梯度向量和垂直梯度向量,并基于各窗口对应的水平梯度向量和垂直梯度向量,计算各窗口对应的梯度幅值;Obtaining the horizontal gradient vector and the vertical gradient vector corresponding to each window respectively, and calculating the gradient amplitude corresponding to each window based on the horizontal gradient vector and the vertical gradient vector corresponding to each window;

分别对各窗口对应的梯度幅值进行归一化处理,得到各窗口对应的归一化梯度幅值。The gradient amplitude corresponding to each window is normalized respectively to obtain the normalized gradient amplitude corresponding to each window.

在一种可能的实现方式中,基于各窗口对应的灰度均值和梯度信息,计算第一边框图像中各窗口与第二边框图像中各窗口之间的匹配代价,包括:In a possible implementation, based on the grayscale mean and gradient information corresponding to each window, the matching cost between each window in the first frame image and each window in the second frame image is calculated, including:

根据第一边框图像和第二边框图像中各窗口对应的灰度均值,分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的灰度差异;Calculating the grayscale differences between each window in the first border image and each window in the second border image according to the grayscale mean values corresponding to each window in the first border image and the second border image;

根据第一边框图像和第二边框图像中各窗口对应的梯度信息,分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的局部结构信息;Calculating local structural information between each window in the first frame image and each window in the second frame image according to gradient information corresponding to each window in the first frame image and the second frame image;

根据所述灰度差异和所述局部结构信息,分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的匹配代价。According to the grayscale difference and the local structure information, the matching cost between each window in the first frame image and each window in the second frame image is calculated respectively.

在一种可能的实现方式中,所述根据第一边框图像和第二边框图像中各窗口对应的灰度均值,分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的灰度差异,包括:In a possible implementation, calculating the grayscale difference between each window in the first border image and each window in the second border image according to the grayscale mean corresponding to each window in the first border image and the second border image, respectively, includes:

根据D(x,y)=|Ilavg(x,y)-Iravg(x,y)|分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的灰度差异;According to D(x,y)=|I lavg (x,y)-I ravg (x,y)|, the grayscale difference between each window in the first frame image and each window in the second frame image is calculated respectively;

其中,D(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中左上角顶点坐标为(x,y)的窗口之间的灰度差异,Ilavg(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口对应的灰度均值,Ilavg(x,y)表示第二边框图像中左上角顶点坐标为(x,y)的窗口对应的灰度均值。Among them, D(x,y) represents the grayscale difference between the window with the upper left corner vertex coordinates (x,y) in the first border image and the window with the upper left corner vertex coordinates (x,y) in the second border image, I lavg (x,y) represents the grayscale mean corresponding to the window with the upper left corner vertex coordinates (x,y) in the first border image, and I lavg (x,y) represents the grayscale mean corresponding to the window with the upper left corner vertex coordinates (x,y) in the second border image.

在一种可能的实现方式中,所述根据第一边框图像和第二边框图像中各窗口对应的梯度信息,分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的局部结构信息,包括:In a possible implementation, respectively calculating the local structural information between each window in the first frame image and each window in the second frame image according to the gradient information corresponding to each window in the first frame image and the second frame image includes:

根据S(x,y)=Nl(x,y)+Nr(x,y)分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的局部结构信息;According to S(x,y)=N l (x,y)+N r (x,y), local structural information between each window in the first frame image and each window in the second frame image is calculated respectively;

其中,S(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中左上角顶点坐标为(x,y)的窗口之间的局部结构信息,Nl(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口对应的梯度信息,Nr(x,y)表示第二边框图像中左上角顶点坐标为(x,y)的窗口对应的梯度信息。Among them, S(x,y) represents the local structural information between the window with the upper left corner vertex coordinates (x,y) in the first border image and the window with the upper left corner vertex coordinates (x,y) in the second border image, N l (x,y) represents the gradient information corresponding to the window with the upper left corner vertex coordinates (x,y) in the first border image, and N r (x,y) represents the gradient information corresponding to the window with the upper left corner vertex coordinates (x,y) in the second border image.

在一种可能的实现方式中,所述根据所述灰度差异和所述局部结构信息,分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的匹配代价,包括:In a possible implementation, respectively calculating the matching cost between each window in the first frame image and each window in the second frame image according to the grayscale difference and the local structure information includes:

根据C(x,y)=αD(x,y)+βS(x,y)分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的匹配代价;According to C(x,y)=αD(x,y)+βS(x,y), the matching cost between each window in the first frame image and each window in the second frame image is calculated respectively;

其中,C(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中左上角顶点坐标为(x,y)的窗口之间的匹配代价,α表示第一权重,β表示第二权重,D(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中左上角顶点坐标为(x,y)的窗口之间的灰度差异,S(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中左上角顶点坐标为(x,y)的窗口之间的局部结构信息。Among them, C(x,y) represents the matching cost between the window with the upper left corner vertex coordinates (x,y) in the first border image and the window with the upper left corner vertex coordinates (x,y) in the second border image, α represents the first weight, β represents the second weight, D(x,y) represents the grayscale difference between the window with the upper left corner vertex coordinates (x,y) in the first border image and the window with the upper left corner vertex coordinates (x,y) in the second border image, and S(x,y) represents the local structural information between the window with the upper left corner vertex coordinates (x,y) in the first border image and the window with the upper left corner vertex coordinates (x,y) in the second border image.

第二方面,本发明实施例提供了一种物料堆体积测量装置,包括:In a second aspect, an embodiment of the present invention provides a material pile volume measuring device, comprising:

获取模块,用于分别获取不同视角下的物料堆图像;An acquisition module, used to respectively acquire images of the material pile at different viewing angles;

处理模块,用于分别对各物料堆图像进行背景分割,得到每一物料堆图像对应的包含物料堆的边框图像;A processing module, used to perform background segmentation on each material pile image respectively, to obtain a frame image containing the material pile corresponding to each material pile image;

所述处理模块,还用于分别对各边框图像进行窗口划分,并基于各窗口对应的灰度均值和梯度信息对边框图像进行立体匹配,得到各边框图像中各对应窗口的最优视差;The processing module is further used to divide each frame image into windows respectively, and perform stereo matching on the frame images based on the grayscale mean and gradient information corresponding to each window to obtain the optimal disparity of each corresponding window in each frame image;

测量模块,用于基于所述最优视差,确定所述物料堆的三维点云数据,并对所述三维点云数据进行三角剖分,得到物料堆体积。A measurement module is used to determine the three-dimensional point cloud data of the material pile based on the optimal parallax, and triangulate the three-dimensional point cloud data to obtain the volume of the material pile.

第三方面,本发明实施例提供了一种电子设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现如上第一方面或第一方面的任一种可能的实现方式所述方法的步骤。In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the processor implements the steps of the method described in the first aspect or any possible implementation manner of the first aspect.

第四方面,本发明实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现如上第一方面或第一方面的任一种可能的实现方式所述方法的步骤。In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described in the first aspect or any possible implementation method of the first aspect are implemented.

本发明实施例提供一种物料堆体积测量方法、装置、电子设备及存储介质,通过对不同视角下的物料堆图像对应的包含物料堆的边框图像,进行窗口划分,并基于各窗口对应的灰度均值和梯度信息对边框图像进行立体匹配,得到最优视差,从而,基于最优视差确定物料堆体积。其中,通过进行窗口划分,并基于各窗口对应的灰度均值和梯度信息进行立体匹配,一方面可以捕捉边框图像中的微小变化,另一方面可以改善因光照影响而造成的纹理贫乏的情况,以提升立体匹配精度,进而提升物料堆体积测量精度。The embodiment of the present invention provides a material pile volume measurement method, device, electronic device and storage medium, which divides the frame image containing the material pile corresponding to the material pile image under different viewing angles into windows, and stereo matching the frame image based on the grayscale mean and gradient information corresponding to each window to obtain the optimal disparity, thereby determining the volume of the material pile based on the optimal disparity. Among them, by dividing the window and performing stereo matching based on the grayscale mean and gradient information corresponding to each window, on the one hand, it is possible to capture slight changes in the frame image, and on the other hand, it is possible to improve the texture poverty caused by the influence of lighting, so as to improve the stereo matching accuracy, and then improve the material pile volume measurement accuracy.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

为了更清楚地说明本发明实施例中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

图1是本发明实施例提供的物料堆体积测量方法的实现流程图;FIG1 is a flow chart of a method for measuring the volume of a material pile provided in an embodiment of the present invention;

图2是本发明实施例提供的确定最优视差的实现流程图;FIG2 is a flowchart of an implementation of determining an optimal disparity provided by an embodiment of the present invention;

图3是本发明实施例提供的计算匹配代价的实现流程图;FIG3 is a flowchart of an implementation of calculating a matching cost provided by an embodiment of the present invention;

图4是本发明实施例提供的物料堆体积测量装置的结构示意图;4 is a schematic diagram of the structure of a material pile volume measuring device provided in an embodiment of the present invention;

图5是本发明实施例提供的电子设备的示意图。FIG. 5 is a schematic diagram of an electronic device provided by an embodiment of the present invention.

具体实施方式Detailed ways

以下描述中,为了说明而不是为了限定,提出了诸如特定系统结构、技术之类的具体细节,以便透彻理解本发明实施例。然而,本领域的技术人员应当清楚,在没有这些具体细节的其它实施例中也可以实现本发明。在其它情况中,省略对众所周知的系统、装置、电路以及方法的详细说明,以免不必要的细节妨碍本发明的描述。In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.

相关技术中,物料堆体积测量方法有两种,分别为激光测量法和摄影测量法。激光测量法通过发射激光脉冲对物料堆进行测距,进而计算得到物料堆体积。激光测量法的测量精度较高,但测量过程复杂,速度较慢,且要求操作人员具有较高的专业水平,造价也相对昂贵。摄影测量法则是通过多目相机对物料堆进行拍摄,并基于物料堆图像测量物料堆体积。摄影测量法具有操作简单、高效率及低成本等优点。但物料堆具有弱纹理性,且拍摄过程容易受到光照影响,导致体积测量精度较低。In the related art, there are two methods for measuring the volume of material piles, namely laser measurement and photogrammetry. The laser measurement method measures the distance of the material pile by emitting laser pulses, and then calculates the volume of the material pile. The laser measurement method has high measurement accuracy, but the measurement process is complicated, the speed is slow, and the operator is required to have a high level of professionalism, and the cost is relatively expensive. The photogrammetry method is to shoot the material pile through a multi-eye camera and measure the volume of the material pile based on the image of the material pile. Photogrammetry has the advantages of simple operation, high efficiency and low cost. However, the material pile has weak texture, and the shooting process is easily affected by light, resulting in low volume measurement accuracy.

出于提高物料堆体积测量精度的想法,本实施例中,通过对物料堆图像对应的包含物料堆的边框图像,进行窗口划分,基于各窗口对应的灰度均值和梯度信息进行立体匹配,不仅可以捕捉边框图像中的微小变化,而且改善因光照影响而造成的纹理贫乏的情况,以提升立体匹配精度,进而提升物料堆体积测量精度。In order to improve the measurement accuracy of the material pile volume, in this embodiment, the border image containing the material pile corresponding to the material pile image is divided into windows, and stereo matching is performed based on the grayscale mean and gradient information corresponding to each window. This can not only capture slight changes in the border image, but also improve the texture poverty caused by lighting, so as to improve the stereo matching accuracy and thus improve the measurement accuracy of the material pile volume.

为使本发明的目的、技术方案和优点更加清楚,下面将结合附图通过具体实施例来进行说明。In order to make the purpose, technical solutions and advantages of the present invention more clear, specific embodiments will be described below in conjunction with the accompanying drawings.

图1为本发明实施例提供的物料堆体积测量方法的实现流程图,详述如下:FIG1 is a flow chart of a method for measuring the volume of a material pile provided by an embodiment of the present invention, which is described in detail as follows:

步骤101,分别获取不同视角下的物料堆图像。Step 101 : acquiring images of a material pile at different viewing angles respectively.

在获取不同视角下的物料堆图像时,本实施例可以分别采用预先标定好的多个相机,如第一相机和第二相机,从不同的视角获取物料堆图像,也可采用双目相机获取不同视角下的物料堆图像。When acquiring images of the material pile at different viewing angles, the present embodiment may respectively use a plurality of pre-calibrated cameras, such as a first camera and a second camera, to acquire images of the material pile from different viewing angles, or may use a binocular camera to acquire images of the material pile at different viewing angles.

其中,本实施例在采用双目相机获取不同视角下的物料堆图像之前,可以预先对相机进行标定和立体校正。In this embodiment, before using a binocular camera to obtain images of a material pile at different viewing angles, the camera may be calibrated and stereo corrected in advance.

如以对双目相机进行标定为例,本实施例在对双目相机进行标定时,可以采用预设标定法,如张正友标定法。可选地,本实施例可以采用待标定的双目相机对棋盘格标定板进行多次拍摄,期间不断调整棋盘格的角度和距离。利用交点检测算法提取拍摄图像中的角点坐标。基于角点坐标求解单应性矩阵,从而计算得到双目相机的内外参数,并利用最小二乘法求取双目相机的畸变系数。对双目相机的内外参数和畸变系数进行优化,得到优化后的内外参数和畸变系数,完成标定。Taking the calibration of a binocular camera as an example, this embodiment can use a preset calibration method, such as Zhang Zhengyou's calibration method, when calibrating the binocular camera. Optionally, this embodiment can use the binocular camera to be calibrated to shoot a checkerboard calibration plate multiple times, and continuously adjust the angle and distance of the checkerboard during the process. The intersection detection algorithm is used to extract the coordinates of the corner points in the captured image. The homography matrix is solved based on the corner point coordinates to calculate the internal and external parameters of the binocular camera, and the distortion coefficient of the binocular camera is obtained using the least squares method. The internal and external parameters and distortion coefficient of the binocular camera are optimized to obtain the optimized internal and external parameters and distortion coefficient, and the calibration is completed.

这里,本实施例可以基于上述优化后的内外参数和畸变系数,利用Bouguet算法使双目相机拍摄的左右两幅图像的平面原点坐标相同,实现面对准与行对齐,从而完成双目相机的立体校正。校正之后的左右图像消除了镜头畸变,左右视图的极线都相互平行,对应点的纵坐标一致。Here, this embodiment can use the Bouguet algorithm to make the plane origin coordinates of the left and right images taken by the binocular camera the same based on the optimized internal and external parameters and distortion coefficients, so as to achieve surface alignment and row alignment, thereby completing the stereo calibration of the binocular camera. The left and right images after calibration eliminate lens distortion, the epipolar lines of the left and right views are parallel to each other, and the ordinates of the corresponding points are consistent.

步骤102,分别对各物料堆图像进行背景分割,得到每一物料堆图像对应的包含物料堆的边框图像。Step 102 : performing background segmentation on each material pile image respectively to obtain a frame image including the material pile corresponding to each material pile image.

其中,本实施例通过对物料堆图像进行背景分割,可以将物料堆图像中的背景剔除,只保留物料堆,提高后续处理结果的准确性。Among them, this embodiment can remove the background in the material pile image by performing background segmentation on the material pile image, and only retain the material pile, thereby improving the accuracy of subsequent processing results.

在对物料堆图像进行背景分割时,本实施例可以采用预设分割方法,如最大类间方差法。本实施例可以通过遍历的方法得到使类间方差最大的像素阈值。基于各像素点的像素值与像素阈值之间的大小关系,进而确定属于物料堆的各像素点。When performing background segmentation on the material pile image, this embodiment may adopt a preset segmentation method, such as the maximum inter-class variance method. This embodiment may obtain the pixel threshold that maximizes the inter-class variance by a traversal method. Based on the size relationship between the pixel value of each pixel point and the pixel threshold, each pixel point belonging to the material pile is further determined.

可以理解的是,物料堆的形状并不规则。为便于后续计算,本发明实施例将物料堆对应的矩形区域确定为边框图像,并基于边框图像执行后续步骤。其中,物料堆对应的矩形区域为包含物料堆外边界的最小矩形区域。It is understandable that the shape of the material pile is irregular. To facilitate subsequent calculations, the embodiment of the present invention determines the rectangular area corresponding to the material pile as a frame image, and performs subsequent steps based on the frame image. The rectangular area corresponding to the material pile is the smallest rectangular area containing the outer boundary of the material pile.

步骤103,分别对各边框图像进行窗口划分,并基于各窗口对应的灰度均值和梯度信息对边框图像进行立体匹配,得到各边框图像中各对应窗口的最优视差。Step 103 , divide each frame image into windows respectively, and perform stereo matching on the frame images based on the grayscale mean and gradient information corresponding to each window, so as to obtain the optimal disparity of each corresponding window in each frame image.

本发明实施例通过对各边框图像进行窗口划分,并基于各窗口对应的灰度均值和梯度信息进行边框图像的立体匹配,可以捕捉边框图像中的微小变化,进而提升立体匹配的准确度,减少误匹配。尤其是针对细节丰富的区域,其立体匹配的准确度可以大幅提高。The embodiment of the present invention can capture small changes in the frame image by dividing each frame image into windows and performing stereo matching of the frame image based on the grayscale mean and gradient information corresponding to each window, thereby improving the accuracy of stereo matching and reducing mismatching. In particular, the accuracy of stereo matching can be greatly improved for areas with rich details.

其中,边框图像包括第一边框图像和第二边框图像。The frame image includes a first frame image and a second frame image.

在一些实施例中,参见图2,上述分别对各边框图像进行窗口划分,并基于各窗口对应的灰度均值和梯度信息对边框图像进行立体匹配,得到各边框图像中各对应窗口的最优视差,可以包括:In some embodiments, referring to FIG. 2 , the above-mentioned window division of each frame image, and stereo matching of the frame images based on the grayscale mean and gradient information corresponding to each window, to obtain the optimal disparity of each corresponding window in each frame image, may include:

步骤201,按照预设的窗口大小,分别将第一边框图像和第二边框图像划分为多个窗口。Step 201 : dividing the first frame image and the second frame image into a plurality of windows respectively according to preset window sizes.

示例性地,预设的窗口大小可以为5×5或7×7,即,5个像素点×5个像素点,或7个像素点×7个像素点。基于预设的窗口大小可以分别将第一边框图像和第二边框图像划分为多个窗口。Exemplarily, the preset window size may be 5×5 or 7×7, that is, 5 pixels×5 pixels, or 7 pixels×7 pixels. Based on the preset window size, the first frame image and the second frame image may be divided into a plurality of windows respectively.

步骤202,分别计算各窗口对应的灰度均值和梯度信息,并基于各窗口对应的灰度均值和梯度信息,计算第一边框图像中各窗口与第二边框图像中各窗口之间的匹配代价。Step 202, respectively calculating the grayscale mean and gradient information corresponding to each window, and based on the grayscale mean and gradient information corresponding to each window, calculating the matching cost between each window in the first frame image and each window in the second frame image.

在一些实施例中,计算各窗口对应的灰度均值,包括:In some embodiments, calculating the grayscale mean corresponding to each window includes:

根据计算各窗口对应的灰度均值;according to Calculate the grayscale mean corresponding to each window;

其中,Iavg(x,y)表示左上角顶点坐标为(x,y)的窗口对应的灰度均值,ω1表示窗口的长度,ω2表示窗口的宽度,i表示长度变量,j表示宽度变量,I(x+i,y+j)表示窗口中坐标为(x+i,y+j)的像素点的灰度值。其中,1≤i≤ω1,1≤j≤ω2Where, I avg (x, y) represents the grayscale mean corresponding to the window with the coordinates of the upper left corner vertex (x, y), ω 1 represents the length of the window, ω 2 represents the width of the window, i represents the length variable, j represents the width variable, and I(x+i, y+j) represents the grayscale value of the pixel point with the coordinates (x+i, y+j) in the window. Where, 1≤i≤ω 1 , 1≤j≤ω 2 .

实质上,对于每一窗口,本发明实施例计算该窗口内所有像素点的灰度值的平均值,并将该平均值确定为该窗口对应得到灰度均值。In essence, for each window, the embodiment of the present invention calculates the average value of the grayscale values of all pixels in the window, and determines the average value as the grayscale mean value corresponding to the window.

需要说明的是,上述左上角顶点坐标(x,y)指的是位于图像像素坐标系下的坐标信息。相应地,上述坐标(x+i,y+j)同样是指位于图像像素坐标系下的坐标信息。It should be noted that the coordinates (x, y) of the upper left corner refer to the coordinate information in the image pixel coordinate system. Correspondingly, the coordinates (x+i, y+j) also refer to the coordinate information in the image pixel coordinate system.

在一些实施例中,梯度信息包括:归一化梯度幅值。计算各窗口对应的梯度信息,可以包括:In some embodiments, the gradient information includes: normalized gradient magnitude. Calculating the gradient information corresponding to each window may include:

分别获取各窗口对应的水平梯度向量和垂直梯度向量,并基于各窗口对应的水平梯度向量和垂直梯度向量,计算各窗口对应的梯度幅值。The horizontal gradient vector and the vertical gradient vector corresponding to each window are obtained respectively, and the gradient amplitude corresponding to each window is calculated based on the horizontal gradient vector and the vertical gradient vector corresponding to each window.

分别对各窗口对应的梯度幅值进行归一化处理,得到各窗口对应的归一化梯度幅值。The gradient amplitude corresponding to each window is normalized respectively to obtain the normalized gradient amplitude corresponding to each window.

其中,本实施例可以采用Sobel、Prewitt或Scharr等滤波器可以分别获取各窗口对应的水平梯度向量和垂直梯度向量。In this embodiment, filters such as Sobel, Prewitt or Scharr can be used to respectively obtain the horizontal gradient vector and the vertical gradient vector corresponding to each window.

根据可以计算各窗口对应的梯度幅值。according to The gradient amplitude corresponding to each window can be calculated.

其中,G(x,y)表示左上角顶点坐标为(x,y)的窗口对应的梯度幅值,IX(x,y)表示左上角顶点坐标为(x,y)的窗口对应的水平梯度向量,IY(x,y)表示左上角顶点坐标为(x,y)的窗口对应的垂直梯度向量。Among them, G(x,y) represents the gradient amplitude corresponding to the window with the upper left corner vertex coordinates (x,y), I X (x,y) represents the horizontal gradient vector corresponding to the window with the upper left corner vertex coordinates (x,y), and I Y (x,y) represents the vertical gradient vector corresponding to the window with the upper left corner vertex coordinates (x,y).

根据可以得到各窗口对应的归一化梯度幅值。according to The normalized gradient amplitude corresponding to each window can be obtained.

其中,N(x,y)表示左上角顶点坐标为(x,y)的窗口对应的归一化梯度幅值,maxG表示上述左上角顶点坐标为(x,y)的窗口所在的边框图像中,各窗口对应的归一化梯度幅值中的最大值。Among them, N(x,y) represents the normalized gradient amplitude corresponding to the window with the upper left corner vertex coordinate (x,y), and maxG represents the maximum value of the normalized gradient amplitudes corresponding to each window in the border image where the window with the upper left corner vertex coordinate (x,y) is located.

在一些实施例中,参见图3,上述基于各窗口对应的灰度均值和梯度信息,计算第一边框图像中各窗口与第二边框图像中各窗口之间的匹配代价,可以包括:In some embodiments, referring to FIG. 3 , the above-mentioned calculation of the matching cost between each window in the first frame image and each window in the second frame image based on the grayscale mean and gradient information corresponding to each window may include:

步骤301,根据第一边框图像和第二边框图像中各窗口对应的灰度均值,分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的灰度差异。Step 301 , calculating the grayscale differences between each window in the first frame image and each window in the second frame image according to the grayscale means corresponding to each window in the first frame image and the second frame image.

在一些实施例中,可以根据D(x,y)=|Ilavg(x,y)-Iravg(x,y)|分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的灰度差异;In some embodiments, the grayscale difference between each window in the first frame image and each window in the second frame image may be calculated according to D(x,y)=|I lavg (x,y)-I ravg (x,y)|;

其中,D(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中左上角顶点坐标为(x,y)的窗口之间的灰度差异,Ilavg(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口对应的灰度均值,Ilavg(x,y)表示第二边框图像中左上角顶点坐标为(x,y)的窗口对应的灰度均值。Among them, D(x,y) represents the grayscale difference between the window with the upper left corner vertex coordinates (x,y) in the first border image and the window with the upper left corner vertex coordinates (x,y) in the second border image, I lavg (x,y) represents the grayscale mean corresponding to the window with the upper left corner vertex coordinates (x,y) in the first border image, and I lavg (x,y) represents the grayscale mean corresponding to the window with the upper left corner vertex coordinates (x,y) in the second border image.

上述灰度差异计算公式示例性地示出了第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中左上角顶点坐标为(x,y)的窗口之间的灰度差异的计算方法。本发明实施例基于该计算方法分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的灰度差异。The grayscale difference calculation formula exemplarily shows a method for calculating the grayscale difference between a window with a top left corner vertex coordinate of (x, y) in the first frame image and a window with a top left corner vertex coordinate of (x, y) in the second frame image. The embodiment of the present invention calculates the grayscale difference between each window in the first frame image and each window in the second frame image based on the calculation method.

步骤302,根据第一边框图像和第二边框图像中各窗口对应的梯度信息,分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的局部结构信息。Step 302 : calculating local structural information between each window in the first frame image and each window in the second frame image according to the gradient information corresponding to each window in the first frame image and the second frame image.

在一些实施例中,可以根据S(x,y)=Nl(x,y)+Nr(x,y)分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的局部结构信息;In some embodiments, the local structural information between each window in the first frame image and each window in the second frame image may be calculated according to S(x,y)=N l (x,y)+N r (x,y);

其中,S(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中左上角顶点坐标为(x,y)的窗口之间的局部结构信息,Nl(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口对应的梯度信息,Nr(x,y)表示第二边框图像中左上角顶点坐标为(x,y)的窗口对应的梯度信息。Among them, S(x,y) represents the local structural information between the window with the upper left corner vertex coordinates (x,y) in the first border image and the window with the upper left corner vertex coordinates (x,y) in the second border image, N l (x,y) represents the gradient information corresponding to the window with the upper left corner vertex coordinates (x,y) in the first border image, and N r (x,y) represents the gradient information corresponding to the window with the upper left corner vertex coordinates (x,y) in the second border image.

上述局部结构信息计算公式示例性地示出了第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中左上角顶点坐标为(x,y)的窗口之间的局部结构信息的计算方法。本发明实施例基于该计算方法分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的局部结构信息。The above local structure information calculation formula exemplarily shows a method for calculating the local structure information between a window with a top left vertex coordinate of (x, y) in the first frame image and a window with a top left vertex coordinate of (x, y) in the second frame image. The embodiment of the present invention calculates the local structure information between each window in the first frame image and each window in the second frame image based on the calculation method.

步骤303,根据灰度差异和局部结构信息,分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的匹配代价。Step 303: Calculate the matching cost between each window in the first frame image and each window in the second frame image according to the grayscale difference and the local structure information.

在一些实施例中,可以根据C(x,y)=αD(x,y)+βS(x,y)分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的匹配代价;In some embodiments, the matching cost between each window in the first frame image and each window in the second frame image may be calculated according to C(x, y)=αD(x, y)+βS(x, y);

其中,C(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中左上角顶点坐标为(x,y)的窗口之间的匹配代价,α表示第一权重,β表示第二权重,D(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中左上角顶点坐标为(x,y)的窗口之间的灰度差异,S(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中左上角顶点坐标为(x,y)的窗口之间的局部结构信息。Among them, C(x,y) represents the matching cost between the window with the upper left corner vertex coordinates (x,y) in the first border image and the window with the upper left corner vertex coordinates (x,y) in the second border image, α represents the first weight, β represents the second weight, D(x,y) represents the grayscale difference between the window with the upper left corner vertex coordinates (x,y) in the first border image and the window with the upper left corner vertex coordinates (x,y) in the second border image, and S(x,y) represents the local structural information between the window with the upper left corner vertex coordinates (x,y) in the first border image and the window with the upper left corner vertex coordinates (x,y) in the second border image.

上述匹配代价计算公式示例性地示出了第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中左上角顶点坐标为(x,y)的窗口之间的匹配代价的计算方法。本发明实施例基于该计算方法分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的匹配代价。The above matching cost calculation formula exemplarily shows a method for calculating the matching cost between a window with a top left corner vertex coordinate of (x, y) in the first frame image and a window with a top left corner vertex coordinate of (x, y) in the second frame image. The embodiment of the present invention calculates the matching cost between each window in the first frame image and each window in the second frame image based on the calculation method.

考虑到物料堆具有弱纹理性且在拍摄过程中容易受到光照影响,进而导致拍摄到的物料堆图像纹理贫乏。本发明实施例基于各窗口对应的灰度均值计算各窗口之间的灰度差异,有助于抵抗纹理贫乏的情况。并且本发明实施例在灰度差异的基础上结合局部结构信息计算匹配代价,进而完成立体匹配,解决了因物料堆图像纹理贫乏而导致的立体匹配精度较低的问题,提升匹配代价的计算精度,从而提升物料堆体积测量精度。Considering that the material pile has weak texture and is easily affected by light during the shooting process, the texture of the captured material pile image is poor. The embodiment of the present invention calculates the grayscale difference between each window based on the grayscale mean corresponding to each window, which helps to resist the situation of poor texture. In addition, the embodiment of the present invention calculates the matching cost based on the grayscale difference and combines the local structure information to complete the stereo matching, which solves the problem of low stereo matching accuracy caused by the poor texture of the material pile image, improves the calculation accuracy of the matching cost, and thus improves the accuracy of the material pile volume measurement.

步骤203,基于匹配代价进行代价聚合、视差计算以及视差优化,得到最优视差图。其中,最优视差图中包括第一边框图像中各窗口与第二边框图像中对应窗口之间的最优视差。Step 203: Perform cost aggregation, disparity calculation and disparity optimization based on the matching cost to obtain an optimal disparity map, wherein the optimal disparity map includes the optimal disparity between each window in the first frame image and the corresponding window in the second frame image.

在对匹配代价进行代价聚合时,可以采用平均滤波的方法,从而减小图像噪声对于匹配代价的影响,使得聚合后的匹配代价更加平滑。平均滤波的计算公式为: When performing cost aggregation on the matching cost, the average filtering method can be used to reduce the impact of image noise on the matching cost and make the aggregated matching cost smoother. The calculation formula of the average filtering is:

其中,Csmooth(x,y)表示经代价聚合处理后,第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中各窗口之间的平滑代价,N表示第一边框图像中左上角顶点坐标为(x,y)的窗口的邻域内的窗口数量,n表示第一边框图像中左上角顶点坐标为(x,y)的窗口的邻域内的第n个窗口,C(n)表示第一边框图像中左上角顶点坐标为(x,y)的窗口的邻域内的第n个窗口与第二边框图像中各窗口之间的匹配代价。Among them, C smooth (x, y) represents the smoothing cost between the window with the upper left corner vertex coordinates (x, y) in the first border image and each window in the second border image after cost aggregation processing, N represents the number of windows in the neighborhood of the window with the upper left corner vertex coordinates (x, y) in the first border image, n represents the nth window in the neighborhood of the window with the upper left corner vertex coordinates (x, y) in the first border image, and C(n) represents the matching cost between the nth window in the neighborhood of the window with the upper left corner vertex coordinates (x, y) in the first border image and each window in the second border image.

本发明实施例基于第一边框图像中各窗口与第二边框图像中各窗口之间的平滑代价进行视差计算。其中,平滑代价用于反映两个窗口之间的相似性。平滑代价越小,窗口越相似。针对第一边框图像中的每一个窗口,将第二边框图像中与该窗口之间的平滑代价最小的窗口,确定为该窗口的同名点。分别计算第一边框图像中每一个窗口与其同名点之间的坐标差,该坐标差即为视差。第一边框图像中每一个窗口与其同名点之间的视差,构成视差图。本发明实施例中将窗口的中心位置处的像素点坐标确定为窗口的坐标。The embodiment of the present invention calculates disparity based on the smoothing cost between each window in the first border image and each window in the second border image. The smoothing cost is used to reflect the similarity between two windows. The smaller the smoothing cost, the more similar the windows are. For each window in the first border image, the window with the smallest smoothing cost between the window and the second border image is determined as the same-name point of the window. The coordinate difference between each window in the first border image and its same-name point is calculated respectively, and the coordinate difference is the disparity. The disparity between each window in the first border image and its same-name point constitutes a disparity map. In the embodiment of the present invention, the coordinates of the pixel point at the center position of the window are determined as the coordinates of the window.

本发明实施例在计算视差的基础上,进一步进行视差优化,以提升视差精度,得到最优视差图。视差优化的具体流程为:首先对视差图使用一致性检查,对错误视差和无效视差进行剔除和填充。然后通过子像素拟合技术视差图中的各视差值进行拟合优化,最后采用中值滤波对视差图进行平滑处理,得到最优视差图。最优视差图中包括第一边框图像中各窗口与第二边框图像中对应窗口之间的最优视差。其中,第二边框图像中对应窗口即为第一边框图像中各窗口的同名点。Based on the calculated disparity, the embodiment of the present invention further performs disparity optimization to improve the disparity accuracy and obtain the optimal disparity map. The specific process of disparity optimization is: first, the disparity map is subjected to consistency check, and the erroneous disparity and invalid disparity are eliminated and filled. Then, the disparity values in the disparity map are fitted and optimized by sub-pixel fitting technology, and finally the disparity map is smoothed by median filtering to obtain the optimal disparity map. The optimal disparity map includes the optimal disparity between each window in the first border image and the corresponding window in the second border image. Among them, the corresponding window in the second border image is the same-name point of each window in the first border image.

步骤104,基于最优视差,确定物料堆的三维点云数据,并对三维点云数据进行三角剖分,得到物料堆体积。Step 104 , based on the optimal parallax, determine the three-dimensional point cloud data of the material pile, and triangulate the three-dimensional point cloud data to obtain the volume of the material pile.

本发明实施例通过获取相机基线和相机焦距,并基于相机基线、相机焦距和最优视差,计算得到物料堆的深度信息。物料堆的深度信息包括各窗口对应的深度信息。The embodiment of the present invention obtains the camera baseline and the camera focal length, and calculates the depth information of the material pile based on the camera baseline, the camera focal length and the optimal parallax. The depth information of the material pile includes the depth information corresponding to each window.

根据可以计算得到各窗口对应的深度信息。according to The depth information corresponding to each window can be calculated.

其中,Z表示各窗口对应的深度信息,即各窗口在世界坐标系下对应的竖坐标,b表示相机基线,f表示相机焦距,d表示各窗口对应的最优视差。Among them, Z represents the depth information corresponding to each window, that is, the vertical coordinate corresponding to each window in the world coordinate system, b represents the camera baseline, f represents the camera focal length, and d represents the optimal disparity corresponding to each window.

本发明实施例采用重投影映射的方法将最优视差图映射到世界坐标系中,可以得到三维点云数据。重投影映射过程中涉及图像像素坐标系、图像物理坐标系、相机坐标系以及世界坐标系。上述4种坐标系存在以下变换关系:The embodiment of the present invention uses a reprojection mapping method to map the optimal disparity map to the world coordinate system, and three-dimensional point cloud data can be obtained. The reprojection mapping process involves the image pixel coordinate system, the image physical coordinate system, the camera coordinate system, and the world coordinate system. The above four coordinate systems have the following transformation relationship:

其中,Zc表示相机坐标系中的竖坐标,u表示图像像素坐标系中的横坐标,v表示图像像素坐标系中的纵坐标,fx、fy、u0和v0为相机参数,R3×3表示相机的旋转矩阵,T3×1表示相机的平移向量,Xw表示世界坐标系中横坐标,Yw表示世界坐标系中的纵坐标,Zw表示世界坐标系中的竖坐标。Among them, Zc represents the vertical coordinate in the camera coordinate system, u represents the horizontal coordinate in the image pixel coordinate system, v represents the vertical coordinate in the image pixel coordinate system, fx , fy , u0 and v0 are camera parameters, R3 ×3 represents the rotation matrix of the camera, T3 ×1 represents the translation vector of the camera, Xw represents the horizontal coordinate in the world coordinate system, Yw represents the vertical coordinate in the world coordinate system, and Zw represents the vertical coordinate in the world coordinate system.

本发明实施例对上述变换关系进行逆变换,并将各窗口对应的深度信息、相机参数以及各窗口在图像像素坐标下对应的坐标信息带入,即可计算得到各窗口在世界坐标系下对应的坐标信息,即,三维点云数据。The embodiment of the present invention performs an inverse transformation on the above transformation relationship, and inputs the depth information, camera parameters and coordinate information corresponding to each window in the image pixel coordinates, so as to calculate the coordinate information corresponding to each window in the world coordinate system, that is, three-dimensional point cloud data.

在对三维点云数据进行三角剖分时,可以采用Delaunay三角剖分算法。Delaunay三角剖分算法将三维点云数据投影到xoy基准平面上,并在xoy基准平面上构建三角网格,使得每个三角网格的顶点都与物料堆的三维点云数据对应,即,xoy基准平面上的每个三角形都与物料堆表面的三角形对应,并组成一个空间几何体。最终将三维点云数据剖分为多个空间几何体。其中,每一个空间体都由一个三棱柱和两个四面体构成。基于体积计算公式可以计算各三棱柱和各四面体的体积,进而得到各空间几何体的体积。所有空间几何体的体积之和即为物料堆体积。When triangulating three-dimensional point cloud data, the Delaunay triangulation algorithm can be used. The Delaunay triangulation algorithm projects the three-dimensional point cloud data onto the xoy reference plane and constructs a triangular mesh on the xoy reference plane, so that the vertices of each triangular mesh correspond to the three-dimensional point cloud data of the material pile, that is, each triangle on the xoy reference plane corresponds to the triangle on the surface of the material pile, and forms a spatial geometric body. Finally, the three-dimensional point cloud data is divided into multiple spatial geometric bodies. Among them, each spatial body is composed of a triangular prism and two tetrahedrons. Based on the volume calculation formula, the volume of each triangular prism and each tetrahedron can be calculated, and then the volume of each spatial geometric body can be obtained. The sum of the volumes of all spatial geometric bodies is the volume of the material pile.

在进行空间资源分配时,分别获取各空间的待占用体积,并将待占用体积与物料堆体积相同的空间分配给物料堆。若不存在待占用体积与物料堆体积相同的空间时,确定待占用体积大于物料堆体积的所有空间,并将待占用体积大于物料堆体积的所有空间中,待占用体积最小的空间分配给物料堆。When allocating space resources, the volume to be occupied of each space is obtained respectively, and the space with the same volume to be occupied as the material pile is allocated to the material pile. If there is no space with the same volume to be occupied as the material pile, all spaces with a volume to be occupied greater than the material pile volume are determined, and among all spaces with a volume to be occupied greater than the material pile volume, the space with the smallest volume to be occupied is allocated to the material pile.

相比于现有技术,本发明实施例通过对各边框图像进行窗口划分,并基于各窗口对应的灰度均值和梯度信息对边框图像进行立体匹配,得到最优视差;基于最优视差进而确定物料堆体积。其中,通过进行窗口划分,并基于各窗口对应的灰度均值和梯度信息进行立体匹配,一方面可以捕捉边框图像中的微小变化,另一方面可以改善因光照影响而造成的纹理贫乏的情况,以提升立体匹配精度,进而提升物料堆体积测量精度。Compared with the prior art, the embodiment of the present invention divides each frame image into windows, and performs stereo matching on the frame image based on the grayscale mean and gradient information corresponding to each window to obtain the optimal disparity; the volume of the material pile is then determined based on the optimal disparity. Among them, by dividing the window and performing stereo matching based on the grayscale mean and gradient information corresponding to each window, on the one hand, it is possible to capture slight changes in the frame image, and on the other hand, it is possible to improve the texture poverty caused by the influence of lighting, so as to improve the stereo matching accuracy, and then improve the measurement accuracy of the material pile volume.

应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本发明实施例的实施过程构成任何限定。It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.

以下为本发明的装置实施例,对于其中未详尽描述的细节,可以参考上述对应的方法实施例。The following is an embodiment of the device of the present invention. For details not described in detail, reference may be made to the corresponding method embodiment described above.

图4示出了本发明实施例提供的物料堆体积测量装置的结构示意图,为了便于说明,仅示出了与本发明实施例相关的部分,详述如下:FIG4 shows a schematic diagram of the structure of a material pile volume measuring device provided by an embodiment of the present invention. For ease of description, only the parts related to the embodiment of the present invention are shown, which are described in detail as follows:

如图4所示,物料堆体积测量装置4包括:获取模块41、处理模块42和测量模块43。As shown in FIG. 4 , the material pile volume measuring device 4 includes: an acquisition module 41 , a processing module 42 and a measurement module 43 .

获取模块41,用于分别获取不同视角下的物料堆图像;An acquisition module 41 is used to acquire images of the material pile at different viewing angles;

处理模块42,用于分别对各物料堆图像进行背景分割,得到每一物料堆图像对应的包含物料堆的边框图像;The processing module 42 is used to perform background segmentation on each material pile image to obtain a frame image containing the material pile corresponding to each material pile image;

处理模块42,还用于分别对各边框图像进行窗口划分,并基于各窗口对应的灰度均值和梯度信息对边框图像进行立体匹配,得到各边框图像中各对应窗口的最优视差;The processing module 42 is further used to divide each frame image into windows respectively, and perform stereo matching on the frame images based on the grayscale mean and gradient information corresponding to each window to obtain the optimal disparity of each corresponding window in each frame image;

测量模块43,用于基于最优视差,确定物料堆的三维点云数据,并对三维点云数据进行三角剖分,得到物料堆体积。The measurement module 43 is used to determine the three-dimensional point cloud data of the material pile based on the optimal parallax, and triangulate the three-dimensional point cloud data to obtain the volume of the material pile.

在一种可能的实现方式中,边框图像包括第一边框图像和第二边框图像;处理模块42,具体用于:In a possible implementation, the frame image includes a first frame image and a second frame image; the processing module 42 is specifically configured to:

按照预设的窗口大小,分别将第一边框图像和第二边框图像划分为多个窗口;According to a preset window size, the first frame image and the second frame image are divided into a plurality of windows respectively;

分别计算各窗口对应的灰度均值和梯度信息,并基于各窗口对应的灰度均值和梯度信息,计算第一边框图像中各窗口与第二边框图像中各窗口之间的匹配代价;Calculating the grayscale mean and gradient information corresponding to each window respectively, and calculating the matching cost between each window in the first frame image and each window in the second frame image based on the grayscale mean and gradient information corresponding to each window;

基于匹配代价进行代价聚合、视差计算以及视差优化,得到最优视差图;其中,最优视差图中包括第一边框图像中各窗口与第二边框图像中对应窗口之间的最优视差。Cost aggregation, disparity calculation and disparity optimization are performed based on the matching cost to obtain an optimal disparity map; wherein the optimal disparity map includes an optimal disparity between each window in the first frame image and a corresponding window in the second frame image.

在一种可能的实现方式中,处理模块42,用于根据计算各窗口对应的灰度均值;In a possible implementation, the processing module 42 is configured to: Calculate the grayscale mean corresponding to each window;

其中,Iavg(x,y)表示左上角顶点坐标为(x,y)的窗口对应的灰度均值,ω1表示窗口的长度,ω2表示窗口的宽度,i表示长度变量,j表示宽度变量,I(x+i,y+j)表示窗口中坐标为(x+i,y+j)的像素点的灰度值;Where, I avg (x, y) represents the grayscale mean corresponding to the window with the coordinates of the upper left corner vertex (x, y), ω 1 represents the length of the window, ω 2 represents the width of the window, i represents the length variable, j represents the width variable, and I(x+i, y+j) represents the grayscale value of the pixel point with coordinates (x+i, y+j) in the window;

梯度信息包括:归一化梯度幅值;处理模块42,具体用于:The gradient information includes: normalized gradient amplitude; a processing module 42, specifically used for:

分别获取各窗口对应的水平梯度向量和垂直梯度向量,并基于各窗口对应的水平梯度向量和垂直梯度向量,计算各窗口对应的梯度幅值;Obtaining the horizontal gradient vector and the vertical gradient vector corresponding to each window respectively, and calculating the gradient amplitude corresponding to each window based on the horizontal gradient vector and the vertical gradient vector corresponding to each window;

分别对各窗口对应的梯度幅值进行归一化处理,得到各窗口对应的归一化梯度幅值。The gradient amplitude corresponding to each window is normalized respectively to obtain the normalized gradient amplitude corresponding to each window.

在一种可能的实现方式中,处理模块42,具体用于:In a possible implementation, the processing module 42 is specifically configured to:

根据第一边框图像和第二边框图像中各窗口对应的灰度均值,分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的灰度差异;Calculating the grayscale differences between each window in the first border image and each window in the second border image according to the grayscale mean values corresponding to each window in the first border image and the second border image;

根据第一边框图像和第二边框图像中各窗口对应的梯度信息,分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的局部结构信息;Calculating local structural information between each window in the first frame image and each window in the second frame image according to gradient information corresponding to each window in the first frame image and the second frame image;

根据灰度差异和局部结构信息,分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的匹配代价。According to the grayscale difference and the local structure information, the matching cost between each window in the first frame image and each window in the second frame image is calculated respectively.

在一种可能的实现方式中,处理模块42,用于根据D(x,y)=|Ilavg(x,y)-Iravg(x,y)|分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的灰度差异;In a possible implementation, the processing module 42 is used to calculate the grayscale difference between each window in the first frame image and each window in the second frame image according to D(x,y)=|I lavg (x,y)-I ravg (x,y)|;

其中,D(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中左上角顶点坐标为(x,y)的窗口之间的灰度差异,Ilavg(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口对应的灰度均值,Ilavg(x,y)表示第二边框图像中左上角顶点坐标为(x,y)的窗口对应的灰度均值。Among them, D(x,y) represents the grayscale difference between the window with the upper left corner vertex coordinates (x,y) in the first border image and the window with the upper left corner vertex coordinates (x,y) in the second border image, I lavg (x,y) represents the grayscale mean corresponding to the window with the upper left corner vertex coordinates (x,y) in the first border image, and I lavg (x,y) represents the grayscale mean corresponding to the window with the upper left corner vertex coordinates (x,y) in the second border image.

在一种可能的实现方式中,处理模块42,用于根据S(x,y)=Nl(x,y)+Nr(x,y)分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的局部结构信息;In a possible implementation, the processing module 42 is used to calculate the local structural information between each window in the first frame image and each window in the second frame image according to S(x,y)=N l (x,y)+N r (x,y);

其中,S(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中左上角顶点坐标为(x,y)的窗口之间的局部结构信息,Nl(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口对应的梯度信息,Nr(x,y)表示第二边框图像中左上角顶点坐标为(x,y)的窗口对应的梯度信息。Among them, S(x,y) represents the local structural information between the window with the upper left corner vertex coordinates (x,y) in the first border image and the window with the upper left corner vertex coordinates (x,y) in the second border image, N l (x,y) represents the gradient information corresponding to the window with the upper left corner vertex coordinates (x,y) in the first border image, and N r (x,y) represents the gradient information corresponding to the window with the upper left corner vertex coordinates (x,y) in the second border image.

在一种可能的实现方式中,处理模块42,用于根据C(x,y)=αD(x,y)+βS(x,y)分别计算第一边框图像中各窗口与第二边框图像中各窗口之间的匹配代价;In a possible implementation, the processing module 42 is used to calculate the matching cost between each window in the first frame image and each window in the second frame image according to C(x,y)=αD(x,y)+βS(x,y);

其中,C(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中左上角顶点坐标为(x,y)的窗口之间的匹配代价,α表示第一权重,β表示第二权重,D(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中左上角顶点坐标为(x,y)的窗口之间的灰度差异,S(x,y)表示第一边框图像中左上角顶点坐标为(x,y)的窗口与第二边框图像中左上角顶点坐标为(x,y)的窗口之间的局部结构信息。Among them, C(x,y) represents the matching cost between the window with the upper left corner vertex coordinates (x,y) in the first border image and the window with the upper left corner vertex coordinates (x,y) in the second border image, α represents the first weight, β represents the second weight, D(x,y) represents the grayscale difference between the window with the upper left corner vertex coordinates (x,y) in the first border image and the window with the upper left corner vertex coordinates (x,y) in the second border image, and S(x,y) represents the local structural information between the window with the upper left corner vertex coordinates (x,y) in the first border image and the window with the upper left corner vertex coordinates (x,y) in the second border image.

本发明实施例通过对各边框图像进行窗口划分,并基于各窗口对应的灰度均值和梯度信息对边框图像进行立体匹配,得到最优视差;基于最优视差进而确定物料堆体积。其中,处理模块42通过进行窗口划分,并基于各窗口对应的灰度均值和梯度信息进行立体匹配,一方面可以捕捉边框图像中的微小变化,另一方面可以改善因光照影响而造成的纹理贫乏的情况,以提升立体匹配精度,进而提升物料堆体积测量精度。The embodiment of the present invention divides each frame image into windows, and performs stereo matching on the frame image based on the grayscale mean and gradient information corresponding to each window to obtain the optimal disparity; the volume of the material pile is then determined based on the optimal disparity. Among them, the processing module 42 divides the window and performs stereo matching based on the grayscale mean and gradient information corresponding to each window. On the one hand, it can capture slight changes in the frame image, and on the other hand, it can improve the texture poverty caused by the influence of lighting, so as to improve the stereo matching accuracy, and then improve the material pile volume measurement accuracy.

图5是本发明实施例提供的电子设备的示意图。如图5所示,该实施例的电子设备5包括:处理器50、存储器51以及存储在所述存储器51中并可在所述处理器50上运行的计算机程序52。所述处理器50执行所述计算机程序52时实现上述各个物料堆体积测量方法实施例中的步骤,例如图1所示的步骤101至步骤104。或者,所述处理器50执行所述计算机程序52时实现上述各装置实施例中各模块/单元的功能,例如图4所示模块41至43的功能。FIG5 is a schematic diagram of an electronic device provided by an embodiment of the present invention. As shown in FIG5 , the electronic device 5 of this embodiment includes: a processor 50, a memory 51, and a computer program 52 stored in the memory 51 and executable on the processor 50. When the processor 50 executes the computer program 52, the steps in the above-mentioned various material pile volume measurement method embodiments are implemented, such as steps 101 to 104 shown in FIG1 . Alternatively, when the processor 50 executes the computer program 52, the functions of the modules/units in the above-mentioned various device embodiments are implemented, such as the functions of modules 41 to 43 shown in FIG4 .

示例性的,所述计算机程序52可以被分割成一个或多个模块/单元,所述一个或者多个模块/单元被存储在所述存储器51中,并由所述处理器50执行,以完成本发明。所述一个或多个模块/单元可以是能够完成特定功能的一系列计算机程序指令段,该指令段用于描述所述计算机程序52在所述电子设备5中的执行过程。例如,所述计算机程序52可以被分割成图4所示的模块41至43。Exemplarily, the computer program 52 may be divided into one or more modules/units, which are stored in the memory 51 and executed by the processor 50 to implement the present invention. The one or more modules/units may be a series of computer program instruction segments capable of implementing specific functions, which are used to describe the execution process of the computer program 52 in the electronic device 5. For example, the computer program 52 may be divided into modules 41 to 43 as shown in FIG. 4 .

所述电子设备5可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。所述电子设备5可包括,但不仅限于,处理器50、存储器51。本领域技术人员可以理解,图5仅仅是电子设备5的示例,并不构成对电子设备5的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如所述电子设备还可以包括输入输出设备、网络接入设备、总线等。The electronic device 5 may be a computing device such as a desktop computer, a notebook, a PDA, and a cloud server. The electronic device 5 may include, but is not limited to, a processor 50 and a memory 51. Those skilled in the art will appreciate that FIG5 is merely an example of the electronic device 5 and does not constitute a limitation on the electronic device 5. The electronic device 5 may include more or fewer components than shown in the figure, or may combine certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.

所称处理器50可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The processor 50 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

所述存储器51可以是所述电子设备5的内部存储单元,例如电子设备5的硬盘或内存。所述存储器51也可以是所述电子设备5的外部存储设备,例如所述电子设备5上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,所述存储器51还可以既包括所述电子设备5的内部存储单元也包括外部存储设备。所述存储器51用于存储所述计算机程序以及所述电子设备所需的其他程序和数据。所述存储器51还可以用于暂时地存储已经输出或者将要输出的数据。The memory 51 may be an internal storage unit of the electronic device 5, such as a hard disk or memory of the electronic device 5. The memory 51 may also be an external storage device of the electronic device 5, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 5. Further, the memory 51 may also include both an internal storage unit of the electronic device 5 and an external storage device. The memory 51 is used to store the computer program and other programs and data required by the electronic device. The memory 51 may also be used to temporarily store data that has been output or is to be output.

所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

在本发明所提供的实施例中,应该理解到,所揭露的装置/电子设备和方法,可以通过其它的方式实现。例如,以上所描述的装置/电子设备实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。In the embodiments provided by the present invention, it should be understood that the disclosed devices/electronic devices and methods can be implemented in other ways. For example, the device/electronic device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, 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 in the form of software functional units.

所述集成的模块/单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明实现上述实施例方法中的全部或部分流程,也可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个物料堆体积测量方法实施例的步骤。其中,所述计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、电载波信号、电信信号以及软件分发介质等。以上所述实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围,均应包含在本发明的保护范围之内。If the integrated module/unit 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. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned various material pile volume measurement method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.

Claims (10)

1. A method of measuring the volume of a stack of materials, comprising:
respectively acquiring material pile images under different visual angles;
respectively carrying out background segmentation on each material pile image to obtain a frame image containing the material pile corresponding to each material pile image;
dividing windows of each frame image respectively, and carrying out three-dimensional matching on the frame images based on gray average values and gradient information corresponding to each window to obtain optimal parallax of each corresponding window in each frame image;
and determining three-dimensional point cloud data of the material pile based on the optimal parallax, and triangulating the three-dimensional point cloud data to obtain the volume of the material pile.
2. The method of claim 1, wherein the frame images comprise a first frame image and a second frame image;
the window division is performed on each frame image, and stereo matching is performed on the frame images based on gray average value and gradient information corresponding to each window, so as to obtain optimal parallax of each corresponding window in each frame image, including:
dividing the first frame image and the second frame image into a plurality of windows according to the preset window size;
Respectively calculating gray average value and gradient information corresponding to each window, and calculating matching cost between each window in the first frame image and each window in the second frame image based on the gray average value and the gradient information corresponding to each window;
performing cost aggregation, parallax calculation and parallax optimization based on the matching cost to obtain an optimal parallax map; the optimal parallax map comprises optimal parallaxes between windows in the first frame image and corresponding windows in the second frame image.
3. The method of claim 2, wherein calculating a gray scale average value for each window comprises:
according toCalculating the gray average value corresponding to each window;
wherein I is avg (x, y) represents the gray-scale average value, ω, corresponding to the window with the upper left corner vertex coordinates of (x, y) 1 Representing the length of the window omega 2 Representing the width of the window, I representing the length variable, j representing the width variable, I (x+i, y+j) representing the gray value of the pixel point in the window with coordinates (x+i, y+j);
the gradient information includes: normalizing the gradient amplitude; calculating gradient information corresponding to each window, including:
respectively obtaining a horizontal gradient vector and a vertical gradient vector corresponding to each window, and calculating a gradient amplitude corresponding to each window based on the horizontal gradient vector and the vertical gradient vector corresponding to each window;
And respectively carrying out normalization processing on the gradient amplitude values corresponding to the windows to obtain normalized gradient amplitude values corresponding to the windows.
4. A method of measuring a volume of a stack of materials according to claim 2 or 3, wherein calculating a matching cost between each window in the first frame image and each window in the second frame image based on gray-scale average and gradient information corresponding to each window comprises:
respectively calculating gray level differences between each window in the first frame image and each window in the second frame image according to gray level average values corresponding to each window in the first frame image and each window in the second frame image;
according to gradient information corresponding to each window in the first frame image and the second frame image, local structure information between each window in the first frame image and each window in the second frame image is calculated respectively;
and respectively calculating the matching cost between each window in the first frame image and each window in the second frame image according to the gray level difference and the local structure information.
5. The method for measuring the volume of a material pile according to claim 4, wherein the calculating the gray scale difference between each window in the first frame image and each window in the second frame image according to the gray scale average value corresponding to each window in the first frame image and the second frame image respectively includes:
According to D (x, y) = |i lavg (x,y)-I ravg Respectively calculating gray scale differences between each window in the first frame image and each window in the second frame image;
wherein D (x, y) represents the gray scale difference between the window with the coordinates of the top left corner vertex (x, y) in the first frame image and the window with the coordinates of the top left corner vertex (x, y) in the second frame image, I lavg (x, y) represents the upper left in the first frame imageGray average value corresponding to window with angular vertex coordinates of (x, y), I lavg And (x, y) represents a gray-scale average value corresponding to a window with the coordinates of the top left corner vertex of the second frame image being (x, y).
6. The method for measuring the volume of a material pile according to claim 4, wherein the calculating the local structure information between each window in the first frame image and each window in the second frame image according to the gradient information corresponding to each window in the first frame image and the second frame image respectively includes:
according to S (x, y) =N l (x,y)+N r (x, y) calculating local structure information between each window in the first frame image and each window in the second frame image respectively;
wherein S (x, y) represents local structure information between a window with (x, y) coordinates of an upper left corner vertex in the first frame image and a window with (x, y) coordinates of an upper left corner vertex in the second frame image, N l (x, y) represents gradient information corresponding to a window with (x, y) coordinates of the top left corner vertex in the first frame image, N r And (x, y) represents gradient information corresponding to a window with the top left corner vertex coordinates of (x, y) in the second frame image.
7. The method for measuring volume of a material pile according to claim 4, wherein the calculating the matching cost between each window in the first frame image and each window in the second frame image according to the gray scale difference and the local structure information includes:
calculating matching cost between each window in the first frame image and each window in the second frame image according to C (x, y) =alpha D (x, y) +beta S (x, y);
wherein C (x, y) represents a matching cost between a window with (x, y) coordinates of an upper left corner vertex in the first frame image and a window with (x, y) coordinates of an upper left corner vertex in the second frame image, α represents a first weight, β represents a second weight, D (x, y) represents a gray scale difference between a window with (x, y) coordinates of an upper left corner vertex in the first frame image and a window with (x, y) coordinates of an upper left corner vertex in the second frame image, and S (x, y) represents local structure information between a window with (x, y) coordinates of an upper left corner vertex in the first frame image and a window with (x, y) coordinates of an upper left corner vertex in the second frame image.
8. A material stack volume measuring device, comprising:
the acquisition module is used for respectively acquiring the material pile images under different visual angles;
the processing module is used for respectively carrying out background segmentation on each material pile image to obtain a frame image which corresponds to each material pile image and contains the material pile;
the processing module is further used for dividing windows of the frame images respectively, and carrying out three-dimensional matching on the frame images based on gray average values and gradient information corresponding to the windows to obtain optimal parallax of the corresponding windows in the frame images;
and the measurement module is used for determining three-dimensional point cloud data of the material pile based on the optimal parallax, and triangulating the three-dimensional point cloud data to obtain the volume of the material pile.
9. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method for measuring the volume of a mass pile according to any one of the preceding claims 1 to 7 when the computer program is executed.
10. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the steps of the method for measuring the volume of a pile according to any one of claims 1 to 7.
CN202410026700.1A 2024-01-08 2024-01-08 Material pile volume measurement method, device, electronic equipment and storage medium Pending CN117830385A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410026700.1A CN117830385A (en) 2024-01-08 2024-01-08 Material pile volume measurement method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410026700.1A CN117830385A (en) 2024-01-08 2024-01-08 Material pile volume measurement method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117830385A true CN117830385A (en) 2024-04-05

Family

ID=90509612

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410026700.1A Pending CN117830385A (en) 2024-01-08 2024-01-08 Material pile volume measurement method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117830385A (en)

Similar Documents

Publication Publication Date Title
US10916033B2 (en) System and method for determining a camera pose
KR101310589B1 (en) Techniques for rapid stereo reconstruction from images
CN102938142B (en) Based on the indoor LiDAR missing data complementing method of Kinect
US10726580B2 (en) Method and device for calibration
CN108288292A (en) A kind of three-dimensional rebuilding method, device and equipment
CN110473262A (en) Outer ginseng scaling method, device, storage medium and the electronic equipment of more mesh cameras
CN110136114B (en) A kind of wavefront height measurement method, terminal equipment and storage medium
CN102903101B (en) Method for carrying out water-surface data acquisition and reconstruction by using multiple cameras
WO2020119467A1 (en) High-precision dense depth image generation method and device
CN106815869A (en) The photocentre of fisheye camera determines method and device
CN112233076B (en) Structural vibration displacement measurement method and device based on red round target image processing
CN113362445B (en) Method and device for reconstructing object based on point cloud data
CN116129037A (en) Visual touch sensor, three-dimensional reconstruction method, system, equipment and storage medium thereof
CN111383264A (en) Positioning method, positioning device, terminal and computer storage medium
CN113793387A (en) Calibration method, device and terminal of monocular speckle structured light system
CN116912417A (en) Texture mapping method, device, equipment and storage medium based on three-dimensional reconstruction of human face
CN117541730A (en) Three-dimensional image reconstruction method and system for underwater target
Shen Depth-map merging for multi-view stereo with high resolution images
CN117830385A (en) Material pile volume measurement method, device, electronic equipment and storage medium
JP6906177B2 (en) Intersection detection device, camera calibration system, intersection detection method, camera calibration method, program and recording medium
CN116379936A (en) Intelligent recognition distance measuring and calculating method and device based on binocular camera
CN111915666A (en) Volume measurement method and device based on mobile terminal
TWI595446B (en) Method for improving occluded edge quality in augmented reality based on depth camera
Gan et al. Multi-view photometric stereo using surface deformation
CN112150621A (en) Aerial view generation method and system based on orthographic projection and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination