A method for fusion analysis of full-angle projection image patches of aviation manufacturing parts
Through the full-angle projection image patch attribute fusion analysis method, using CATIA and OpenCV for image processing and deep learning model training, the problem of low efficiency in patch attribute judgment in the generation of tool path data for aviation manufacturing parts is solved, and automatic identification and classification are realized. , improving the efficiency and accuracy of aviation manufacturing.
Patent Information
- Application Number
- CN202210431339.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-22
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2042-04-22
AI Technical Summary
In the existing technology, the tool path data generation of aerospace manufacturing parts relies on manual selection, which is inefficient and cannot meet the needs of automation, high efficiency and low cost. In particular, there is a time-consuming process of human intervention in judging the patch properties of the frame and beam structure. question.
The full-angle projection image patch attribute fusion analysis method is adopted. By importing the three-dimensional model in the CATIA software, an index table is generated, patch coloring and grayscale assignment are performed, and OpenCV is used for image processing and deep learning model training to realize patch attributes. Automatic identification and classification.
It greatly improves the accuracy of patch recognition, reduces the time-consuming human intervention, and realizes automated programming of aviation manufacturing parts, which is of great significance to efficient and intelligent manufacturing in the aviation field.
Smart Images

Figure CN114882272B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of CNC machining feature recognition of aviation manufacturing parts, and in particular relates to a method for fusion analysis of full-angle projection image patch attributes of aviation manufacturing parts. Background Art
[0002] The entire manufacturing process of aviation parts with frame beam structures relies on high-precision CNC machining machines. The machine tools must realize the entire machining process, and tool path data is the basis for accurate machining. Under this background, designing reasonable means to obtain the tool path data required for aviation manufacturing parts has become the focus and core of parts processing. The current method of generating tool path data in the industry is mainly based on manual selection. Common software in the industry include SolidWorks, CATIA, and UG. The implementation method is to manually select a set of features consisting of a driving surface and a guide surface in the software, set the corresponding machining tool path information, such as stroke, speed, feed rate, etc., and further processing can obtain the tool path data.
[0003] The characteristic surfaces or characteristic patches of frames and beams commonly found in the aviation field mainly include webs, fillets, bottom corners, rib tops, side walls, etc. In the aviation manufacturing field, webs and rib tops are usually regarded as driving surfaces, bottom corners are surfaces automatically generated by circular tools, and fillets and side walls are regarded as guide surfaces. CNC machining mainly uses subtractive methods to achieve manufacturing, and of course also includes additive manufacturing methods such as 3D metal printing. 3D printing usually cannot meet the performance requirements of aviation parts, and is mainly a subtractive manufacturing method. Therefore, for frame and beam structural parts, in order to mill a specific configuration on the blank, it is particularly important to judge the properties of the patches in the three-dimensional image.
[0004] In the industry, facet attribute judgment mainly relies on skilled process technicians to manually select processing features. However, the disadvantages of manual selection of processing surfaces are also obvious. For parts with many faces, it is inefficient to manually select all feature faces, which cannot meet the needs of automation, high efficiency and low cost. Improving the efficiency of accurate selection of feature faces is the core of the work.
[0005] Therefore, in order to achieve the needs of efficient automated programming and reduce human intervention in part programming, how to accurately judge the properties of the patch is particularly critical and is also a problem that the industry needs to solve urgently. Against this background, a method is designed to realize automatic recognition of the three-dimensional projection image patch of aviation parts, and at the same time, the integration of multi-view two-dimensional projection image results is beneficial to ensure the integrity and accuracy of the recognition. Summary of the invention
[0006] In order to provide an effective reference solution for the patch feature recognition problem that needs to be solved urgently in automated programming in the aviation field and reduce the time-consuming problem of human intervention in part programming, the present invention discloses a method for fusion analysis of patch attributes of full-angle projection images of aviation manufacturing parts.
[0007] The present invention is achieved through the following technical solutions:
[0008] A method for fusion analysis of full-angle projection image patches of aviation manufacturing parts, comprising the following steps:
[0009] Import the designed .CATPart 3D model of the part to be processed into the 3D modeling software CATIA, and obtain all the component faces of the part based on the CATIA 3D model.
[0010] All the patches are numbered according to random rules, and the patch numbers start from 1 and increase. An index table is constructed based on the numbering, and each row of the index table consists of the corresponding patch number and its attributes. The first column of each row in the index table is the corresponding patch number, and the second column is the red grayscale information h corresponding to the patch. R (x, y), the third column is the green grayscale information h corresponding to the patch G (x, y), the fourth column is the blue grayscale information h corresponding to the patch B (x, y), the fifth column is the size of the patch slice The initial grayscale information corresponding values of all patches in different color spaces are all 255.
[0011] Color all the patches in the index table based on the number. The coloring method is as follows: the initial red, green, and blue values corresponding to the first row of patches in the index table are assigned as h R (x,y)=0、h G (x,y)=125、h B (x, y) = 15. The red, green, and blue values of the second row are h R (x,y)=0、h G (x,y)=125、h B (x,y)=35, the red, green, and blue values of the corresponding face in the third row are h R (x,y)=0、h G (x,y)=125、h B (x,y)=55, increasing in sequence when h B (x,y)>255h G (x,y)+25 at the same time h B (x,y)=h B (x,y)%255, increasing in sequence when h G (x,y)>255hR (x,y)+30 at the same time h G (x,y)=h G (x,y)%255.
[0012] The grayscale value of the corresponding n-th row of the face in the index table can be expressed by the following recursive formula:
[0013]
[0014] Among them, times R 、times G 、times B They represent the multiplication numbers of the red, green, and blue channels of the patch respectively, and their initial values are all 0.
[0015] The grayscale values corresponding to the patches in different rows of the index table are used to complete the coloring steps of all patches in the three-dimensional image.
[0016] In CATIA software, set the display parameters of the background and the contour lines of the part's 3D image. Select "Part Geometry" in the left navigation bar of CATIA software, then select "Properties" and "Image". Set the color in the "Fill" column to 0, 0, 0. The color in the "Border Line" column is black, the corresponding "Line Type" is 1, and the "Line Width" is 2: 0.8mm. Set the "Color" in the "Straight Line and Curve" column to black, the corresponding "Line Type" is 1, and the "Line Width" is 2: 0.5mm. Hide all points in the 3D image. Select "View" and "Lighting" in the "Menu Bar", and select "No Light" in the "Light Source" window that opens. The corresponding "Scattering", "Reflection", and "Diffuse" parameter values are all 1.00.
[0017] Based on the secondary development function of CATIA, the full-angle projection image screenshot tool of the designed parts can obtain images from different perspectives and save the graphics. The corresponding image format is lossless compressed .png format.
[0018] Set the screenshot viewpoint of the part enclosing sphere to the coordinates of the intersection of the longitude and latitude. The parameters in the screenshot tool are set as follows: screenshot magnification is 2, the initial arbitrary longitude position is the prime meridian, the east longitude and west longitude range is 0-180°, the north latitude and south latitude range is 0-180°, and the image is captured at the corresponding coordinate points at intervals of 10°.
[0019] In "Select image storage path", select "E:\11.All project data sets\5.Quick programming\2021.12.30", in "Select image storage format", select ".png" format to save the image, and in "Other parameter settings", "Longitude range", "Latitude range", "Zoom ratio", and "Interval division" are 360, 360, 2, and 10 respectively. Click "Start" to acquire the image.
[0020] Define a dictionary to store pixel information. The data in the dictionary is stored in a container to store the grayscale values and coordinate values of pixels that meet different grayscale differences. The storage type corresponding to the container vector is the structure struct. The variable of the structure contains an integer array to evaluate the grayscale category of the corresponding pixel. The size of the array is set to 207406, and the values of all elements in the array are initialized to 1.
[0021] The relationship between array subscripts and corresponding numerical identifiers can be expressed as follows:
[0022] array location =[h R (x,y)+11]*256+[h G (x,y)+14]*257+[h B (x,y)+17]*258 (2)
[0023] array initializing→array[0-207406]={1} (3)
[0024] flag based→array[array location ]=2 (4)
[0025] Among them, array location Indicates the array coordinate position generated based on the grayscale value; array[array location ] represents the corresponding position of the array that satisfies the relationship.
[0026] A container vector is defined in the structure to store the coordinates Poi nt(i,j) of the pixels that satisfy the same grayscale. That is, the structure contains two integer variables row and col to store the row coordinate values and column coordinate values of the pixels that satisfy the relationship respectively.
[0027] Get the coordinates pixel(x,y) of the pixels with the same grayscale saved in the dictionary with grayscale as the key, and draw these areas that satisfy the relationship in a new image of the same size as the original image based on the coordinate information.
[0028] A new image new_image is created by OpenCV, and the grayscale values of R, G, and B filled in the image are 124, 251, and 164. The colors of the corresponding areas of the pixels in new_image that satisfy the mathematical relationship that key is not 1 are all transformed to 200, 121, and 196. That is, the areas where the pixels satisfying key are located in new_image are processed to the same grayscale value.
[0029] Based on the 0 threshold loop processing method, new_image is binarized, and the binarization formula is:
[0030]
[0031] Among them, new_cols and new_rows represent the number of rows and columns of the image of new_image respectively; h R-n (x,y),h G-n (x,y),h B-n (x, y) represents the grayscale value of the red, green, and blue channels in new_image at the point (x, y); h 0-1 (x,y) represents the gray value corresponding to (x,y) in the binary image.
[0032] Get the high frequency contours of the binary image. 0-1 Back up and get new_image1 0-1 , new_image for the original binary image 0-1 Perform 4-neighborhood scaling operation on high grayscale area to get new_image2 0-1 , new_image1 0-1 with new_image2 0-1 The high-frequency contour line is obtained by subtraction.
[0033] The high grayscale area 4 neighborhood scaling operation formula is:
[0034] org(x,y)-kernel four ={min→result(x+x′,y+y′)(x′,y′):kernel four (x′,y′)≠0} (6)
[0035] Among them, org(x,y) represents the image new_image to be scaled 0-1 ;kernel four Represents the 4-neighborhood scaling factor; result(x,y) represents the pixel value after processing at the (x,y) position in the image.
[0036] The difference method of the gray value of the corresponding pixel position point is:
[0037]
[0038] Among them, h n-1 (x,y) and h n-2(x, y) represents the grayscale value of the single-channel original binary image and the scaled image at (x, y) respectively; result(x, y) represents the result containing high-frequency contour lines obtained after calculation.
[0039] The calculation of the minimum enclosing rectangular area of the image 0 inclination angle uses a loop traversal method to obtain the extreme value x of the projection point of the high-frequency contour line on the X and Y axes min 、x max ,y min ,y max , the corresponding extreme point in the image is the vertex of the minimum enclosing rectangular area with a 0 inclination angle, and the grayscale value of the point on the corresponding high-frequency contour line in the image should satisfy result(x,y)=255.
[0040] The image in new_image is intercepted according to the obtained coordinates of the minimum enclosing rectangular area with a zero inclination angle to ensure that the facets of the part's three-dimensional model in the two-dimensional image constitute independent analysis elements.
[0041] Re-assign the three channels of the foreground area in the captured image. The corresponding assignment method is: the grayscale value of the R channel is 221, the grayscale value of the G channel is 169, and the grayscale value of the B channel is 15.
[0042] After the grayscale transformation of each channel of the image patch, the patch attributes are classified and saved based on the index number, and the transformed image is used as the sample image for deep learning.
[0043] The sample images are classified into 6 categories, including sidewall, web, fillet, rib top, bottom corner and others. The number of samples in each category is close to the numerical relationship of 1:1:1:1:1:1. At the same time, in order to ensure the generalization ability of the model, the number of patches of the same category should be as large as possible and have different feature expressions.
[0044] Design enhancement methods such as random rotation at any angle (0°-360° range, the specific value is obtained based on the random number number%360 generated based on time), left-right symmetry, top-bottom symmetry, and proportional scaling of the image along the length cols and width rows (0.7-1.2), and randomly select one or more of them for enhancement. The number of enhancements is selected as nums=random(time)%4.
[0045] After enhancement, the number of 6 types of feature patches approaches a 1:1 relationship, and the numbers of side walls, webs, fillets, rib tops, bottom angles and others are 6412:5861:6384:6435:6024:6862 respectively.
[0046] Design a deep learning classification network for patch category segmentation, and perform preprocessing transformations on training and test data.
[0047] Build a basic network with resnet50 as feature extraction, batch_size=5, num_class=6, num_workers=0, shuffle=True of train_dataset, shuffle=False of validate_dataset, loss_function=nn.CrossEntropyLoss(), optimizer=optim.Adam(net.parameters(),lr=0.0001), initial best_accuracy=0.0, training epoch=106, use softmax as classifier, use net.train() mode to modify the weight parameters of the network during training, and use net.eval() mode to keep the model parameters of the network unchanged during testing.
[0048] The training process saves the accuracy, loss, and updated network parameters for each epoch (weights are in .pth format). The accuracy and loss are kept in the result.log file.
[0049] After training is completed, obtain the network model parameters saved in the epoch corresponding to the minimum training loss and the minimum test sample loss in the result.log file, and initialize the network based on the parameters corresponding to the epoch.
[0050] The image to be analyzed is obtained by the same pre-processing method as the training sample, and the grayscale of the obtained patch filling is consistent with the grayscale of the area corresponding to the training sample.
[0051] To initialize the predicted patch image data, the network is set to model.eval() mode, model.load_state_dict(torch.load("optimal weight file")) is used to load the model, output = torch.squeeze(model(img)) is used to get the predicted result, and predict = torch.softmax(output, dim = 0) is used to get the category with the highest probability.
[0052] The Image function in the PIL library batch reads the images to be judged img = Image.open (path_all), data conversion img = data_transform (img), img = torch.unsqueeze (img, dim = 0), and then inputs the model according to softmax to get the final recognized category data, and the corresponding data is result 1.
[0053] Batch predicts images from different perspectives and obtains result data, which is stored in the dictionary. Finally, the results of the same face in the dictionary at different perspectives are fused, and more accurate face category information data is obtained based on the voting method. The corresponding data is result 2.
[0054] The classification result obtained after voting is the final recognition result of the corresponding face patch, and the data is used as the category information of the face patch attributes in the three-dimensional image of the part.
[0055] The advantages of this application are:
[0056] The present invention realizes the fusion judgment of the facet properties of aviation manufacturing parts based on full-angle projection images. Compared with the judgment results under a single viewing angle, the method can greatly improve the accuracy of facet recognition by integrating multi-view two-dimensional projection image results. It provides an effective reference solution for the facet feature recognition problem that needs to be solved urgently in automated programming in the aviation field, reduces the time-consuming problem of human intervention in part programming, and is of great significance to the efficient, intelligent and industrial manufacturing upgrades in the aviation field. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 It is the core step of a method for fusion analysis of full-angle projection image patches of aviation manufacturing parts.
[0058] Figure 2 It is a data storage format based on the CATIA part patch index table.
[0059] Figure 3 The effect of randomly assigning grayscale values to the three-dimensional image patches of the part.
[0060] Figure 4 The interface of the tool for automatic screenshot of all angles of the developed parts.
[0061] Figure 5 This is a full-angle image of the part obtained based on the automated screenshot tool.
[0062] Figure 6 The pixel areas in new_image that satisfy key are processed to have the same grayscale value effect.
[0063] Figure 7 , Figure 8 , Fig. 9 is the 4-neighborhood scaling factor image.
[0064] Fig.10 is the result image containing high-frequency contour lines obtained after calculation.
[0065] Fig.11 The extreme points of the high-frequency contour line are obtained by loop traversal.
[0066] Fig.12 It is the minimum enclosing rectangular area image with zero inclination angle captured in new_image.
[0067] Fig.13 Extract network structure parameters for the designed features.
[0068] Fig.14 It represents the fusion result of different patch data in the dictionary. DETAILED DESCRIPTION
[0069] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is to explain the present invention rather than to limit the present invention. Based on the embodiment of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0070] The software system of the present invention is implemented based on Windows 7 system 64 bits, the processor is a workstation-level InterXeon W-2223 3.60Ghz, the running memory capacity is 32GB, the memory frequency is 3200Mhz, the graphics card model used by the designed deep learning model is P2200 (brand is Nvidia, the memory capacity is 5GB), the Nvidia graphics card driver version number is 441.66, the version corresponding to the deep learning calculation CUDA core is 10.2, and the hard disk capacity is 256GB (solid state drive). The software development platform is based on Visual Studio 2017Release X64, and the programming languages include C++ and Python. The corresponding software for 3D modeling and tool path generation of aviation manufacturing parts is CATIA, and the corresponding version number is V5.21. The image processing library used is OpenCV4.5.2. The deep learning platform is based on the PyTorch framework, and the Python version number is 3.7.1, the Pytorch version is 1.5.0, the Torchvision version is 0.6.0, the sample annotation tool is labelimg, the matrix operation tool library Numpy version is 1.21.4, the wheel version is 0.32.3, the tqdm version number is 4.28.1, the scipy version number is 1.1.0, and the SDK version is 10.0.22000.0. The core steps of a method for fusion analysis of full-angle projection image patches of aviation manufacturing parts are as follows: Figure 1 shown.
[0071] 1. Import the designed 3D model of the part to be processed in the .CATPart format into CATIA, and obtain all the component slices of the part based on the CATIA 3D model.
[0072] 2. Number all the patches based on random rules, starting from 1. Construct an index table based on the numbers, and each row of the index table consists of the corresponding patch number and its attributes. The first column of each row in the index table is the corresponding patch number, and the second column is the red grayscale information of the patch. R (x, y), the third column is the green grayscale information h corresponding to the patch G (x, y), the fourth column is the blue grayscale information h corresponding to the patch B (x, y), the fifth column is the size of the patch slice The initial grayscale information corresponding values of all patches in different color spaces are all 255. Based on the CATIA part patch index table data storage format, such as Figure 2 shown.
[0073] 3. Color all the patches in the index table. The initial red, green, and blue values corresponding to the patches in the first row of the index table are h R (x,y)=0、h G (x,y)=125、h B (x, y) = 15. The red, green, and blue values of the second row are h R (x,y)=0、h G (x,y)=125、h B (x,y)=35, the red, green, and blue values of the corresponding face in the third row are h R (x,y)=0、h G (x,y)=125、h B (x,y)=55, increasing in sequence when h B (x,y)>255h G (x,y)+25 at the same time h B (x,y)=h B (x,y)%255, increasing in sequence when h G (x,y)>255h R (x,y)+30 at the same time h G (x,y)=h G (x,y)%255, that is, the grayscale value of the nth row of the corresponding face in the index table can be expressed by the following recursive formula:
[0074]
[0075] Among them, times R 、times G 、times BThey represent the multiplication numbers of the red, green, and blue channels of the patch respectively, and their initial values are all 0.
[0076] 4. Based on the grayscale values corresponding to the facets in different rows in the index table, complete the coloring steps of all the facets in the 3D image. The grayscale indexing rules in the index table can ensure that the grayscale values of each facet are different. The effect of random grayscale assignment of facets in the 3D image of the part, such as Figure 3 shown.
[0077] 5. Set the display parameters of the background and part 3D image contour lines in CATIA software. To set the display parameters, select "Part Geometry" in the left navigation bar of CATIA software, then select "Properties" and "Image", set the color in the "Fill" column to 0, 0, 0, the color in the "Border" column is black, the corresponding "Line Type" is 1, and the "Line Width" is 2: 0.8mm, set the "Color" in the "Straight Line and Curve" column to black, the corresponding "Line Type" is 1, and the "Line Width" is 2: 0.5mm, and hide all points in the 3D image. Select "View" and "Lighting" in the "Menu Bar", and select "No Light" in the "Light Source" window that opens. The corresponding "Scattering", "Reflection", and "Diffuse" parameter values are all 1.00.
[0078] 6. Based on the secondary development function of CATIA, design a full-angle projection image screenshot tool for parts. Use CATIA.ActiveWindow.ActiveViewer.Viewpoint3D.PutOrigin Op, CATIA.ActiveWindow.ActiveViewer.Viewpoint3D.PutUpDirection XpCATIA.ActiveWindow.ActiveViewer.Viewpoint3D.PutSightDirection Zp code to obtain images from different perspectives, and 'CATIA.ActiveWindow.ActiveViewer.CaptureToFile catCaptureFormatJPEG,"C:\\part\\"+Str(num)+".png" to save the graphics. The corresponding image format is lossless compressed .png format. The interface of the developed full-angle automatic screenshot tool for parts is as follows: Figure 4 shown.
[0079] 7. Set the screenshot viewpoint of the part enclosing sphere to the coordinates of the intersection of the longitude and latitude. The screenshot magnification is 2, the initial arbitrary longitude position is the prime meridian, the east longitude and west longitude range is 0°-180°, the north latitude and south latitude range is 0°-180°, and the image is captured at the corresponding coordinate points at intervals of 10°.
[0080] 8. Select "E:\11.All project data sets\5.Quick programming\2021.12.30" in "Select image storage path", select ".png" format to save the image in "Select image storage format", and set "Longitude range", "Latitude range", "Zoom ratio", and "Interval division" in "Other parameter settings" to 360, 360, 2, and 10 respectively. Click "Start" to get the projection image of the part in the screen direction under different viewing angles. Full-angle images of parts obtained based on the automated screenshot tool, such as Figure 5 shown.
[0081] 9. Define a pixel information dictionary implemented in C++ programming language. The data in the dictionary is saved in a container to store the grayscale values and coordinate values of pixels that meet different grayscale differences. The storage type corresponding to the container vector is the structure struct. The variable of the structure contains an integer array to evaluate the grayscale category of the corresponding pixel. The size of the array is set to 207406, and the values of all elements in the array are initialized to 1. The subscript of the integer array and its corresponding element constitute the key. The relationship between the array subscript and the corresponding value identifier can be expressed as follows:
[0082] array location =[h R (x,y)+11]*256+[h G (x,y)+14]*257+[h B (x,y)+17]*258 (2)
[0083] array initializing→array[0-207406]={1} (3)
[0084] flag based→array[array location ]=2 (4)
[0085] Among them, array location Indicates the array coordinate position generated based on the grayscale value; array[array location ] represents the corresponding position of the array that satisfies the relationship.
[0086] 10. In the structure in the above step, define another container vector to store the coordinates Point(i,j) of the pixels with the same grayscale. That is, the storage type of the container is also a structure. The structure contains two integer variables row and col to store the row coordinate values and column coordinate values of the pixels that meet the relationship.
[0087] 11. The specific implementation code is: the structure storing pixel coordinates is struct Location{int i; intj;}, and the structure storing pixels satisfying the grayscale relationship is struct VecHead{int vec_int; int length; Vec3b vec; int cha[207406]={1}; vector <location>locationArray;}. In order to achieve accelerated calculation, the optimized code is: for(int i=0; i <img.size[0];i++){for(intj=0;j<img.size[1];j++){if(img.at <vec3b>(i,j)[0]==255&&img.at <vec3b>(i,j)[1]==255&&img.at <vec3b>(i,j)[2]==255)continue;if(img.at <vec3b>(i,j)[0]==0&&img.at <vec3b>(i,j)[1]==0&&img.at <vec3b>(i,j)[2]==0)continue;Vec3b vc3=img.at <vec3b>(i, j); int vec_int = vc3[0] * 256 + vc3[1] * 257 + vc3[2] * 258; / / flag int length, first = 0; for (int k = 0; k < all_location_info.size(); k++) { / / if (all_location_info[k].vec_int == vec_int) if (all_location_info[k].cha[vec_int] == 2) { all_location_info[k].length += 1; / / 2及后录入长度+1 Location loc; loc.row = i; loc.col = j; all_location_info[k].locationArray.push_back(loc); first = 1; break;}} if (first == 0) { VecHead head; head.length = 1; / / 首个录入长度为1, head.vec = vc3; / / 图像位置信息 head.cha[vec_int] = 2; / / int te = vc3[1]; std::cout << "输出第" << num << "个不同灰度" << vc3 << endl; num++; head.vec_int = vec_int; Location loc; loc.row = i; loc.col = j; head.locationArray.push_back(loc); all_location_info.push_back(head);} cout << "[" << img.at <vec3b>(i,j)< <vc3[0]<<"]";}。
[0088] 12. When extracting the grayscale values corresponding to different pixels, the image format read is .png. The matrix scaling corresponding to the image will affect the pixel count statistics number gray , pixel-level grayscale difference value gray R , G , B , pixel coordinate deviation Point(x,y), so the scale of the image matrix should be strictly unified.
[0089] 13. Get the coordinates pixel(x,y) of the pixel with the same grayscale saved as the key in the dictionary, and draw these areas that meet the relationship in a new image of the same size as the original image based on the coordinate information. The way to create a new image by OpenCV is Mat new_image(org.rows,org.cols,CV_8UC3,Scalar(124,251,164)), where Mat is the storage format of image data; org represents the original image; CV_8UC3 represents the image as 8-bit 3-channel; Scalar represents the filled color information, and the filled R, G, B grayscale values are 124, 251, 164; the colors of the corresponding areas of the pixels in new_image that meet the mathematical relationship that key is not 1 are all transformed to 200, 121, 196. That is, the areas where the pixels that meet the key are located in new_image are processed into the same grayscale value, and the effect is as follows: Figure 6 shown.
[0090] 14. All independent three-channel color new_images are binarized by 0 threshold loop processing. The binarization formula is:
[0091]
[0092] Among them, new_cols and new_rows represent the number of rows and columns of the image of new_image respectively; h R-n (x,y),h G-n (x,y),h B-n (x, y) represents the grayscale value of the red, green, and blue channels in new_image at the point (x, y); h 0-1 (x,y) represents the gray value corresponding to (x,y) in the binary image.
[0093] 15. Based on the binary image 4-neighborhood scaling image difference, obtain the high-frequency contour area of the image. 0-1 Back up and get new_image1 0-1 , new_image for the original binary image 0-1 Perform 4-neighborhood scaling operation on the high grayscale area to obtain new_image2 0-1 , new_image1 0-1 with new_image2 0-1 The high-frequency contour line is obtained by subtracting the grayscale values of the corresponding pixel positions.
[0094] The high grayscale area 4 neighborhood scaling operation formula is:
[0095] org(x,y)-kernel four ={min→result(x+x′,y+y′)(x′,y′):kernel four (x′,y′)≠0} (6)
[0096] Among them, org(x,y) represents the image new_image to be scaled 0-1 ;kernel four represents the 4-neighborhood scaling factor; result(x,y) represents the pixel value at the (x,y) position in the image after processing. The 4-neighborhood scaling factor, such as Figure 7-Figure 9 shown.
[0097] The difference method of the gray value of the corresponding pixel position point is:
[0098]
[0099] Among them, h n-1 (x,y) and h n-2 (x, y) represents the grayscale value of the single-channel original binary image and the scaled image at (x, y) respectively; result(x, y) represents the result containing high-frequency contour lines obtained after calculation, such as Fig.10 shown.
[0100] 16. Calculate the minimum enclosing rectangular area of the high-frequency contour line image at zero inclination, combined with Fig.11 To explain, firstly, a loop traversal method is used to obtain the extreme value x of the projection point of the high-frequency contour line on the X and Y axes. min 、x max ,y min ,y max , the corresponding extreme point in the image is the vertex of the minimum enclosing rectangular area with a zero inclination angle. Fig.12 The corresponding x min Corresponding to A′, x max Corresponding to A″″, y min Corresponding to B′, y max Corresponding to B″″″, the grayscale value of the point on the corresponding high-frequency contour line in the image should satisfy result(x,y)=255.
[0101] 17. The image in new_image is intercepted by the obtained coordinates of the minimum enclosing rectangular area with a zero inclination angle, ensuring that the facets of the part's 3D model in the 2D image constitute independent analysis elements. The effect is as follows: Fig.12 shown.
[0102] 18. Reassign the three channels of the foreground area in the captured image. The corresponding assignment method is: the grayscale value of the R channel is 221, the grayscale value of the G channel is 169, and the grayscale value of the B channel is 15.
[0103] 19. After grayscale transformation of each channel of the image patch, the patch attributes are classified and saved based on the index number, and the transformed image is used as a sample image for deep learning.
[0104] 20. The sample images are classified into 6 categories, including sidewall, web, fillet, rib top, bottom corner and others. In order to ensure that the model has a good recognition effect on each type, the number of samples of each type should be close to the numerical relationship of 1:1:1:1:1:1. At the same time, in order to ensure the generalization ability of the model, the number of patches of the same category should be as large as possible and have different feature expressions.
[0105] 21. Randomly select one or more of the following enhancement methods: random rotation at any angle (0°-360° range, the specific value is obtained based on the random number number%360 generated based on time), left-right symmetry, top-bottom symmetry, and proportional scaling of the image along the length cols and width rows (0.7-1.2). The number of enhancement methods is selected as nums=random(time)%4.
[0106] 22. After enhancement, the number of 6 types of feature patches approaches a 1:1 relationship, and the numbers of side walls, webs, fillets, rib tops, bottom angles and others are 6412:5861:6384:6435:6024:6862 respectively.
[0107] 23. Design a deep learning classification network for patch classification. The preprocessing method of training data is transforms.Compose([transforms.Resize((228,228)),transforms.RandomHorizontalFlip(),transforms.ToTensor(),transforms.Normalize([0.481,0.458,0.418],[0.211,0.238,0.227])]).
[0108] 24. The preprocessing method of test data is transforms.Compose([transforms.Resize((228,228)),transforms.ToTensor(),transforms.Normalize([0.481,0.458,0.418],[0.211,0.238,0.227])])}.
[0109] 25. Use resnet50 as the basic network for feature extraction (the corresponding network results are as follows Fig.11 As shown), batch_size=5, num_class=6, num_workers=0, shuffle=True of train_dataset, shuffle=False of validate_dataset, loss_function=nn.CrossEntropyLoss(), optimizer=optim.Adam(net.parameters(),lr=0.0001), initial best_accuracy=0.0, training epoch=106, softmax is used as classifier, the network uses net.train() mode to modify the weight parameters of the network during training, and the network uses net.eval() mode to keep the model parameters of the network unchanged during testing.
[0110] 26. Iterate the training and save the accuracy, loss, and updated network parameters for each epoch. The accuracy and loss are saved in the result.log file.
[0111] 27. Read the network model parameters saved in the epoch corresponding to the minimum training loss and the minimum test sample loss in the result.log file, and initialize the network based on the parameters corresponding to the epoch.
[0112] 28. The image to be analyzed is obtained by the same pre-processing method as the training sample, and the grayscale of the obtained patch filling is consistent with the grayscale of the area corresponding to the training sample.
[0113] 29. The initialization method for patch image data with unknown attributes is transforms.Compose([transforms.Resize((228,228)), transforms.ToTensor(), transforms.Normalize([0.481,0.458,0.418],[0.211,0.238,0.227])])}. The network is set to model.eval() mode, model.load_state_dict(torch.load("optimal weight file")) is used to load the model, output = torch.squeeze(model(img)) is used to get the predicted result, and predict = torch.softmax(output, dim = 0) is used to get the category with the highest probability.
[0114] 30. Use the Image function in the PIL library to batch read the images to be judged img = Image.open (path_all), data conversion img = data_transform (img), img = torch.unsqueeze (img, dim = 0), and then input the model according to softmax to get the final recognized category data, the corresponding data is result 1.
[0115] 31. Batch predict the images under different viewpoints and obtain the result data, which is stored in the dictionary. Finally, the results of the same face in the dictionary under different viewpoints are fused, and more accurate face category information data is obtained based on the voting method, and the corresponding data is result 2.
[0116] 32. The category obtained after voting, i.e., result 2, is saved in the dictionary, and the data is used as the category information of the facet attributes in the three-dimensional image of the part. The fusion results of different facet data are represented in the dictionary, such as Fig.14 shown. < / location>
Claims
1. A method for fusion analysis of surface attributes of full-angle projection images of aviation manufacturing parts. It is characterized in that The method includes the following steps: importing the designed 3D model of the part in the .CATPart format into CATIA, and obtaining all the component slices; All the patches are numbered based on random rules. The numbering order starts from 1. An index table is constructed based on the numbers. Each row of the index table consists of the corresponding patch number and its attributes. Color all the patches in the index table. The initial red, green, and blue values corresponding to the patches in the first row of the index table are h R (x,y)=0、h G (x,y)=125、h B (x,y)=15, the red, green and blue values of the second row are h respectively. R (x,y)=0、h G (x,y)=125、h B (x,y)=35, the red, green, and blue values of the corresponding face in the third row are h R (x,y)=0、h G (x,y)=125、h B (x,y)=55, increasing in sequence when h B (x,y)>255h G (x,y)+25 at the same time h B (x,y)=h B (x,y)%255, increasing in sequence when h G (x,y)>255h R (x,y)+30 at the same time h G (x,y)=h G (x,y)%255; In CATIA software, set the display parameters of the background and part 3D image contour lines. The color in the "Fill" column is set to 0, 0, 0, the "Line Type" is 1, the "Line Width" is 2: 0.8mm, and the "Scattering", "Reflection", and "Diffuse" parameter values are all 1.
00. Based on the secondary development function of CATIA, a full-angle projection image screenshot tool for parts is designed, and the screenshot viewpoint of the part enclosing sphere is set to the coordinates of the intersection of the longitude and latitude lines. The screenshot magnification is 2, the initial arbitrary longitude position is the prime meridian, the east longitude and west longitude range is 0-180°, the north latitude and south latitude range is 0-180°, the image is intercepted at the corresponding coordinate points at intervals of 10°, and the full-angle projection image is obtained; A pixel information dictionary implemented by C++ programming language is defined. The data in the dictionary is stored in a container for storing the grayscale values and coordinate values of pixels that meet different grayscale differences. Get the coordinates pixel(x,y) of the pixel points with the same grayscale saved in the dictionary with grayscale as the key, and draw the pixel point area that satisfies the relationship in a new Scalar(124,251,164) grayscale image of the same size as the original image based on the coordinate information; All independent three-channel color new_images are binarized by using a 0-threshold loop processing method; Based on the binary image 4 neighborhood scaling image difference to obtain the high-frequency contour area of the image; for the binary image new_image 0-1 Back up and get new_image1 0-1 , new_image for the original binary image 0-1 Perform 4-neighborhood scaling operation on high grayscale area to get new_image2 0-1 , new_image1 0-1 with new_image2 0-1 Subtract the grayscale values of corresponding pixel positions to obtain high-frequency contour lines; Calculate the minimum enclosing rectangular area of the high-frequency contour line image at zero inclination, and intercept the rectangular area image; In the captured image, the three channels of the foreground area are reassigned. The corresponding assignment method is: the grayscale value of the R channel is 221, the grayscale value of the G channel is 169, and the grayscale value of the B channel is 15. The processed image is used as a deep learning sample; Design the deep learning classification network and hyperparameters for face classification, resnet50 is the basic network for feature extraction, batch_size=5, num_class=6, num_workers=0, shuffle=True of train_dataset, shuffle=False of validate_dataset, loss_function=nn.CrossEntropyLoss(), optimizer=optim.Adam(net.parameters(),lr=0.0001), initial best_accuracy=0.0, training epoch=106; Iterate the training and save the accuracy, loss, and updated network parameters corresponding to each epoch, select the weight parameters corresponding to the epoch, and initialize the prediction model; Load the predicted image and input it into the network to judge the category, and get result 1; Batch processing is used to predict images from different perspectives and obtain result data, which is stored in the dictionary. Finally, the voting method is used to fuse the results of the same face in the dictionary at different perspectives to obtain more accurate face category information data as result 2, and result 2 is used as the final recognition result of the face.
2. A method for fusion analysis of full-angle projection image patches of aviation manufacturing parts as claimed in claim 1, It is characterized in that The first column of each row in the index table is the corresponding patch number, and the second column is the red grayscale information h corresponding to the patch. R (x, y), the third column is the green grayscale information h corresponding to the patch G (x, y), the fourth column is the blue grayscale information h corresponding to the patch B (x,y), the fifth column is the size of the patch slice .
3. A method for fusion analysis of full-angle projection image patches of aviation manufacturing parts as claimed in claim 2, It is characterized in that The grayscale value of the nth row of patches corresponding to the patch coloring in the index table can be expressed by the following recursive formula: Among them, times R 、times G 、times B They represent the multiplication numbers of the red, green, and blue channels of the patch respectively, and their initial values are all 0.
4. The method for fusion analysis of full-angle projection image patches of aviation manufacturing parts according to claim 1, It is characterized in that The display parameters are set by selecting "Part Geometry" in the left navigation bar of the CATIA software, then selecting "Properties" and "Image", setting the color in the "Fill" column to 0, 0, 0, the color in the "Edge" column to black, and the corresponding "Line Type" to 1, "Line Width" to 2: 0.8mm, set the "Color" in the "Straight Lines and Curves" column to black, and the corresponding "Line Type" to 1, "Line Width" to 2: 0.5mm, hide all points in the 3D image; select "View" and "Lighting" in the "Menu Bar", select "No Light" in the opened "Light Source" window, and the corresponding "Scattering", "Reflection", and "Diffuse" parameter values are all 1.
00.
5. The method for fusion analysis of full-angle projection image patches of aviation manufacturing parts according to claim 1, It is characterized in that In "Select image storage format", select ".png" format to save the image. In "Other parameter settings", set "Longitude range", "Latitude range", "Zoom ratio", and "Interval division" to 360, 360, 2, and 10 respectively. Click "Start" to get the projection images of the parts at different viewing angles.
6. The method for fusion analysis of full-angle projection image patches of aviation manufacturing parts according to claim 1, It is characterized in that The variables of the structure contain an integer array used to evaluate the grayscale category of the corresponding pixel. The size of the array is set to 207406, and the values of all elements in the array are initialized to 1.
7. A method for fusion analysis of full-angle projection image patches of aviation manufacturing parts as claimed in claim 6, It is characterized in that The relationship between the array subscript and the corresponding numerical identifier is expressed as follows: array location =[h R (x,y)+11]*256+[h G (x,y)+14]*257+[h B (x,y)+17]*258 (2) array initializing→array[0-207405]={1} (3) flag based →array[array location ]=2 (4) Among them, array location Indicates the array coordinate position generated based on the grayscale value; array[array location ] represents the corresponding position of the array that satisfies the relationship.
8. The method for fusion analysis of full-angle projection image patches of aviation manufacturing parts as claimed in claim 1, It is characterized in that The way to create a new image by OpenCV is Mat new_image(org.rows,org.cols,CV_8UC3,Scalar(124,251,164)), where Mat is the storage format of image data; org represents the original image; CV_8UC3 means the image is 8-bit and 3-channel; Scalar represents the filled color information, and the filled R, G, and B grayscale values are 124, 251, and 164.
9. The method for fusion analysis of full-angle projection image patches of aviation manufacturing parts according to claim 1, It is characterized in that The colors of the areas corresponding to the pixels in new_image that satisfy the mathematical relationship that key is not 1 are all transformed into 200, 121, and 196, completing the processing of the areas in new_image where the pixels satisfying the mathematical relationship that key is not 1 are located into the same grayscale value.
10. The method for fusion analysis of full-angle projection image patches of aviation manufacturing parts according to claim 1, It is characterized in that The 0 threshold cycle process obtains a binary image, and the binary formula is: Among them, h R-n (x,y),h G-n (x,y),h B-n (x, y) represents the grayscale value of the red, green, and blue channels in new_image at the point (x, y); h 0-1 (x,y) represents the grayscale value corresponding to (x,y) in the binary image.
11. The method for fusion analysis of full-angle projection image patches of aviation manufacturing parts according to claim 1, It is characterized in that The difference method of the gray value of the corresponding pixel position point is: result(x,y)=h n-1 (x,y)-h n-2 (x,y) (7) Among them, h n-1 (x,y) and h n-2 (x, y) represents the grayscale value of the single-channel original binary image and the scaled image at (x, y) respectively; result(x, y) represents the result obtained after calculation containing high-frequency contour lines.
12. A method for fusion analysis of full-angle projection image patches of aviation manufacturing parts as claimed in claim 11, It is characterized in that Use a loop traversal method to obtain the extreme value x of the projection point of the high-frequency contour line on the X and Y axes min 、x max ,y min ,y max , the grayscale value of the point corresponding to the high-frequency contour line in the image should satisfy result (x, y) = 255.
13. The method for fusion analysis of full-angle projection image patches of aviation manufacturing parts according to claim 1, It is characterized in that The sample images are classified into 6 categories, including side wall, web, fillet, rib top, bottom corner and remaining categories.
14. The method for fusion analysis of full-angle projection image patches of aviation manufacturing parts according to claim 1, It is characterized in that Use random rotation at any angle, left-right symmetry, top-bottom symmetry, and proportional scaling of the image along the length cols and width rows to randomly select one or more of them for enhancement.
15. The method for fusion analysis of full-angle projection image patches of aviation manufacturing parts according to claim 1, It is characterized in that The numbers of enhanced side walls, webs, fillets, rib tops, bottom corners and the remaining categories are 6412, 5861, 6384, 6435, 6024 and 6862 respectively.
16. The method for fusion analysis of full-angle projection image patches of aviation manufacturing parts according to claim 1, It is characterized in that Design a deep learning classification network for patch category division. The preprocessing method of training data is transforms.Compose([transforms.Resize(228,228),transforms.RandomHorizontalFlip(),transforms.ToTensor(),transforms.Normalize([0.481,0.458,0.418],[0.211,0.238,0.227])]).
17. The method for fusion analysis of full-angle projection image patches of aviation manufacturing parts according to claim 1, It is characterized in that The test data is preprocessed using transforms.Compose([transforms.Resize(228,228),transforms.ToTensor(),transforms.Normalize([0.481,0.458,0.418],[0.211,0.238,0.227])]).
18. The method for fusion analysis of full-angle projection image patches of aviation manufacturing parts according to claim 1, It is characterized in that The weight parameter selection method is: read the network model parameters saved in the epoch corresponding to the minimum training loss and the minimum test sample loss in the result.log file, and initialize the network based on the parameters corresponding to the epoch.
19. The method for fusion analysis of full-angle projection image patches of aviation manufacturing parts according to claim 1, It is characterized in that The network is set to model.eval() mode, output = torch.squeeze(model(img)) to get the predicted result, and predict = torch.softmax(output, dim = 0) is used to get the category with the highest probability.
20. The method for fusion analysis of full-angle projection image patches of aviation manufacturing parts according to claim 1, It is characterized in that Use the Image function in the PIL library to batch read the images to be judged img = Image.open (path_all), data conversion img = data_transform (img), img = torch.unsqueeze (img, dim = 0), and then input the model according to softmax to get the final recognized category data, and the corresponding data is result 1.
21. The method for fusion analysis of full-angle projection image patches of aviation manufacturing parts according to claim 1, It is characterized in that The category obtained after voting, that is, result 2, is used as the category information of the face patch attribute in the three-dimensional image of the part.
Citation Information
Patent Citations
Projection full-convolution network three-dimensional model segmentation method based on fusion of multi-view-angle features
CN108389251A
Deep learning chip packaging crack defect detection method based on YOLO
CN112967243A
