Skip to content

Fix: Make second parameter of Mat.ucharPtr optional#83

Merged
ttt43ttt merged 2 commits intomainfrom
copilot/fix-82
Sep 5, 2025
Merged

Fix: Make second parameter of Mat.ucharPtr optional#83
ttt43ttt merged 2 commits intomainfrom
copilot/fix-82

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jul 30, 2025

The Mat.ucharPtr method's second parameter j should be optional to support getting row data by passing only the row index, as indicated in the TypeScript method signature and OpenCV documentation.

Problem:
The current type definition required both parameters:

public ucharPtr(i: any, j: any): any;

This prevented developers from calling ucharPtr with just a row index to get a pointer to the entire row, which is a valid and commonly used pattern in OpenCV.

Solution:
Made the second parameter optional:

public ucharPtr(i: any, j?: any): any;

Usage:

const mat = new cv.Mat(3, 3, cv.CV_8UC1);

// Get pointer to entire row (now works)
const rowPtr = mat.ucharPtr(0);

// Get pointer to specific element (still works)
const elementPtr = mat.ucharPtr(0, 0);

This change makes the TypeScript definitions consistent with the actual OpenCV.js implementation and allows the more flexible usage pattern that developers expect.

Fixes #82.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: ttt43ttt <132509+ttt43ttt@users.noreply.github.com>
Copilot AI changed the title [WIP] 2nd parameter for Mat.ucharPtr should be optional Fix: Make second parameter of Mat.ucharPtr optional Jul 30, 2025
Copilot AI requested a review from ttt43ttt July 30, 2025 13:29
@ttt43ttt ttt43ttt marked this pull request as ready for review September 5, 2025 02:29
@ttt43ttt ttt43ttt merged commit c69c389 into main Sep 5, 2025
1 check passed
@ttt43ttt ttt43ttt deleted the copilot/fix-82 branch September 5, 2025 02:30
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.

2nd parameter for Mat.ucharPtr should be optional

2 participants