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_0

ComfyUI Node: OpenCV batchDistance_0

Class Name

batchDistance_0

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_0 Description

Computes vector distances using OpenCV's `batchDistance` for image processing and computer vision.

OpenCV batchDistance_0:

The batchDistance_0 node is designed to compute the distance between two sets of vectors using OpenCV's 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 leveraging this node, you can efficiently calculate distances in a batch mode, which is beneficial for handling large datasets or performing operations that require comparing multiple vectors simultaneously. The node supports various distance metrics and normalization types, allowing you to customize the distance computation according to your specific needs. This flexibility makes it a valuable tool for tasks such as object recognition, clustering, and image matching.

OpenCV batchDistance_0 Input Parameters:

src1

src1 is the first input array of vectors for which you want to compute the distance. It is expected to be a NumPy array (NPARRAY). This parameter represents the set of vectors that will be compared against the vectors in src2.

src2

src2 is the second input array of vectors to be compared with src1. Like src1, it should be a NumPy array (NPARRAY). This parameter contains the vectors that will be used as the reference set for distance computation.

dtype

dtype specifies the data type of the output distance matrix. It is an integer (INT) that determines how the computed distances will be stored. The choice of data type can affect the precision and memory usage of the output.

normType

normType defines the type of norm to be used for distance computation. It is an integer (INT) that specifies the metric for measuring the distance between vectors. Different norm types can be used depending on the desired distance metric, such as L1, L2, etc.

K

K is an integer (INT) that indicates the number of nearest neighbors to find. This parameter is crucial when you are interested in finding the closest vectors in src2 for each vector in src1.

update

update is an integer (INT) that determines whether the distance matrix should be updated. This parameter is useful when you want to incrementally update the distance computation without recalculating everything from scratch.

crosscheck

crosscheck is a boolean (BOOLEAN) that specifies whether to perform a cross-check during the distance computation. Enabling cross-check ensures that the nearest neighbor relationship is mutual, which can improve the robustness of the results.

dist

dist is an optional parameter that allows you to provide a pre-allocated NumPy array (NPARRAY) for storing the computed distances. If not provided, a new array will be created.

nidx

nidx is an optional parameter that can be used to store the indices of the nearest neighbors. It is a NumPy array (NPARRAY) that, if provided, will be filled with the indices of the closest vectors in src2 for each vector in src1.

mask

mask is an optional parameter that allows you to specify a mask as a NumPy array (NPARRAY). This mask can be used to ignore certain elements during the distance computation, providing more control over which vectors are considered.

OpenCV batchDistance_0 Output Parameters:

nparray_0

nparray_0 is the output NumPy array containing the computed distances between the vectors in src1 and src2. This array provides the actual distance values, which can be used for further analysis or processing.

nparray_1

nparray_1 is the output NumPy array containing the indices of the nearest neighbors. This array helps identify which vectors in src2 are closest to each vector in src1, based on the computed distances.

OpenCV batchDistance_0 Usage Tips:

  • Ensure that src1 and src2 are properly formatted as NumPy arrays with compatible dimensions to avoid errors during execution.
  • Experiment with different normType values to find the most suitable distance metric for your specific application, as this can significantly impact the results.
  • Use the crosscheck option to enhance the reliability of nearest neighbor searches, especially in applications where mutual nearest neighbors are important.

OpenCV batchDistance_0 Common Errors and Solutions:

Mismatched Array Dimensions

  • Explanation: This error occurs when the dimensions of src1 and src2 are not compatible for distance computation.
  • Solution: Ensure that both src1 and src2 have the same number of columns, representing the dimensionality of the vectors.

Invalid Norm Type

  • Explanation: An invalid normType value can lead to errors if it does not correspond to a supported distance metric.
  • Solution: Verify that the normType value is valid and corresponds to a supported norm type in OpenCV, such as L1 or L2.

Memory Allocation Error

  • Explanation: This error can occur if the system runs out of memory while trying to allocate space for the output arrays.
  • Solution: Consider reducing the size of src1 and src2 or using a machine with more memory to handle larger datasets.

OpenCV batchDistance_0 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_0