Method for drawing patrol route map based on Graphics2D Qt scanning data
Through the Qt scanning data drawing method based on Graphics2D, the problem of unfixed pixels and insufficient detail display of inspection routes generated by traditional methods is solved, and fixed resolution and high-quality inspection route map generation is realized, which is suitable for real-time monitoring and management of robot inspection systems.
Patent Information
- Application Number
- CN202411559534.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-02-25
AI Technical Summary
The pixels of the inspection route image generated by the traditional Qt scanning tool are not fixed, which is difficult to meet the needs of fixed resolution, and it is impossible to clearly display the inspection route, key points and the real-time location of the robot.
Using the Graphics2D-based Qt scan data drawing method, we use the Graphics2D-based Qt scan data to create image objects of specified pixels, acquire and preprocess point cloud data, calculate and convert coordinate systems, draw map elements and generate images using the Graphics2D tool.
The generated inspection roadmap has fixed resolution and high quality, and can clearly display inspection routes and real-time locations, improving the display effect and practicality of the image, and is suitable for real-time monitoring and management of robot inspection systems.
Smart Images

Figure CN119516029A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of industrial automation and intelligent monitoring, and in particular to a method for drawing a patrol route map based on Qt scanning data of Graphics2D. Background Art
[0002] In the field of industrial automation and intelligent monitoring, robot inspection systems are widely used due to their high efficiency and accuracy. Robot inspection requires real-time display of the robot's inspection route and location on the monitoring interface to facilitate monitoring and management by operators. In order to achieve this function, it is usually necessary to display the robot's inspection base map on the page and cooperate with real-time location push to achieve dynamic effects.
[0003] The traditional method is to use the image scanning tool in the Qt framework to directly generate images. This method is simple and easy to use, but there are some limitations in practical applications. Specifically, the pixels of the images generated by the Qt image scanning tool are not fixed and will change with the size of the scanning area. This results in inconsistent resolution of the generated images in different scenarios, making it difficult to meet the requirements of fixed resolution. For example, a unified 1280*960 pixel image is required on the monitoring interface to ensure the consistency and accuracy of the display effect.
[0004] In addition, since the robot patrol route map needs to clearly display the patrol route, key points and the real-time position of the robot, the pictures generated by traditional methods often cannot meet the needs of displaying these details, especially in terms of high resolution and high definition. Therefore, the drawing of patrol route maps needs further improvement. Summary of the invention
[0005] The present invention aims to solve one of the technical problems existing in the related art at least to a certain extent. Therefore, a method for drawing a patrol route map based on Qt scan data of Graphics2D is provided to generate a patrol route map with fixed resolution and high quality.
[0006] In order to achieve the above-mentioned object, the present invention provides a method for drawing a patrol route map based on Qt scanning data of Graphics2D, comprising:
[0007] S1. Create a Graphics2D object and use BufferedImage to construct an image object of a specified pixel;
[0008] S2, obtain the original point cloud file data, perform preprocessing, and extract common points, patrol routes, and patrol points;
[0009] S3. Calculate the offset rate of a coordinate system with the upper left corner as the origin, the right as the positive direction of the X axis, and the bottom as the positive direction of the Y axis according to the original point coordinates; transform the entire amount of data using the offset rate to transform the coordinate system;
[0010] S4. Use the Graphics2D tool to draw map elements including routes and inspection points;
[0011] S5. After all elements are drawn, use the image writing tool to generate the image.
[0012] A further preferred technical solution of the present invention is that when using BufferedImage to construct an image object of a specified pixel in step S1, anti-aliasing properties and high-quality compression properties are set.
[0013] Preferably, when extracting common points in step S2, overlapping points are diluted.
[0014] Preferably, the method for extracting the patrol route in step S2 is: according to the node attributes of the points, sequentially obtain point data with patrol route attributes, and then sequentially connect the points to form a patrol route;
[0015] The method for extracting patrol points is as follows: according to the node attributes of the points, point data with patrol point attributes are extracted, and then the feature points are marked on the image according to the point attributes in the point data.
[0016] Preferably, when calculating the offset rate in step S3, a multiple factor affecting the offset rate is calculated based on the maximum value of the point data and the maximum value of the canvas.
[0017] Preferably, in step S4, a Graphics2D tool is used to draw a map element including a route and inspection points, and the specific method is as follows:
[0018] First, call Graphics2D.setColor to set the color of the brush as required;
[0019] Then call Graphics2D.drawLine to connect every two points in the track with a line segment, so that each track is connected into an overall route;
[0020] Call Graphics2D.fillOvall to draw the inspection points, and different types of inspection points are distinguished by different colors.
[0021] Preferably, after all elements are drawn in step S5, an image writing tool is used to generate an image, and the specific method is as follows:
[0022] After all elements are drawn, call the Graphics2D.dispose method to dispose of the drawing.
[0023] Then use the image writing tool javax.imageio.ImageIO class to generate the image.
[0024] On the other hand, the present invention provides a non-transitory computer-readable storage medium having computer instructions stored thereon, which enable a computer to execute the above-mentioned method of drawing a patrol route map based on Qt scanning data of Graphics2D.
[0025] Another aspect of the present invention provides an electronic device, comprising: a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus, and the processor calls the logic instructions in the memory to execute the above-mentioned method of drawing a patrol route map based on Qt scanning data based on Graphics2D.
[0026] On the other hand, the present invention provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer executes the above-mentioned method of drawing a patrol route map based on Qt scan data of Graphics2D.
[0027] Beneficial effects: Through the above technical solution, the present invention can generate a high-quality patrol route map that meets the fixed resolution requirements, improves the display effect and practicality of the image, and also facilitates the real-time monitoring and management of the robot patrol system.
[0028] The invention generates a standard patrol route map based on the method of drawing images by Graphics2D, and the implementation process is simple and convenient. The invention realizes the generation of a patrol route map according to different pixel size specifications by setting the upper left corner as the origin position, calculating the coordinate conversion rate, and completing the conversion of the new coordinate system. The patrol route map generated by the invention can be directly converted into a stream for network transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 The present invention is a flowchart of a method for drawing a patrol route map based on Qt scanning data of Graphics2D. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings in the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments, and they should not be understood as limitations on the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. In the description of the present invention, it should be understood that the terms used are only for descriptive purposes and cannot be understood as indicating or implying relative importance.
[0031] Combine the following Figure 1 The present invention describes a method for drawing a patrol route map based on Qt scanning data of Graphics2D.
[0032] Embodiment 1: This embodiment provides a method for drawing a patrol route map based on Qt scanning data of Graphics2D.
[0033] 1. Implementation environment and tools
[0034] Development environment: Java development environment, Qt framework
[0035] Graphics processing library: Java Graphics2DAPI
[0036] Data format: point cloud data in JSON format
[0037] Image output format: JPEG
[0038] 2. Implementation steps
[0039] Step 1: Create a Graphics2D object
[0040] Use Java's BufferedImage class to create an image object with a width of 1280 pixels and a height of 960 pixels. BufferedImage is a buffered image class that provides functions such as obtaining drawing objects, image scaling, and selecting image smoothness. It is usually used to resize images, gray images, set transparency or opacity, etc. When constructing, you can fill in the image's width and height; then get a Graphics2D object based on the BufferedImage class; in order to improve the quality and clarity of the image, you need to add anti-aliasing properties and high-quality compression properties.
[0041] Step 2: Point cloud preprocessing
[0042] Use Java's FileUtils class to read the JSON format point cloud data file stored on the server.
[0043] Parse the JSON data and extract common points, patrol routes and patrol points. The operation of extracting points is as follows:
[0044] Get common points: Since the original file has dense points, according to calculations, if you want to draw it on a 1280*960 image according to the number of original points, many points will overlap. Algorithm optimization is needed to dilute the overlapping points.
[0045] Get the patrol route: According to the node attributes of the points, the point data with patrol route attributes are obtained in sequence, and then the points can be connected in sequence to form a patrol route image.
[0046] Get patrol points: According to the node attributes of the points, extract the point data with patrol point attributes, and then mark the feature points on the image according to the point attributes in the point data.
[0047] Step 3: Transform the coordinate system
[0048] Calculate the offset rate from the original point coordinates to the new coordinate system, with the upper left corner as the origin, the right as the positive direction of the X axis, and the bottom as the positive direction of the Y axis. Calculate the offset pixel size based on the multiple size and the up, down, left, and right directions to ensure that the image is displayed in the center of the canvas. Apply the offset rate to all original point data to complete the coordinate system transformation.
[0049] The reason for this step is that after obtaining all the required original points, the coordinates of the origin are drawn with the center point as the origin. It is necessary to calculate the offset rate of the coordinate system with the upper left corner as the origin, the right as the positive direction of the X axis, and the bottom as the positive direction of the Y axis.
[0050] The factors that affect the offset are mainly the multiple size and the up, down, left, and right directions. Among them, the multiple factor can be calculated based on the maximum value of the point data and the maximum value of the canvas. In order to achieve the overall image effect, it is necessary to draw at the central symmetrical position of the canvas and calculate the moving pixel size of the up, down, left, and right directions.
[0051] Step 4: Draw the map elements
[0052] Use the Graphics2D object to set the pen color. For example, the route uses blue (RGB: 0,0,255) and the patrol point uses red (RGB: 255,0,0).
[0053] Call the Graphics2D.drawLine method to draw the tour route based on the converted coordinates.
[0054] Call the Graphics2D.fillOval method to draw the patrol points, and set the width and height to 10 pixels.
[0055] Step 5: Image Generation
[0056] After completing all drawing operations, call the Graphics2D.dispose method to release resources.
[0057] Use the javax.imageio.ImageIO class to save the drawn image in JPEG format, and the save path is the specified directory of the server.
[0058] The image writing tool uses the javax.imageio.ImageIO class. Calling the write(RenderedImageim,String formatName,OutputStream output) method can write the image to the output stream. Calling the write(RenderedImage im,String formatName,File output) method can write the image to a file according to a specific path. The second parameter of the write method is the write file format, which can be set to jpg.
[0059] 3. Implementation Effect
[0060] Through the above embodiments, a patrol route map with a resolution of 1280*960 pixels is successfully generated, the image is clear, and the patrol route and point markings are accurate.
[0061] Images can be directly transmitted to the monitoring interface via the network for real-time updating and display.
[0062] By adjusting the properties of the Graphics2D object, you can flexibly control the quality and style of the image to meet different display requirements.
[0063] Embodiment 2: This embodiment provides a non-transitory computer-readable storage medium on which computer instructions are stored. The computer instructions enable a computer to execute the method of drawing a patrol route map based on Qt scan data of Graphics2D in Embodiment 1.
[0064] Embodiment 3: This embodiment provides an electronic device, which may include: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus. The processor may call the logic instructions in the memory to execute the method of drawing a patrol route map based on Qt scanning data of Graphics2D in Embodiment 1.
[0065] In addition, the logic instructions in the above-mentioned memory can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0066] Embodiment 4: This embodiment provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the method of drawing a patrol route map based on Qt scan data of Graphics2D in Embodiment 1.
[0067] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0068] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0069] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these 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.
Claims
1. A method for drawing a patrol route map based on Qt scanning data of Graphics2D, characterized in that: include: S1. Create a Graphics2D object and use BufferedImage to construct an image object of a specified pixel; S2, obtain the original point cloud file data, perform preprocessing, and extract common points, patrol routes, and patrol points; S3. Calculate the offset rate of a coordinate system with the upper left corner as the origin, the right as the positive direction of the X axis, and the bottom as the positive direction of the Y axis according to the original point coordinates; transform the entire amount of data using the offset rate to transform the coordinate system; S4. Use the Graphics2D tool to draw map elements including routes and inspection points; S5. After all elements are drawn, use the image writing tool to generate the image.
2. The method for drawing a patrol route map based on Qt scanning data of Graphics2D according to claim 1, characterized in that: When constructing an image object of a specified pixel using BufferedImage in step S1, anti-aliasing properties and high-quality compression properties are set.
3. The method for drawing a patrol route map based on Qt scanning data of Graphics2D according to claim 1, characterized in that: When extracting common points in step S2, the overlapping points are diluted.
4. The method for drawing a patrol route map based on Qt scanning data of Graphics2D according to claim 3 is characterized in that: The method for extracting the patrol route in step S2 is: according to the node attributes of the points, point data with patrol route attributes are obtained in sequence, and then point-to-point lines are connected in sequence to form a patrol route; The method for extracting patrol points is as follows: according to the node attributes of the points, point data with patrol point attributes are extracted, and then the feature points are marked on the image according to the point attributes in the point data.
5. The method for drawing a patrol route map based on Qt scanning data of Graphics2D according to claim 1, characterized in that: When calculating the offset rate in step S3, the multiple factor affecting the offset rate is calculated according to the maximum value of the point data and the maximum value of the canvas.
6. The method for drawing a patrol route map based on Qt scanning data of Graphics2D according to claim 1, characterized in that: In step S4, the Graphics2D tool is used to draw map elements including routes and inspection points. The specific method is as follows: First, call Graphics2D.setColor to set the color of the brush as required; Then call Graphics2D.drawLine to connect every two points in the track with a line segment, so that each track is connected into an overall route; Call Graphics2D.fillOvall to draw the inspection points, and different types of inspection points are distinguished by different colors.
7. The method for drawing a patrol route map based on Qt scanning data of Graphics2D according to claim 1, characterized in that: After all elements are drawn in step S5, an image is generated using an image writing tool. The specific method is as follows: After all elements are drawn, call the Graphics2D.dispose method to dispose of the drawing. Then use the image writing tool javax.imageio.ImageIO class to generate the image.
8. A non-transitory computer-readable storage medium having computer instructions stored thereon, wherein the computer instructions enable a computer to execute the method of drawing a patrol route map based on Qt scan data of Graphics2D as described in any one of claims 1-7.
9. An electronic device, comprising: A processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus, and the processor calls the logic instructions in the memory to execute the method for drawing a patrol route map based on Qt scanning data of Graphics2D as described in any one of claims 1-7.
10. A computer program product, comprising a computer program stored on a non-transitory computer-readable storage medium, wherein when the computer program is executed by a processor, the computer executes the method of drawing a patrol route map based on Qt scan data of Graphics2D as described in any one of claims 1 to 7.