-
Notifications
You must be signed in to change notification settings - Fork 1
Improves Homography code and implement drawCorners method #15
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
Conversation
|
with the testing class WebARKItCOreCV2 i'am on the right path, at least we have a debug image in the |
|
The simple example example.html will not works because the imageData is not continuosly updated, until i will not improve that it worth to focus on other aspects. |
|
with the commit 48bdfd6 the example_image example doesn't works, I need to understand what bug was introduced... |
- some small improves - it can detect and track (image example)
- make AbstractWebARKitCVWorker constructor protected - a bunch of readonly properties
|
the image_example can detect the face pattern and we can see the descriptors and the three red, green, blu line onto the image, we get at the end this error: but i think can be easily solved. |
|
The problem with the webcam example is that in the track method: webarkit-cv/src/core/WebARKitCoreCV2.ts Lines 78 to 90 in b943eea
we are providing wrong width and height params (in this case 1280 720) but imagedata is filled witha canvas with 320 and 240 height... we should provide these values in the builder with setWidth and setHeight methods webarkit-cv/examples/example.html Lines 42 to 45 in b943eea
i should move this block inside the camera initialization webarkit-cv/examples/example.html Line 49 in b943eea
|
- Add drawCorners method to draw polygon and corner markers on processing canvas - Add tests/CameraViewRenderer.test.js to validate drawing calls using mocked context Small, defensive change that doesn't affect existing behaviour. Tests pass.
- Added logging of camera view initialization for debugging purposes. - Improved ImageData construction by dynamically handling width and height based on incoming message data, with fallbacks for mismatched buffer lengths. - Implemented robust error handling in optical flow calculations to prevent crashes and ensure graceful degradation in tracking performance. - Introduced a new method `drawCorners` in CameraViewRenderer to visualize detected corners on the processing canvas.
Updated the message sent to the worker to include the actual width and height of the ImageData. This ensures that the worker can reconstruct the ImageData accurately as produced by the renderer, improving processing accuracy.
- Improved logging for 'getMatrix' and 'lostMarker' events in example HTML files to provide clearer context. - Added corner drawing functionality in the overlay for better visual feedback when corners are detected. - Implemented buffer size validation in WebARKitCVWorkers to catch mismatches early, preventing potential errors in processing. - Enforced strict validation of ImageData buffer lengths in WebARKitCoreCV2, eliminating silent failures and improving debugging.
…me rate control - Added methods to set image size preservation and target frame rate in CameraViewRenderer. - Updated example.html to utilize new camera settings for improved performance. - Enhanced Worker.ts to handle marker results more robustly. - Improved image data handling in WebARKitCoreCV2.ts for better memory management. - Added tests for CameraViewRenderer to ensure correct behavior with image size preservation.
…tions - Deleted the implementation of WebARKitCoreCV from WebARKitCoreCV.ts. - Updated the type definitions in WebARKitCoreCV.d.ts to reflect the removal of the implementation. - Adjusted the visibility of class properties and methods in the type definitions for clarity.
- Added stopTracking method in WebARKitCV class to cancel ongoing animation frames. - Updated startTracking method to call stopTracking before initiating tracking. - Modified example_image.html to call webarkit.stopTracking() after drawing the overlay. - Updated TypeScript definitions to include the new stopTracking method.
- Updated devDependencies in package.json to latest versions. - Added ESM tests for Trackable, Tracker, and WebARKitCVBuilder classes. - Created tsconfig.jest.esm.json for ESM compatibility in Jest tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request enhances the WebARKitCV library by improving homography computation, adding corner visualization capabilities, and updating project dependencies. The changes primarily focus on refactoring the core computer vision logic to use a more modern approach with optical flow tracking, implementing methods to draw detected corners, and upgrading various development dependencies.
Key changes:
- Refactored
WebARKitCoreCVto use optical flow tracking with solvePnP for improved pose estimation - Added
drawCornersmethod toCameraViewRendererfor visualizing detected marker corners - Updated development dependencies including TypeScript, Babel, Jest, and build tools to newer versions
Reviewed Changes
Copilot reviewed 20 out of 53 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/core/WebARKitCoreCV.ts |
Major refactoring to implement optical flow tracking, keypoint matching, and projection matrix computation |
src/io/CameraViewRenderer.ts |
Added corner drawing functionality and improved image caching mechanism |
src/Workers/WebARKitCVWorkers.ts |
Enhanced worker message handling to include corners and processed image data |
src/Workers/Worker.ts |
Updated message processing logic and improved error handling |
src/WebARKitCV.ts |
Added tracking lifecycle management with stopTracking method |
package.json |
Updated multiple dependencies to latest versions |
examples/example.html |
Implemented overlay canvas for visualizing tracking results |
examples/example_image.html |
Added corner drawing and overlay visualization functions |
tests/CameraViewRenderer.test.js |
Added tests for drawCorners method |
tests-esm/*.ts |
Added ESM-specific tests for builder, tracker, and trackable classes |
jest.esm.config.cjs |
New Jest configuration for ESM testing |
tsconfig.jest.esm.json |
New TypeScript configuration for ESM tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Added validation for the received tracking data ID to ensure it corresponds to an existing memory entry. - Implemented a warning log when tracking data is received for an ID without a corresponding memory entry. - Updated the call to estimateCameraPosition to use the validated ID instead of a hardcoded value.
…/webarkit-cv into feat-improves-homography
- Changed imageDataCache type from ImageData to Uint8ClampedArray for improved performance. - Introduced cachedImageData to hold ImageData instances for rendering. - Updated logic to invalidate caches when processing dimensions change. - Modified updateImageCache method to handle new caching strategy. - Adjusted getCachedImage method to return cachedImageData correctly.
This pull request introduces several significant improvements and updates across the codebase, focusing on enhanced example usage, improved robustness in tracking, developer experience upgrades, and modernization of the build environment. The main changes include new and improved example HTML/CSS for demos, better error handling and validation in the tracking logic, and updates to dependencies and CI workflows to use more recent Node.js and Ubuntu versions.
Thus this PR try to implement the 2 point of issue #8.
Example and Demo Improvements:
nft-style.css) and updated example HTML files to provide a more modern, visually appealing, and functional demo experience, including overlay canvases for drawing tracking results and improved event handling for detected markers. [1] [2] [3] [4]Robustness and Error Handling in Tracking:
WebARKitCVclass to validate image data before processing, skip invalid trackables, and provide astopTrackingmethod to cleanly cancel animation frames. [1] [2] [3] [4]WebARKitCVOrbWorkerto validateImageDatabuffer sizes before posting to the worker, improving debugging and preventing subtle errors. Also updated the worker's message handling for better state management. [1] [2] [3] [4] [5]Developer Experience and Testing:
uuidmodule and introduced a new Jest ESM configuration for improved and more flexible testing. [1] [2]Build and Dependency Updates:
uuid, TypeScript, Jest, Babel, Webpack, and others. [1] [2]CI and Workflow Modernization:
Final note
Even it's not completely implemented the features of the main title, now the two examples can detect and track the images provided.