Skip to content
This repository was archived by the owner on Oct 26, 2026. It is now read-only.

Add OpenCV ops - #123

Merged
hinerm merged 42 commits into
mainfrom
opencv-ops
Mar 6, 2024
Merged

hinerm merged 42 commits into
mainfrom
opencv-ops

Conversation

@hinerm

@hinerm hinerm commented Feb 7, 2024 •

Copy link
Copy Markdown
Member

Hooray it's an external library wrapped into Ops with no code.

Closes scijava/scijava#158

Questions/notes:

  • Currently I'm doing nothing with priority of the wrapped ops. Thoughts?
  • Missing out on the parameter names/documentation 😞
  • My Computer heuristic is stupid and tailored to OpenCV. I saw it as something we could expand support for as needed, but wanted to mention it.
  • Are there other methods in OpenCV you'd like to see wrapped?
  • Any suggestions for changes to the aliases I picked? I expect I missed existing Ops when I was naming some of the wrappers.
  • Deciding what to wrap was overwhelming. I ended up only using a curated "white" list in the YAML. Wrapping everything, even with a block list, makes me nervous about getting tons of junk. Also any auto-wrapped ops won't have "Ops-style" aliases. So as I was assessing what I did want to wrap and what their aliases should be, it felt unnecessary to also be documenting a "block" list. So I didn't implement a block list for OpenCV since I wasn't going to use it. If we end up wanting it, it would be trivial to add another mode to the parser to just grab all the methods in a class, with a block list. Any objections?

Remaining tasks:

  • Wrap the ImageJ-opencv conversion into Ops

@hinerm
hinerm requested review from ctrueden and gselzer February 7, 2024 19:40

@gselzer gselzer left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for all this work @hinerm!

Couple of additional comments I have:

  • I think it is important to add some mechanism to add descriptions to parameters. Ideally, we'd be able to scrape the javadoc, but that could be tricky.
  • How much additional effort would it require to add some simplifiers on top of this, so that you can call OpenCV functions with RAIs? (I see you mentioned this as a TODO, which is great)

Comment thread scijava-ops-ext-parser/README.md Resolved
Comment thread scijava-ops-ext-parser/README.md Resolved
Comment thread scijava-ops-ext-parser/README.md Resolved
Comment thread scijava-ops-ext-parser/pom.xml Resolved
Comment thread scijava-ops-ext-parser/pom.xml Resolved
Comment thread scijava-ops-ext-parser/README.md Resolved
Comment thread scijava-ops-opencv/opencv-ops.yaml Resolved
Comment thread scijava-ops-opencv/opencv-ops.yaml Resolved
Comment thread scijava-ops-opencv/opencv-ops.yaml Resolved
@gselzer

gselzer commented Feb 8, 2024

Copy link
Copy Markdown
Member

Questions/notes:

* [ ]  Currently I'm doing nothing with `priority` of the wrapped ops. Thoughts?

I think that the only thing you can do is enable users to set a priority in your allowlist...

* [ ]  Missing out on the parameter names/documentation 😞

As far as names go, if you're accessing the methods via reflection, then you should have access to the Parameter objects, and you can call Parameter.getName().

Like I mentioned in my review, I think that short of actually parsing the .java files, you won't be able to get the descriptions. You could allow for copying and pasting of descriptions in your YAML, or you could change the parser radically to run on .java files, which maybe would be best accomplish later with an issue filed for now.

* [ ]  My `Computer` heuristic is stupid and tailored to OpenCV. I saw it as something we could expand support for as needed, but wanted to mention it.

Yeah, like I mentioned in my review I have concerns that this will hold up.

* [ ]  Are there other methods in OpenCV you'd like to see wrapped?

The array operations may be useful, but we could also add more later.

* [ ]  Any suggestions for changes to the aliases I picked? I expect I missed existing Ops when I was naming some of the wrappers.

Just added in some comments where I found aliases in SciJava Ops that differed.

* [ ]  Deciding what to wrap was overwhelming. I ended up _only_ using a curated "white" list in the YAML. Wrapping everything, even with a block list, makes me nervous about getting tons of junk. Also any auto-wrapped ops won't have "Ops-style" aliases. So as I was assessing what I _did_ want to wrap and what their aliases should be, it felt unnecessary to also be documenting a "block" list. So I didn't implement a block list for OpenCV since I wasn't going to use it. If we end up wanting it, it would be trivial to add another mode to the parser to just grab all the methods in a class, with a block list. Any objections?

None here!

@gselzer

gselzer commented Feb 8, 2024

Copy link
Copy Markdown
Member

One final comment - have you thought about the case where there are multiple methods of the same name (i.e. they have different parameters) - your YAML allowlist schema may want to have a way to specify some but not others.

@hinerm
hinerm force-pushed the opencv-ops branch 4 times, most recently from 172a74a to 3a162e3 Compare February 8, 2024 17:22
@hinerm

hinerm commented Feb 8, 2024

Copy link
Copy Markdown
Member Author

have you thought about the case where there are multiple methods of the same name

Yeah this was the intent, to avoid having to explicitly include each method.. if you're making decisions on each method individually, I would consider just writing the yaml by hand.

then an alternative design that would be more explicit, at the cost of adding more lines, would be:

Yeah I think I like this, and we can just say Computer2 in the config yaml to indicate the container position, and can throw priority and author in there as well (with global overrides)

@hinerm
hinerm force-pushed the opencv-ops branch 3 times, most recently from e544731 to 8a69b9f Compare February 15, 2024 16:19
@gselzer gselzer mentioned this pull request Feb 27, 2024
@hinerm
hinerm force-pushed the opencv-ops branch 8 times, most recently from ca924fe to e7af1dd Compare March 5, 2024 21:42
@hinerm
hinerm marked this pull request as ready for review March 5, 2024 21:45
@hinerm

hinerm commented Mar 5, 2024

Copy link
Copy Markdown
Member Author

@gselzer do you mind taking a quick look to see if anything glaring stands out? it does not need to be exhaustive.

hinerm added 27 commits March 6, 2024 08:45
This project has no source code.
Use priority, description, type and alias keys in the shorthand YAML
(removing need for an explicit containers specification).
This will make the output op.yaml deterministic
Without priority being specified these will clash with each other.
Since we're translating between data types the appropriate framework
pathway is simplification.
These are necessary for simplification and adaptation.
This is necessary for the provided RAI copy ops
These are just guarantees that it is possible for the framework to make
satisfy these calls.
We need to compare castability to original method parameters, not
necessarily the simplifiers (which will give an erroneous false positive
in the case of identity focusers)
Remove unused deps, move what we can to runtime/test scope, and add
undeclared imglib2 dep.
@hinerm
hinerm merged commit 55982c8 into main Mar 6, 2024
@hinerm
hinerm deleted the opencv-ops branch March 6, 2024 15:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

Generate an ops.yaml for a 3rd-party library

2 participants