Save 4 hours! We auto-setup your workflow! Free!

Drop your workflow.json — we handle every dependency, custom node, and model. Just open the link and run.

Auto-Setup Workflow Json (Free) Now!
ComfyUI > Nodes > opencv-comfyui > OpenCV batchDistance_1

ComfyUI Node: OpenCV batchDistance_1

Class Name

batchDistance_1

Category
image/OpenCV
Author
geroldmeisinger (Account age: 1432days)
Extension
opencv-comfyui
Latest Updated
2026-07-22
Github Stars
0.04K

How to Install opencv-comfyui

Install this extension via the ComfyUI Manager by searching for opencv-comfyui
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter opencv-comfyui in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

OpenCV batchDistance_1 Description

Computes vector distances using OpenCV for efficient image processing and computer vision tasks.

OpenCV batchDistance_1:

The batchDistance_1 node is designed to compute the distance between two sets of vectors, leveraging the OpenCV batchDistance function. This node is particularly useful in image processing and computer vision tasks where you need to measure the similarity or dissimilarity between feature vectors. By efficiently calculating distances in batches, it optimizes performance and can handle large datasets, making it ideal for applications such as object recognition, clustering, and image matching. The node supports various distance metrics and configurations, allowing you to tailor the computation to your specific needs, whether you are comparing images, detecting patterns, or analyzing data distributions.

OpenCV batchDistance_1 Input Parameters:

src1

src1 is the first input array of vectors, represented as an NPARRAY. This parameter is crucial as it contains the set of vectors against which the distances will be calculated. The quality and structure of this data directly impact the accuracy and relevance of the distance computation.

src2

src2 is the second input array of vectors, also an NPARRAY. It serves as the comparison set for src1. The node computes the distance between each vector in src1 and src2, making this parameter essential for defining the scope of the comparison.

dtype

dtype is an integer parameter that specifies the data type of the output distance matrix. It ensures that the results are stored in a format that is compatible with subsequent processing steps, affecting both precision and memory usage.

normType

normType is an integer that determines the type of norm used for distance calculation. This parameter allows you to choose the metric that best suits your application, such as L1, L2, or other norms, influencing the interpretation of distance.

K

K is an integer that specifies the number of nearest neighbors to find. This parameter is particularly useful in tasks like k-nearest neighbors (k-NN) classification, where you need to identify the closest vectors in src2 for each vector in src1.

update

update is an integer flag that indicates whether to update the distance matrix. This parameter controls whether the node should modify the existing distance data, which can be useful in iterative processes or when refining results.

crosscheck

crosscheck is a boolean parameter that, when set to true, ensures that the nearest neighbor relationship is mutual. This option is valuable for applications requiring bidirectional consistency, such as feature matching in stereo vision.

dist

dist is an optional NPARRAY that can be provided to store the computed distances. If specified, this parameter allows you to reuse an existing array, optimizing memory usage and potentially speeding up the computation.

nidx

nidx is an optional NPARRAY that holds the indices of the nearest neighbors. This parameter is useful for retrieving the positions of the closest vectors, facilitating further analysis or processing.

mask

mask is an optional NPARRAY that acts as a mask for the input vectors. It allows you to selectively include or exclude certain vectors from the distance computation, providing flexibility in handling incomplete or noisy data.

OpenCV batchDistance_1 Output Parameters:

nparray_0

nparray_0 is an NPARRAY that contains the computed distances between the vectors in src1 and src2. This output is crucial for understanding the similarity or dissimilarity between the input sets, serving as a foundation for further analysis or decision-making.

nparray_1

nparray_1 is an NPARRAY that holds the indices of the nearest neighbors found during the computation. This output is essential for identifying which vectors in src2 are closest to those in src1, enabling tasks like clustering or nearest neighbor search.

OpenCV batchDistance_1 Usage Tips:

  • Ensure that src1 and src2 are properly preprocessed and normalized to improve the accuracy of the distance computation.
  • Experiment with different normType values to find the most suitable distance metric for your specific application, as this can significantly affect the results.
  • Utilize the mask parameter to exclude irrelevant or noisy data from the computation, enhancing the quality of the output.

OpenCV batchDistance_1 Common Errors and Solutions:

Mismatched Array Dimensions

  • Explanation: This error occurs when the dimensions of src1 and src2 do not match, preventing the node from computing distances.
  • Solution: Verify that both input arrays have compatible dimensions and reshape them if necessary to ensure they align correctly.

Invalid Norm Type

  • Explanation: An unsupported normType value can lead to this error, as the node cannot perform the distance calculation with an invalid metric.
  • Solution: Check the documentation for valid normType values and ensure you are using one that is supported by the node.

Memory Overflow

  • Explanation: Large input arrays or high K values can cause memory overflow, leading to computation failure.
  • Solution: Reduce the size of the input arrays or the value of K, or consider processing the data in smaller batches to manage memory usage effectively.

OpenCV batchDistance_1 Related Nodes

Go back to the extension to check out more related nodes.
opencv-comfyui
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.

OpenCV batchDistance_1