Skip to content
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

Add demosaicing wrapper #1145

Closed
wants to merge 3 commits into from

Conversation

l0rem1psum
Copy link
Contributor

I have added the wrapper for both cuda and non-cuda version of the demosaicing function.

The unit test for non-cuda demosaicing is completed but I have yet to write a UT for the cuda version because there seems to be a compilation error there which I think I may not be best equipped to address that.

Would be happy to write UT for cuda demosaicing once those errors are fixed.

@l0rem1psum
Copy link
Contributor Author

l0rem1psum commented Jan 28, 2024

Demosaicing with CUDA supports a few additional demosaic types defined in opencv2/cudaimgproc.hpp as DemosaicTypes.

This means CUDA demosaicing can either take in gocv.ColorConversionCode or cuda.DemosaicType (not yet implemented).

In order to ensure type safety and not simply change the last parameter's type to a int. The best way I propose is to use a generic type. For example:

In cuda/imgproc_colorcodes.go (not yet existent):

type DemosaicTypes int

const (
	ColorBaylerBGToBGR_MHT DemosaicTypes = 256
	// ...
)

type ColorConversionCode interface {
	DemosaicTypes | gocv.ColorConversionCode
}

In cuda/imgproc.go:

func Demosaicing[Code ColorConversionCode](src GpuMat, dst *GpuMat, code Code) {
	C.GpuDemosaicing(src.p, dst.p, C.int(code), nil)
}

There won't be any changes to the call site, and caller can now choose what type of code to put in.

However, the current minimum supported Go version is 1.13 (as in go.mod) which does not support generics. So I submitted a PR to update the version to 1.21 (or can be 1.18 for better compatibility).

@deadprogram deadprogram changed the base branch from release to dev March 30, 2024 15:13
@deadprogram
Copy link
Member

there seems to be a compilation error there which I think I may not be best equipped to address that.

Hi @l0rem1psum could you please elaborate a little more on that? Thanks.

@deadprogram
Copy link
Member

Hello @l0rem1psum I think you should rebase against the latest dev branch as the test failure you referred to should be corrected now thanks to #1167

@deadprogram
Copy link
Member

I merged your commits into dev branch after adding some tests. See https://github.com/hybridgroup/gocv/commits/dev/

Thanks again for working on this @l0rem1psum

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.

2 participants