Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 9, 2025

TypeScript types incorrectly advertised a divide(scale, src2, dst, dtype?) overload that doesn't exist in the OpenCV.js WASM binary, causing runtime failures:

// TypeScript accepted this, but failed at runtime with "Cannot pass number as a Mat"
cv.divide(1 / srcStd, sourceNormalized, sourceNormalized);

Changes

  • Removed non-existent divide(scale: double, src2: InputArray, dst: OutputArray, dtype?: int) overload from core_array.ts
  • Added documentation note explaining C++ OpenCV vs OpenCV.js differences and workaround pattern
  • Added test suite validating correct usage and TypeScript type checking

Workaround

// Use Mat.ones with scale parameter for scalar division
const ones = cv.Mat.ones(3, 3, cv.CV_32F);
cv.divide(ones, sourceNormalized, dst, 1 / srcStd);

TypeScript now correctly rejects scalar-first parameter at compile time: Argument of type 'number' is not assignable to parameter of type 'Mat'

Original prompt

This section details on the original issue you should resolve

<issue_title>cv.divide overloading doesn't work</issue_title>
<issue_description>image
image
</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 9, 2025 13:45
…rload

Co-authored-by: ttt43ttt <132509+ttt43ttt@users.noreply.github.com>
Co-authored-by: ttt43ttt <132509+ttt43ttt@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix cv.divide overloading issues Remove unsupported scalar-by-array overload from cv.divide type definition Nov 9, 2025
Copilot AI requested a review from ttt43ttt November 9, 2025 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cv.divide overloading doesn't work

2 participants