Bounding box in-point quantity counting method and system for browser endpoint cloud labeling

CN122653742APending Publication Date: 2026-08-28SUZHOU KUSHUJU INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611123559.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-28
Publication Date
2026-08-28

AI Technical Summary

Technical Problem

其中,服务端方案需要频繁上传查询请求并等待统计结果返回,存在网络通信延迟,难以满足实时交互需求;桌面客户端方案依赖本地计算环境,不利于纯Web标注系统部署;浏览器的主线程统计方式通常需要遍历候选点并逐点执行包围盒包含关系检测,在面对千万级点云数据时,容易占用大量CPU资源,影响浏览器界面响应速度

Benefits of technology

首先,本发明通过将逐点几何包含检测从主线程卸载至Web Worker,并在八叉树层级上对节点进行outside、inside、intersect三类空间分类,使outside节点直接剔除、inside节点直接累加计数、仅intersect节点进入Web Worker逐点检测,从而显著降低了主线程阻塞时间,避免了浏览器UI卡顿,同时大幅减少了无效计算比例,提升了整体统计效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122653742A_ABST
    Figure CN122653742A_ABST
Patent Text Reader

Abstract

The application discloses a bounding box in-point quantity counting method and system for browser endpoint cloud labeling, and comprises the following steps: step one, receiving a bounding box parameter, and constructing a space classifier; step two, traversing a point cloud space index node and completing node classification; step three, eliminating an outside node, directly counting an inside node, and encapsulating an intersect node into a NodeRecord array; step four, batch sending the NodeRecord array to a Web Worker; step five, point-by-point resolving the NodeRecord array and counting point quantities according to a queryKey; step six, returning a counting dictionary to a main thread; and step seven, merging the counting dictionary and a direct counter to obtain a bounding box in-point quantity. The application realizes efficient and accurate counting of the point cloud quantity in the bounding box at the browser end, and improves the point cloud labeling efficiency and interaction performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of 3D point cloud data processing and computer graphics interaction technology, and in particular to a method and system for counting the number of points within a bounding box for browser endpoint cloud annotation. Background Technology

[0002] With the development of technologies such as autonomous driving, digital twins, surveying and modeling, and 3D reconstruction, the scale of 3D point cloud data is constantly increasing, and browser-based point cloud visualization is gradually becoming an important implementation method for point cloud annotation systems. Existing browsers typically employ techniques such as octrees, multi-resolution hierarchical structures, frustum culling, and on-demand loading to organize and render massive amounts of point cloud data, loading only the data in the currently visible area to reduce network transmission and GPU rendering pressure, thus enabling real-time browsing of large-scale point clouds. During point cloud annotation, annotators typically use 3D bounding boxes to annotate targets such as vehicles, pedestrians, and traffic facilities, and need to obtain the number of points contained within the bounding box in real time to help determine whether the annotation box is accurate, the target is complete, and the annotation quality meets requirements. It is also widely used in scenarios such as quality inspection, multi-frame tracking, batch editing, and training sample selection.

[0003] In existing technologies, the counting of points within bounding boxes is typically achieved through server-side computation, desktop client computation, or point-by-point traversal computation via the browser's main thread. Server-side solutions require frequent uploading of query requests and waiting for statistical results, resulting in network communication latency and making it difficult to meet real-time interaction requirements. Desktop client solutions rely on local computing environments, which is not conducive to the deployment of pure web annotation systems. Browser-based main thread methods typically require traversing candidate points and performing bounding box containment relationship detection point by point, which can easily consume significant CPU resources and affect browser interface responsiveness when dealing with tens of millions of point cloud datasets. Furthermore, while some solutions introduce Web Workers for asynchronous computation, they still suffer from insufficient candidate data filtering, duplicate copying of binary data, difficulties in buffer ownership management, repeated reading of multiple frames of data, and a lack of a unified scheduling mechanism between continuous query requests. This leads to wasted computing resources, increased memory consumption, and delayed updates of statistical results, making it difficult to balance statistical efficiency with browser interaction performance.

[0004] Therefore, how to provide a method and system for counting the number of points within a bounding box for browser endpoint cloud annotation is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0005] One objective of this invention is to propose a method and system for counting the number of points within a bounding box for browser endpoint cloud annotation. This invention comprehensively utilizes technologies such as octree spatial classification, asynchronous computation with Web Worker, zero-copy transmission with TransferableArrayBuffer, multi-frame aggregation statistics, and request cancellation control to achieve efficient real-time counting of the number of points within a bounding box on the browser side. It has the advantages of fast counting speed, low memory overhead, smooth interactive response, high accuracy of results, and strong concurrent processing capabilities.

[0006] The method for counting the number of points within a bounding box for browser endpoint cloud annotation according to an embodiment of the present invention includes the following steps: Step 1: Receive bounding box parameters from the 3D point cloud annotations on the browser and construct a spatial classifier; Step 2: In the browser's main thread, traverse the point cloud spatial index nodes and call the spatial classifier to classify the nodes as outside, inside, or intersect; Step 3: Remove outside nodes directly, increment the number of inside nodes that meet the conditions to the direct counter, and read binary data for intersect nodes or nodes that need frame filtering and encapsulate them into NodeRecord arrays in batches. Step 4: Send the NodeRecord array to the WebWorker in batches using Transferable ArrayBuffer; Step 5: Receive batch data, perform coordinate decoding, frame attribute parsing, and bounding box containment detection point by point for each NodeRecord array in the batch, and aggregate the number of points by queryKey; Step 6: Return the counting dictionary with queryKey as the key and the number of points as the value to the main thread; Step 7: In the main thread, merge the counting dictionary and the direct counter to obtain the final number of points for each queryKey, and after consistency verification, fill the result back into the annotation object and update the UI.

[0007] Optionally, step two specifically includes: One or more QueryItems are generated based on the business scenario. Each QueryItem includes queryKey, frameIndex, enableFrameFilter, and geometrySignature. The queryKey is a unique identifier for statistical result aggregation and backfilling, the frameIndex is the target frame index, the enableFrameFilter is an identifier for whether frame attribute filtering is enabled, and the geometrySignature is the bounding box geometry signature when the request is initiated. In the browser, the main thread creates a statistics context, including requestId, AbortSignal, traversal stack, direct counter, batch to be sent, number of visited nodes, number of detected points, and performance monitoring metrics. Among them, requestId is a unique identifier for the request, AbortSignal is the cancellation signal, the traversal stack is used to store the octree nodes to be traversed, and the direct counter is used to store the number of points directly accumulated by the main thread. The main thread performs a depth-first or breadth-first traversal starting from the root node of the octree, and for each node... Get the bounding box of the node. Call the OBB / AABB spatial classifier to perform spatial classification on the node: If node node bounding box If a node does not intersect with the target OBB, it is classified as outside and skipped, along with all its child nodes. If node node bounding box If the entire node is located inside the target OBB, then the node is classified as inside, and the fullyInside state is passed to all child nodes of that node. If node node bounding box If a node intersects with the target OBB portion, it is classified as an intersect and enters the candidate batch for point-by-point detection. During the traversal, the main thread periodically executes the yield operation based on the node count threshold or the time consumption threshold, returning control to the browser event loop to avoid prolonged occupation of the main thread and causing UI lag.

[0008] Optionally, step three specifically includes: For nodes classified as outside, the main thread directly removes the node without performing any counting or data transfer operations; For nodes categorized as inside, the main thread determines whether the node meets the direct counting condition. The direct counting condition is that the enableFrameFilter of all query items is disabled, and the node's point count metadata is reliable. If the direct counting condition is met, the main thread will directly add the number of points of that node to the direct counters corresponding to all queryKeys. If the direct counting condition is not met, the main thread will treat the node as a candidate node and proceed to the subsequent processing flow. For nodes classified as intersect, and inside nodes that do not meet the direct counting conditions, the main thread reads the binary point cloud data and attribute layout metadata of the node, constructs a NodeRecord array through all node records, and adds the NodeRecord array to the batch to be sent.

[0009] Optionally, step four specifically includes: When the number of nodes in the batch to be sent reaches or the cumulative number of bytes reaches When the main thread calls the WebWorker's message sending method, it passes in the batch request and the list transferList as parameters. The ArrayBuffer in transferList transfers ownership from the main thread to the WebWorker through the Transferable mechanism, and the original buffer of the main thread is set to the detached state. The main thread adds the buffers of all NodeRecord arrays in the batch to be sent that are in the transferred state to the transferList, which is a list of transferable ArrayBuffers; After sending is complete, the main thread clears the current batch to be sent and resets the cumulative number of bytes to zero, and continues to execute the traversal operation in step two; The maximum number of nodes in a single batch is recommended to be between 8 and 32, with an optimal value of 16. The maximum number of bytes per batch is 4MB to 16MB, with 8MB being the preferred value.

[0010] Optionally, step five specifically includes: The Web Worker receives batch requests sent by the main thread, verifies the requestId, initializes the counting dictionary, and iterates through each NodeRecord array in the batch. For each NodeRecord array, the Web Worker reads each point in steps of pointByteSize using DataView or TypedArray. For compressed coordinates, world coordinates are restored based on the coordinate scaling factor and origin offset. If frame filtering is enabled, the frame attribute value is read from the frame attribute offset position and mapped to the target queryKey; For non-fullyInside nodes, the Web Worker transforms the point's world coordinates to the bounding box local coordinate system and determines whether the point is inside the OBB based on the half-length vector and tolerance. If the point meets the internal judgment condition of OBB, the Web Worker will increment the count of the queryKey corresponding to that point.

[0011] Optionally, step six specifically includes: After completing the point-by-point statistics, the Web Worker returns the batch results to the main thread and returns the count dictionary by queryKey; If the ownership return strategy is adopted, the batch results will carry the ArrayBuffer that needs to be returned; After the Web Worker finishes processing, the buffer will be returned as a Transferable object along with the batch results. The main thread receives the returned buffer and restores the node cache state to available; If AbortSignal triggers cancellation during processing, the Web Worker terminates the current statistical operation, and the cancellation control module decides whether to discard the processed results, re-acquire node data, or rebuild the node cache based on the timing of the cancellation.

[0012] Optionally, step seven specifically includes: The main thread receives the batch results, merges them with the direct counter, and obtains the final number of points for each queryKey; Before backfilling, check whether the current requestId and geometrySignature are still consistent with those when the statistics were initiated; if either of the above checks is inconsistent, the main thread discards the batch of results and refuses to backfill the old results to the UI. If all the above checks are consistent, the main thread will count the final points corresponding to each queryKey. Write the data layer of the annotation object and trigger the UI update operation to display the number of points corresponding to each queryKey on the annotation interface.

[0013] A bounding box point count system for browser endpoint cloud annotation according to an embodiment of the present invention includes: The parameter receiving module is used to receive bounding box parameters from the 3D point cloud annotations on the browser and build a spatial classifier. The spatial classification module is used to traverse the spatial index nodes of the point cloud in the main thread of the browser and call the spatial classifier to classify the nodes as outside, inside or intersect. The batch encapsulation module is used to directly remove outside nodes, directly increment the number of inside nodes that meet the conditions to a direct counter, and read binary data of intersect nodes or nodes that need frame filtering and encapsulate them into NodeRecord arrays in batches. The batch sending module is used to send NodeRecord arrays in batches to Web Workers via Transferable ArrayBuffer; The point-by-point statistics module is used to accept batch data, perform coordinate decoding, frame attribute parsing and bounding box containment detection on each point of the NodeRecord array in the batch, and aggregate the number of points by queryKey; The result return module is used to return a counting dictionary with queryKey as the key and the number of points as the value to the main thread; The statistics merging module is used to merge the counting dictionary and the direct counter in the main thread to obtain the final number of points for each queryKey, and after consistency verification, the results are backfilled into the annotation object and the UI is updated.

[0014] The beneficial effects of this invention are: First, this invention offloads point-by-point geometric inclusion detection from the main thread to a Web Worker, and classifies nodes into three spatial categories—outside, inside, and intersect—at the octree level. This allows outside nodes to be directly removed, inside nodes to be directly counted, and only intersect nodes to enter the Web Worker for point-by-point detection. This significantly reduces the main thread blocking time, avoids browser UI lag, and greatly reduces the proportion of invalid calculations, thereby improving overall statistical efficiency.

[0015] Secondly, this invention utilizes Transferable ArrayBuffer to batch transfer candidate node binary data, achieving zero-copy data transfer between the main thread and Web Worker. This avoids the high memory peaks, GC pressure, and throughput reduction issues caused by traditional structured cloning. Furthermore, through a buffer ownership management mechanism, while maintaining the advantages of zero-copy, it prevents the main thread from mistakenly accessing the detached buffer after the transfer, ensuring the collaborative work between the statistical task and the front-end point cloud rendering cache.

[0016] Finally, this invention improves the efficiency of multi-frame statistics by carrying multiple QueryItems in a single Web Worker request, enabling point counts for multiple frames to be completed with a single node read and a single data transfer. Simultaneously, through combined validation using AbortSignal, requestId, and geometrySignature, old requests generated by continuous dragging or batch editing by the user are canceled and isolated, ensuring result consistency and preventing old results from overwriting the current UI state. Furthermore, by using node count thresholds, byte count thresholds, and a main thread yield mechanism, throughput, memory usage, and UI responsiveness are dynamically balanced, supporting real-time statistical needs in continuous interaction scenarios. Attached Figure Description

[0017] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is a flowchart of the method for counting the number of points within a bounding box for browser endpoint cloud annotation proposed in this invention. Figure 2 This is a schematic diagram illustrating the collaboration between the main thread and Web Worker in the method for counting the number of points within a bounding box for browser endpoint cloud annotation proposed in this invention. Figure 3 This is a schematic diagram of the two-level decision mechanism of the spatial classifier for the bounding box point count method for browser endpoint cloud annotation proposed in this invention. Figure 4 This is a module structure diagram of the bounding box point count system for browser endpoint cloud annotation proposed in this invention. Detailed Implementation

[0018] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.

[0019] refer to Figures 1-3 A method for counting the number of points within a bounding box in browser endpoint cloud annotations includes the following steps: Step 1: Receive bounding box parameters from the 3D point cloud annotations on the browser and construct a spatial classifier; Step 2: In the browser's main thread, traverse the point cloud spatial index nodes and call the spatial classifier to classify the nodes as outside, inside, or intersect; Step 3: Remove outside nodes directly, increment the number of inside nodes that meet the conditions to the direct counter, and read binary data for intersect nodes or nodes that need frame filtering and encapsulate them into NodeRecord arrays in batches. Step 4: Send the NodeRecord array in batches to the WebWorker via Transferable ArrayBuffer; Step 5: Receive batch data, perform coordinate decoding, frame attribute parsing, and bounding box containment detection point by point for each NodeRecord array in the batch, and aggregate the number of points by queryKey; Step 6: Return the counting dictionary with queryKey as the key and the number of points as the value to the main thread; Step 7: In the main thread, merge the counting dictionary and the direct counter to obtain the final number of points for each queryKey, and after consistency verification, fill the result back into the annotation object and update the UI.

[0020] In this embodiment, step one specifically includes: Receive bounding box parameters drawn or edited by the user in the 3D point cloud annotation scene on the browser, denoted as ,in This represents the vector representing the center position of the bounding box. Represents the length, width, and height dimensions of the bounding box as vectors. The rotation parameters of the bounding box can be represented using any of Euler angles, quaternions, or rotation matrices. A directed bounding box is a three-dimensional rectangular bounding box whose orientation can be rotated arbitrarily, denoted as OBB; An axis-aligned bounding box is a three-dimensional rectangular bounding box whose sides are parallel to the coordinate axes, denoted as AABB; Based on the bounding box parameter B, construct the transformation matrix from the local coordinate system of the bounding box to the world coordinate system. And find the inverse matrix of the transformation matrix. ; The formula for calculating the half-length vector h of the bounding box is as follows: ; in, This represents the half-length of the bounding box along the x-axis. This represents the half-length of the bounding box along the y-axis. This represents the half-length of the bounding box along the z-axis. Calculate the AABB of OBB in the world coordinate system as the coarse boundary for fast node removal; Based on the above parameters, an OBB / AABB spatial classifier is constructed, which employs a two-level decision mechanism: Level 1: Perform fast overlap detection between node AABB and the world AABB of the target OBB. If there is no overlap between node AABB and the world AABB of the target OBB, then classify the node as outside. Level 2: If there is overlap in the judgment, the OBB / AABB is accurately classified by corner point transformation or the separating axis theorem, and the node is judged as one of the three categories: outside, inside or intersect. Here, node AABB is the axis-aligned bounding box of the octree node itself, target OBB is the directed bounding box drawn by the user, and world AABB is the axis-aligned bounding box of target OBB calculated in the world coordinate system.

[0021] In this embodiment, step two specifically includes: One or more query items (QueryItems) are generated based on the business scenario. In a single-frame scenario, a single query item containing only the current frame index is generated. In a multi-frame scenario or a batch editing scenario, multiple query items containing multiple frame indices are generated. Each QueryItem includes queryKey, frameIndex, enableFrameFilter, and geometrySignature. The queryKey is a unique identifier for statistical result aggregation and backfilling, the frameIndex is the target frame index, the enableFrameFilter is an identifier for whether frame attribute filtering is enabled, and the geometrySignature is the bounding box geometry signature when the request is made. The main thread creates a statistics context in the browser, which includes requestId, AbortSignal, traversal stack, direct counter, batch to be sent, number of visited nodes, number of detected points, and performance monitoring metrics. Among them, requestId is a unique identifier for the request, AbortSignal is the cancellation signal, traversal stack is used to store the octree nodes to be traversed, and direct counter is used to store the number of points directly accumulated by the main thread. The main thread performs a depth-first or breadth-first traversal starting from the root node of the octree, and for each node... Get the bounding box of the node. Call the OBB / AABB spatial classifier to perform spatial classification on the node: If node node bounding box If a node does not intersect with the target OBB, it is classified as outside and skipped, along with all its child nodes. If node node bounding box If the entire node is located inside the target OBB, then the node is classified as inside, and the fullyInside state is passed to all child nodes of that node. If node node bounding box If a node intersects with the target OBB portion, it is classified as an intersect and enters the candidate batch for point-by-point detection. During the traversal, the main thread periodically executes the yield operation based on the node count threshold or the time consumption threshold, returning control to the browser event loop to avoid prolonged occupation of the main thread and causing UI lag.

[0022] In this embodiment, step three specifically includes: The main thread performs differentiation processing on the categorized nodes: For nodes classified as outside, the main thread directly removes the node without performing any counting or data transfer operations; For nodes categorized as inside, the main thread determines whether the node meets the direct counting condition. The direct counting condition is that the enableFrameFilter of all query items is disabled, and the node's point count metadata is reliable. If the direct counting condition is met, the main thread will directly add the number of points of that node to the direct counters corresponding to all queryKeys. If the direct counting condition is not met, the main thread will treat the node as a candidate node and proceed to the subsequent processing flow. For nodes classified as intersect, and inside nodes that do not meet the direct counting conditions, the main thread reads the binary point cloud data and attribute layout metadata of the node, constructs a NodeRecord array through all node records, and adds the NodeRecord array to the batch to be sent. The NodeRecord array includes the following fields: nodeId is the unique identifier of the octree node, buffer is the ArrayBuffer corresponding to the binary point data of the node, the number of points contained in the node, pointByteSize is the length of a single point in bytes, positionOffset is the offset of the coordinate attribute in the single point record, frameOffset is the offset of the frame attribute in the single point record, frameType is the data type of the frame attribute, scale is the coordinate scaling factor vector, offset is the coordinate origin offset vector, and fullyInside is an indicator of whether the node has been determined to be completely inside the target OBB; The main thread maintains the ownership status of the buffer for each NodeRecord array in the batch to be sent. The ownership status of the buffer includes three states: available, transferred, and shared. For a buffer with a status of available, if the data of that node is no longer used by the main thread for rendering cache, the main thread marks its status as transferred and adds it to transferList; `transferList` is a list of ArrayBuffers whose ownership is to be transferred. It is passed as the second parameter to the `worker.postMessage` method, so that each ArrayBuffer is transferred to the Web Worker with zero copy through the Transferable mechanism. If the node's data still needs to be used by the main thread for rendering and caching, the main thread will use one of the following strategies: Retrieve a separate ArrayBuffer from the data source and keep the original buffer state available; After the Web Worker statistics are completed, the ownership of the buffer in the transferred state is returned to the main thread and restored to the available state; When cross-source isolation security conditions are met, SharedArrayBuffer is used as a read-only shared buffer and its state is marked as shared; For non-transferable shared data, slice copying is performed within a controlled range, and peak memory usage is limited by batch thresholds.

[0023] In this embodiment, step four specifically includes: The main thread monitors the number of nodes and the cumulative number of bytes in the batch to be sent. The number of nodes is the number of NodeRecord arrays in the batch to be sent, and the cumulative number of bytes is the sum of the buffer byte lengths of all NodeRecord arrays in the batch to be sent. When the number of nodes reaches the maximum number of nodes in a single batch Or the cumulative number of bytes reaches the maximum number of bytes in a single batch. At that time, the main thread constructs a batch request, which includes requestId, MatrixInverse, a half-length vector h, tolerance, QueryItem, and a NodeRecord array, where requestId is a unique identifier for the request, and MatrixInverse is the inverse matrix. tolerance is the tolerance for point inclusion. The main thread adds the buffers of all NodeRecord arrays in the batch to be sent that are in the transferred state to the transferList, which is a list of transferable ArrayBuffers; The main thread sends the batch requests and transferList to the Web Worker in batches via worker.postMessage(batchRequest, transferList). The ArrayBuffer in transferList transfers ownership from the main thread to the Web Worker through the Transferable mechanism, and the original buffer in the main thread is set to a detached state. After sending is complete, the main thread clears the current batch to be sent and resets the cumulative number of bytes to zero, and continues to execute the traversal operation in step two; The recommended range is 8 to 32, with an optimal value of 16; The recommended range is 4MB to 16MB, with 8MB being the preferred value.

[0024] In this embodiment, step five specifically includes: The Web Worker receives batch requests sent by the main thread, verifies whether the requestId in the batch request is consistent with the unique identifier of the request generated in step two, initializes a counting dictionary with queryKey as the key and the number of points as the value, and iterates through each NodeRecord array in the batch request. For each NodeRecord array, the Web Worker reads each point in steps of pointByteSize using DataView or TypedArray, where pointByteSize is the byte length of a single point in the NodeRecord array. For points stored using compressed coordinates, the Web Worker uses the coordinate scaling factor vector in the NodeRecord array. and the offset vector of the coordinate origin Restore world coordinates The restoration formula is: ; in, These are the quantized integer coordinates read from the buffer; If enableFrameFilter in QueryItem is enabled, the Web Worker reads the frame attribute value from the frameOffset position in the buffer and maps the current point to the corresponding target queryKey based on the frame attribute value. For nodes in the NodeRecord array where fullyInside is false, the Web Worker will assign the node's world coordinate vector... Transform to the bounding box local coordinate system using the following formula: ,in For local coordinates, This is the inverse matrix in the batch request; Web Worker based on half-length vector and tolerance To determine whether a point is located inside an OBB, the criteria are as follows: and and ,in For the point inclusion tolerance in batch requests, a recommended range is 10. -4 m to 10 -2 m, with a preferred value of 0.01m; If the point meets the internal judgment condition of OBB, the Web Worker will increment the count of the queryKey corresponding to the point in the counting dictionary.

[0025] In this embodiment, step six specifically includes: After completing the point-by-point statistics, the Web Worker returns a batch result to the main thread. This batch result includes requestId, counts, visitedNodes, testedPoints, elapsedMs, and returnedBuffers. Among them, requestId is a unique identifier for the request, counts is a counting dictionary with queryKey as the key and the corresponding number of points as the value, visitedNodes is the number of nodes actually processed by the Web Worker, testedPoints is the number of points actually detected by the Web Worker, elapsedMs is the processing time of the Web Worker, and returnedBuffers is a list of ArrayBuffers to be returned. If the ownership return strategy is adopted, the Web Worker will return the ArrayBuffer in transferList as a Transferable object to the main thread along with the batch results. After receiving the returned ArrayBuffer, the main thread will restore the cache status of the corresponding node from transferred to available. If AbortSignal triggers cancellation during processing, the Web Worker terminates the current statistical operation, and the cancellation control module decides whether to discard the processed results, re-acquire node data, or rebuild the node cache based on the timing of the cancellation.

[0026] In this embodiment, step seven specifically includes: The main thread receives batch results and extracts the counts from them as the Web Worker counting result. ,in A counting dictionary with queryKey as the key and the number of points counted by Web Worker as the value; The main thread will directly compare the counter with the Web Worker's counting result. Merge the results key by key according to queryKey to obtain the final number of points for each queryKey. The merging formula is: ; in, This represents the number of points directly incremented by the main thread in the direct counter. The number of final points corresponding to the queryKey; The main thread performs a consistency check before backfilling the results. This check includes: Compare the current requestId with the unique request identifier generated in step two to see if they are consistent; compare the current geometrySignature with the bounding box geometric signature generated in step two to see if they are consistent. If any of the above checks are inconsistent, the main thread will discard the batch of results and refuse to populate the UI with the old results. If all the above checks are consistent, the main thread will count the final points corresponding to each queryKey. Write the data layer of the annotation object and trigger the UI update operation to display the number of points corresponding to each queryKey on the annotation interface; When a user performs a drag-and-drop bounding box, switches frames, re-triggers statistics, or unloads a component on the browser side, the main thread generates an AbortSignal through the AbortController. This AbortSignal is then passed to the traversal process in step two and the Web Worker processing process in step six. The main thread locates the old request based on the requestId and pendingJobs mapping, stops the octree traversal in step two in the main thread, terminates or resets the Web Worker created in step four, and rejects the pending job corresponding to the old request. Among them, pendingJobs is a mapping table maintained by the main thread with requestId as the key and corresponding statistics request Promise as the value, which is used to manage the lifecycle of multiple concurrent statistics requests; pending job is a statistics request Promise instance that has not yet been completed corresponding to a certain requestId in the mapping table. If the old Web Worker has returned batch results before termination, the main thread determines that the results have expired by comparing the requestId or geometrySignature and performs a discard operation. Only the statistical results corresponding to the latest request can be populated back into the UI after passing the consistency check.

[0027] refer to Figure 4 A bounding box point count system for browser endpoint cloud annotation, including: The parameter receiving module is used to receive bounding box parameters from the 3D point cloud annotations on the browser and build a spatial classifier. The spatial classification module is used to traverse the spatial index nodes of the point cloud in the main thread of the browser and call the spatial classifier to classify the nodes as outside, inside or intersect. The batch encapsulation module is used to directly remove outside nodes, directly increment the number of inside nodes that meet the conditions to a direct counter, and read binary data of intersect nodes or nodes that need frame filtering and encapsulate them into NodeRecord arrays in batches. The batch sending module is used to send NodeRecord arrays in batches to Web Workers via Transferable ArrayBuffer; The point-by-point statistics module is used to accept batch data, perform coordinate decoding, frame attribute parsing and bounding box containment detection on each point of the NodeRecord array in the batch, and aggregate the number of points by queryKey; The result return module is used to return a counting dictionary with queryKey as the key and the number of points as the value to the main thread; The statistics merging module is used to merge the counting dictionary and the direct counter in the main thread to obtain the final number of points for each queryKey, and after consistency verification, the results are backfilled into the annotation object and the UI is updated.

[0028] Example 1: To verify the feasibility of the present invention in practice, the present invention was applied to a typical 3D point cloud annotation scenario. The number of points within the bounding box was counted in real time through the browser-based point cloud annotation system. The stability, accuracy and adaptability of the asynchronous counting method for the number of points within the bounding box proposed in this invention for browser-based 3D point cloud annotation were comprehensively tested.

[0029] In this embodiment, the annotation system uses a browser-based web application to load a road scene containing tens of millions of point clouds. This scene covers an eight-lane, two-way urban road, including various target objects such as motor vehicles, non-motor vehicles, pedestrians, traffic signs, streetlights, green belts, and buildings. The point cloud data is collected via vehicle-mounted LiDAR, with approximately 12 million point clouds per frame. The octree has eight levels, and each leaf node contains an average of 3200 points. The annotator draws a 3D bounding box around a car in the browser. The car is located in the center lane of the road, oriented east-west, with its front facing east. The annotator generates the bounding box by dragging and dropping with the mouse. The bounding box's center position is (45.2, 12.8, 0.6), in meters, with dimensions of 4.5 meters long, 1.8 meters wide, and 1.5 meters high. The rotation angles are 15 degrees yaw, 2 degrees pitch, and 0 degrees roll. The system needs to display the number of points within the bounding box in real time to determine if the annotation box is empty or offset.

[0030] After receiving the aforementioned box3D parameters, the system constructs an OBB classifier and inverse transform matrix. The system generates a QueryItem containing only the current frame, where the queryKey is set to "frame_001_car_01", frameIndex is 0, enableFrameFilter is false, and geometrySignature is generated by hashing the center position, size, and rotation parameters. The main thread creates a statistics context with requestId "req_20240624_001", initializes the direct counter to 0, creates an empty array of batches to be sent, and sets... It is 16. The size is 8MB, and the yield node threshold is 1000.

[0031] The main thread performs a depth-first traversal starting from the root node of the octree. The root node covers the entire scene, and its AABB overlaps with the world AABB of the target OBB, thus entering the second-level judgment. After transformation, the corner points of the root node no longer satisfy the condition that they are all inside the OBB, and are classified as intersects, continuing to traverse its child nodes. The first level has 8 child nodes, of which 3 nodes have AABBs that do not overlap with the world AABB of the target OBB, are classified as outside and directly eliminated, and the remaining 5 nodes enter the second-level judgment. Among these 5 nodes, 1 node is determined to be completely inside the OBB after corner point transformation, and is classified as inside. This node contains 28,000 points, and the main thread directly increments it to the direct counter, updating the direct counter to 28,000, and simultaneously passes this inside state to its child nodes, which do not need to perform further classification judgment. The remaining 4 nodes are classified as intersects, and the main thread reads the binary data of these 4 nodes, constructs a NodeRecord array, and adds it to the batch to be sent.

[0032] During continued traversal, the main thread encountered two more inside nodes, containing 15,600 and 8,900 points respectively, immediately incrementing the counter to 52,500. Simultaneously, it encountered 12 intersect nodes, adding their NodeRecord arrays to the batch to be sent. When the number of nodes in the batch to be sent reached 16, the cumulative bytes were 6.2MB, which was less than the target. However, it has already reached The main thread constructs a batch request and sends the ArrayBuffer of 16 NodeRecord arrays to the Web Worker through the Transferable mechanism. The original buffer of the main thread is set to a detached state, and the traversal continues after the batch is cleared.

[0033] During subsequent traversal, the main thread encountered another inside node with 4200 points, and the counter was immediately updated to 56700. Five intersect nodes were encountered and added to the batch to be sent. When the cumulative number of bytes reached 8.1MB, it exceeded... The main thread then sends another batch of requests to the Web Worker. Finally, two intersect nodes remain. After adding them to the batch, the total number of nodes is 2, and the total number of bytes is 3.1MB, both below the threshold. After completing the octree traversal, the main thread sends these two nodes as the final batch to the Web Worker.

[0034] After receiving three batches of requests, the Web Worker initializes its counting dictionary to 0 for each batch. For the first batch of 16 intersect nodes, the Web Worker reads each node one by one, with each node containing an average of 3100 points, for a total of 49600 points. After coordinate decoding and OBB inclusion detection, the first batch's count shows 12350 points corresponding to the query key "frame_001_car_01". The second batch of 5 intersect nodes has a total of 15500 points detected, with a count of 4120 points. The third batch of 2 intersect nodes has a total of 5800 points detected, with a count of 1680 points. The total count for all three batches of Web Worker requests is 18150 points.

[0035] The main thread merges the direct counter and the counting dictionary to determine the final count. =56700 + 18150 = 74850 points. The main thread verifies that both requestId and geometrySignature are consistent with those initiated during the statistics process, and then populates the UI with 74850 points. The annotation interface displays in real time that the car body box contains 74850 points. The system's preset threshold for empty frames is 500 points; this result is far higher than the threshold, therefore it is judged as a non-empty frame, and the annotation quality is qualified.

[0036] To compare and verify the effectiveness of this invention, the same bounding box was statistically analyzed using a full-scale point-by-point detection scheme with the main thread. The main thread traversed all octree nodes, visiting a total of 156 nodes, including 43 outside nodes, 4 inside nodes, and 109 intersect nodes. The main thread detected each of the 109 intersect nodes, totaling 352,800 detection points, in 1260 milliseconds. During this time, the UI frame rate dropped to 12fps, resulting in noticeable stuttering, and mouse dragging and camera rotation became unresponsive. In contrast, using the scheme of this invention, the main thread only batch-encapsulated and sent 23 intersect nodes, with a total of 70,900 detection points by the Web Worker. The main thread traversal took 89 milliseconds, and the Web Worker processing took 156 milliseconds, for a total processing time of 245 milliseconds. The UI frame rate remained at 58fps, with no stuttering observed. The scheme of this invention is approximately 5.1 times more efficient than the full-scale point-by-point detection scheme with the main thread.

[0037] To test the multi-frame statistical effect, the annotator tracked and annotated the same car in a road scene for 10 consecutive frames, with the car's position changing with the driving trajectory in each frame. The system generated 10 QueryItems for the 10 frames, with query keys from "frame_001_car_01" to "frame_010_car_01" and frameIndex from 0 to 9. The main thread traversed the octree only once, counting each frame separately. In the 10 frames, the total number of directly counted inside nodes was 489,200, the total number of points detected by Web Worker in intersect nodes was 142,800, and the total number of points in the 10 frames was 632,000. If a frame-by-frame independent statistical scheme were used, the octree would need to be traversed 10 times, with a total time of approximately 2450 milliseconds; using the scheme of this invention, a single traversal plus batch processing by Web Worker reduces the total time to approximately 380 milliseconds, improving efficiency by approximately 6.4 times.

[0038] To test the effect of request cancellation, the annotator continuously dragged and adjusted the bounding box position, triggering 15 statistical requests within 3 seconds. The system manages these requests via AbortController and requestId; the first 14 requests were cancelled, with only the 15th request completing and updating the results. Throughout this process, the UI consistently displayed the number of points corresponding to the latest bounding box state, without any flickering or overwriting of old results. If a no-cancellation mechanism were used, all 15 requests would have completed, with 14 of them being invalid calculations, taking approximately 3675 milliseconds in total. Furthermore, the repeated updating of old results caused the UI point count to jump 6 times.

[0039] To test the effectiveness of buffer ownership management, node binary data was simultaneously used for point cloud rendering caching. A Transferable ArrayBuffer transfer scheme was employed. After the main thread sent 16 node buffers, the original buffers were set to detached. The rendering cache module detected the state change, retrieved independent ArrayBuffers from the data source for rendering, and after statistics were completed, the Worker returned the buffers, and the main thread restored the cache state. Throughout the process, rendering was uninterrupted, and point cloud display remained continuous. If a structured cloning scheme were used, copying 16 node buffers would generate a peak memory usage of approximately 198MB, triggering GC three times, and causing significant fluctuations in the rendering frame rate. Using the Transferable scheme of this invention, the peak memory usage was approximately 62MB, no GC was triggered, and the rendering frame rate remained stable.

[0040] Table 1. Comparison of node classification and statistical performance under different bounding box sizes. As shown in Table 1, with the increase in bounding box size, the proportion of inside nodes increases significantly, while the proportion of outside nodes decreases, and the proportion of intersect nodes remains between 63% and 76%. For small bounding boxes such as Test-010, the proportion of outside nodes is as high as 88.5%. The spatial classification mechanism of this invention can effectively remove a large number of irrelevant nodes, with a total time of only 62 milliseconds. For large bounding boxes such as Test-006, the proportion of inside nodes reaches 33.3%. The direct counting mechanism avoids the point-by-point detection of these nodes, with a total time of 425 milliseconds, which is 37.5% lower than the estimated time of 680 milliseconds for the direct counting scheme without a main thread.

[0041] Table 2 Performance Comparison of Main Thread Full Detection and the Scheme of this Invention Table 2 clearly demonstrates the significant advantages of the present invention in various metrics. Main thread blocking time is reduced from 1260 milliseconds to 89 milliseconds, a reduction of 93%, ensuring smooth UI interaction. Peak memory usage is reduced by 68.7%, GC is completely avoided, and system stability is greatly improved. The total number of detection points is reduced by 80%, significantly reducing the proportion of invalid calculations.

[0042] Table 3. Comparison of Statistical Efficiency Across Multiple Frames Table 3 shows that the relative advantages of the present invention become increasingly apparent as the number of statistical frames increases. The mechanism of single traversal and multi-frame aggregation improves the statistical efficiency of 50 frames by 7.3 times compared to independent frame-by-frame statistics, fully verifying the high efficiency of the present invention in multi-frame scenarios.

[0043] Table 4 Comparison of Cancel Request Effects in Continuous Drag-and-Drop Scenarios Table 4 verifies the effectiveness of the request-level cancellation mechanism. Regardless of the number of requests triggered, this invention only retains the last valid request, and the number of UI points always remains consistent with the current bounding box state without any fluctuations. Without a cancellation mechanism, the proportion of invalid calculations increases with the number of triggers, and the UI fluctuates frequently, severely impacting the annotation experience.

[0044] Based on the above test data, this invention demonstrates excellent stability, accuracy, and efficiency in various scenarios, including single-frame statistics, multi-frame statistics, and continuous interaction, fully meeting the real-time point count requirements of browser-based 3D point cloud annotation services.

[0045] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A method for counting the number of points within a bounding box in browser endpoint cloud annotation, characterized in that, Includes the following steps: Step 1: Receive bounding box parameters from the 3D point cloud annotations on the browser and construct a spatial classifier; Step 2: In the browser's main thread, traverse the point cloud spatial index nodes and call the spatial classifier to classify the nodes as outside, inside, or intersect; Step 3: Remove outside nodes directly, increment the number of inside nodes that meet the conditions to the direct counter, and read binary data for intersect nodes or nodes that need frame filtering and encapsulate them into NodeRecord arrays in batches. Step 4: Send the NodeRecord array in batches to the Web Worker via Transferable ArrayBuffer; Step 5: Receive batch data, perform coordinate decoding, frame attribute parsing, and bounding box containment detection point by point for each NodeRecord array in the batch, and aggregate the number of points by queryKey; Step 6: Return the counting dictionary with queryKey as the key and the number of points as the value to the main thread; Step 7: In the main thread, merge the counting dictionary and the direct counter to obtain the final number of points for each queryKey, and after consistency verification, fill the result back into the annotation object and update the UI.

2. The method for counting the number of points within a bounding box for browser endpoint cloud annotation according to claim 1, characterized in that, Step two specifically includes: One or more QueryItems are generated based on the business scenario. Each QueryItem includes queryKey, frameIndex, enableFrameFilter, and geometrySignature. The queryKey is a unique identifier for statistical result aggregation and backfilling, the frameIndex is the target frame index, the enableFrameFilter is an identifier for whether frame attribute filtering is enabled, and the geometrySignature is the bounding box geometry signature when the request is initiated. In the browser, the main thread creates a statistics context, including requestId, AbortSignal, traversal stack, direct counter, batch to be sent, number of visited nodes, number of detected points, and performance monitoring metrics. Among them, requestId is a unique identifier for the request, AbortSignal is the cancellation signal, the traversal stack is used to store the octree nodes to be traversed, and the direct counter is used to store the number of points directly accumulated by the main thread. The main thread performs a depth-first or breadth-first traversal starting from the root node of the octree, and for each node... Get the node's bounding box. Call the OBB / AABB spatial classifier to perform spatial classification on the node: If node node bounding box If the node does not intersect with the target OBB, then classify the node as outside and skip the node and all its child nodes; If node node bounding box If the entire node is located inside the target OBB, then the node is classified as inside, and the fullyInside state is passed to all child nodes of that node. If node node bounding box If a node intersects with the target OBB portion, it is classified as an intersect and enters the candidate batch for point-by-point detection. During the traversal, the main thread periodically executes the yield operation based on the node count threshold or time consumption threshold, returning control to the browser event loop to avoid prolonged occupation of the main thread and causing UI lag.

3. The method for counting the number of points within a bounding box for browser endpoint cloud annotation according to claim 1, characterized in that, Step three specifically includes: For nodes classified as outside, the main thread directly removes the node without performing any counting or data transfer operations; For nodes categorized as inside, the main thread determines whether the node meets the direct counting condition. The direct counting condition is that the enableFrameFilter of all query items is disabled, and the node's point count metadata is reliable. If the direct counting condition is met, the main thread will directly add the number of points of that node to the direct counters corresponding to all queryKeys. If the direct counting condition is not met, the main thread will treat the node as a candidate node and proceed to the subsequent processing flow. For nodes classified as intersect, and inside nodes that do not meet the direct counting conditions, the main thread reads the binary point cloud data and attribute layout metadata of the node, constructs a NodeRecord array through all node records, and adds the NodeRecord array to the batch to be sent.

4. The method for counting the number of points within a bounding box for browser endpoint cloud annotation according to claim 1, characterized in that, Step four specifically includes: When the number of nodes in the batch to be sent reaches or the cumulative number of bytes reaches When the main thread calls the WebWorker's message sending method, it passes in the batch request and the list transferList as parameters. The ArrayBuffer in transferList transfers ownership from the main thread to the WebWorker through the Transferable mechanism, and the original buffer of the main thread is set to the detached state. The main thread adds the buffers of all NodeRecord arrays in the batch to be sent that are in the transferred state to the transferList, which is a list of transferable ArrayBuffers; After sending is complete, the main thread clears the current batch to be sent and resets the cumulative number of bytes to zero, and continues to execute the traversal operation in step two; The maximum number of nodes in a single batch is recommended to be between 8 and 32, with an optimal value of 16. The maximum number of bytes per batch is recommended to be between 4MB and 16MB, with 8MB being the preferred value.

5. The method for counting the number of points within a bounding box for browser endpoint cloud annotation according to claim 1, characterized in that, Step five specifically includes: The Web Worker receives batch requests sent by the main thread, verifies the requestId, initializes the counting dictionary, and iterates through each NodeRecord array in the batch. For each NodeRecord array, the Web Worker reads each point in steps of pointByteSize using DataView or TypedArray. For compressed coordinates, world coordinates are restored based on the coordinate scaling factor and origin offset. If frame filtering is enabled, the frame attribute value is read from the frame attribute offset position and mapped to the target queryKey; For non-fullyInside nodes, the Web Worker transforms the point's world coordinates to the bounding box local coordinate system and determines whether the point is inside the OBB based on the half-length vector and tolerance. If the point meets the internal judgment condition of OBB, the Web Worker will increment the count of the queryKey corresponding to that point.

6. The method for counting the number of points within a bounding box for browser endpoint cloud annotation according to claim 1, characterized in that, Step six specifically includes: After completing the point-by-point statistics, the Web Worker returns the batch results to the main thread and returns the count dictionary by queryKey; If the ownership return strategy is adopted, the batch results will carry the ArrayBuffer that needs to be returned; After the Web Worker finishes processing, the buffer will be returned as a Transferable object along with the batch results. The main thread receives the returned buffer and restores the node cache state to available; If AbortSignal triggers cancellation during processing, the Web Worker terminates the current statistical operation, and the cancellation control module decides whether to discard the processed results, re-acquire node data, or rebuild the node cache based on the timing of the cancellation.

7. The method for counting the number of points within a bounding box for browser endpoint cloud annotation according to claim 1, characterized in that, Step seven specifically includes: The main thread receives the batch results, merges them with the direct counter, and obtains the final number of points for each queryKey; Before backfilling, check whether the current requestId and geometrySignature are still consistent with those when the statistics were initiated; if either of the above checks is inconsistent, the main thread discards the batch of results and refuses to backfill the old results to the UI. If all the above checks are consistent, the main thread will count the final points corresponding to each queryKey. Write the data layer of the annotation object and trigger the UI update operation to display the number of points corresponding to each queryKey on the annotation interface.

8. A system for counting the number of points within a bounding box for browser endpoint cloud annotation, comprising executing the method for counting the number of points within a bounding box for browser endpoint cloud annotation as described in any one of claims 1 to 7, characterized in that, include: The parameter receiving module is used to receive bounding box parameters from the 3D point cloud annotations on the browser and build a spatial classifier. The spatial classification module is used to traverse the spatial index nodes of the point cloud in the main thread of the browser and call the spatial classifier to classify the nodes as outside, inside or intersect. The batch encapsulation module is used to directly remove outside nodes, directly increment the number of inside nodes that meet the conditions to a direct counter, and read binary data of intersect nodes or nodes that need frame filtering and encapsulate them into NodeRecord arrays in batches. The batch sending module is used to send NodeRecord arrays in batches to Web Workers via Transferable ArrayBuffer; The point-by-point statistics module is used to accept batch data, perform coordinate decoding, frame attribute parsing and bounding box containment detection on each point of the NodeRecord array in the batch, and aggregate the number of points by queryKey; The result return module is used to return a counting dictionary with queryKey as the key and the number of points as the value to the main thread; The statistics merging module is used to merge the counting dictionary and the direct counter in the main thread to obtain the final number of points for each queryKey, and after consistency verification, the results are backfilled into the annotation object and the UI is updated.