Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot 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.

@Copilot 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 Copilot AI requested a review from ttt43ttt July 30, 2025 13:29
Copilot finished work on behalf of ttt43ttt July 30, 2025 13:29
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