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

Im migrating my java application from 1.8 to 11 Im getting Import Errors. #1287

Closed
MachineIntelligence6 opened this issue Aug 28, 2019 · 22 comments

Comments

@MachineIntelligence6
Copy link

MachineIntelligence6 commented Aug 28, 2019

I'm using eclipse and create module.info file int which added automatically the exports and requires
requires opencv;
requires org.bytedeco.javacpp;
requires org.bytedeco.javacv;
requires org.bytedeco.opencv;

It is giving me the error

The package org.bytedeco.javacpp is accessible from more than one module: ffmpeg, opencv, org.bytedeco.javacpp

I was also using OpenCV jar which is also giving me error.

The package org.opencv.core is accessible from more than one module: opencv, org.bytedeco.opencv

In my pom i have added

	<dependency>
		<groupId>org.bytedeco</groupId>
		<artifactId>javacpp</artifactId>
		<version>1.5.1</version>
	</dependency>

	<!-- https://mvnrepository.com/artifact/org.bytedeco/javacv -->
	<dependency>
		<groupId>org.bytedeco</groupId>
		<artifactId>javacv</artifactId>
		<version>1.5.1</version>
	</dependency>

	<dependency>
		<groupId>org.bytedeco.javacpp-presets</groupId>
		<artifactId>libdc1394</artifactId>
		<version>2.2.5-1.4.4</version>
	</dependency>

	<dependency>
		<groupId>org.bytedeco.javacpp-presets</groupId>
		<artifactId>ffmpeg</artifactId>
		<version>4.1-1.4.4</version>
	</dependency>

	<dependency>
		<groupId>org.bytedeco.javacpp-presets</groupId>
		<artifactId>libfreenect</artifactId>
		<version>0.5.3-1.4.4</version>
	</dependency>

	<dependency>
		<groupId>org.bytedeco.javacpp-presets</groupId>
		<artifactId>libfreenect2</artifactId>
		<version>0.2.0-1.4.4</version>
	</dependency>
	
	<dependency>
		<groupId>org.bytedeco.javacpp-presets</groupId>
		<artifactId>librealsense</artifactId>
		<version>1.12.1-1.4.4</version>
	</dependency>

	<dependency>
		<groupId>org.bytedeco.javacpp-presets</groupId>
		<artifactId>artoolkitplus</artifactId>
		<version>2.3.1-1.4.4</version>
	</dependency>

	<dependency>
		<groupId>org.bytedeco.javacpp-presets</groupId>
		<artifactId>flycapture</artifactId>
		<version>2.13.3.31-1.4.4</version>
	</dependency>

	<dependency>
		<groupId>org.bytedeco.javacpp-presets</groupId>
		<artifactId>opencv</artifactId>
		<version>4.0.1-1.4.4</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/org.bytedeco/javacv-platform -->
	<dependency>
		<groupId>org.bytedeco</groupId>
		<artifactId>javacv-platform</artifactId>
		<version>1.5.1</version>
	</dependency>

Thank you

@saudet
Copy link
Member

saudet commented Aug 28, 2019

Use version 1.5.1 everywhere.

@saudet
Copy link
Member

saudet commented Aug 28, 2019

@MachineIntelligence6
Copy link
Author

MachineIntelligence6 commented Aug 29, 2019

Thank you I have correct the version of my dependencies to 1.5.1. I was using very old version of JavaCV before and found out that opencv imports was coming from javacpp packge which need to be also correct, which resolve most of my error.

JavaCV Java2DFrameConverter class when converting JavaCV frame to BufferedImage is giving me error

The type java.awt.image.BufferedImage cannot be resolved. It is indirectly referenced from required .class files

I have used BuferedImage other places in app it only giving me error on converter.

converter.convert(frame);

Any Ideas? Also openCV is also showing error

The package org.opencv.core is accessible from more than one module: opencv, org.bytedeco.opencv

@saudet
Copy link
Member

saudet commented Aug 29, 2019

You'll need Java 2D to be able to use Java2DFrameConverter.

JavaCV doesn't depend on the "opencv" module; you can remove it.

@MachineIntelligence6
Copy link
Author

Thank you for Java2D hint i will check it.
Our App has some module which work on OpenCV so we using both JavaCV and OpenCV.
Is there a way we can resolve the conflict?

@saudet
Copy link
Member

saudet commented Aug 29, 2019

JavaCV bundles all the classes from OpenCV, just use those.

@MachineIntelligence6
Copy link
Author

MachineIntelligence6 commented Aug 29, 2019

I have 7 child modules which is using openCV, and one module (video-viewer) is using both javacv which use open cv and ffmpeg.

video-viewer is using method of other child modules and the input of those method have openCV MAT image.

it will be big change if i change all the 7 modules to JavaCV opencv. do you have a work around for that?

I will be Thank you

@saudet
Copy link
Member

saudet commented Aug 29, 2019

Just exclude the "opencv" module in your app, that will work fine.

@MachineIntelligence6
Copy link
Author

I have exclude the openCV modules in the VIdeo-Viewer which is giving me error on JavaCV version of OpenCV code in video-viewer.

There are 5-8 classes which i nned to change, which is less then the other work.

I think there is no other work around that these both can can work together.

@MachineIntelligence6
Copy link
Author

Thank you for support. Let me know if i can do something for you.

@saudet
Copy link
Member

saudet commented Aug 29, 2019

You shouldn't need to change any classes. What is missing from the presets?

@MachineIntelligence6
Copy link
Author

MachineIntelligence6 commented Aug 29, 2019

I have excluded the openCV like that

<!-- https://mvnrepository.com/artifact/org.bytedeco/javacv -->
		<dependency>
			<groupId>org.bytedeco</groupId>
			<artifactId>javacv</artifactId>
			<version>1.5.1</version>
			<exclusions>
				<exclusion>
					<groupId>org.bytedeco</groupId>
					<artifactId>opencv</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
			<groupId>org.bytedeco</groupId>
			<artifactId>ffmpeg-platform</artifactId>
			<version>4.1.3-1.5.1</version>
		</dependency>

So it start giving me error on

import static org.bytedeco.opencv.global.opencv_core.IPL_DEPTH_8U; import static org.bytedeco.opencv.global.opencv_core.cvAbsDiff; import static org.bytedeco.opencv.global.opencv_core.cvClearMemStorage; import static org.bytedeco.opencv.global.opencv_imgproc.CV_CHAIN_APPROX_SIMPLE; import static org.bytedeco.opencv.global.opencv_imgproc.CV_GAUSSIAN; import static org.bytedeco.opencv.global.opencv_imgproc.CV_RETR_LIST; import static org.bytedeco.opencv.global.opencv_imgproc.CV_RGB2GRAY; import static org.bytedeco.opencv.global.opencv_imgproc.CV_THRESH_BINARY; import static org.bytedeco.opencv.global.opencv_imgproc.cvCvtColor; import static org.bytedeco.opencv.global.opencv_imgproc.cvMinAreaRect2; import static org.bytedeco.opencv.global.opencv_imgproc.cvSmooth; import static org.bytedeco.opencv.global.opencv_imgproc.cvThreshold; import static org.bytedeco.opencv.global.opencv_imgproc.cvFindContours; import org.bytedeco.opencv.opencv_core.*;

After excluding openCV conflict errror is resolved but import error start coming, so i guess i have to port the code form bytedeco.opencv to openCV version?

Im doing something wrong?

@saudet
Copy link
Member

saudet commented Aug 29, 2019

That excludes "org.bytedeco.opencv". JavaCV won't be able to work without it. You need to exclude the "opencv" one.

@MachineIntelligence6
Copy link
Author

Thank you I get it now, it use the openCV version of JavaCV. My version was older, so few error comes after excluding which i resolve now. Thank you for your support. Again let me know i can help you.

@MachineIntelligence6
Copy link
Author

All Error are resolved in the code , when i run the app it give me

Error occurred during initialization of boot layer java.lang.module.FindException: Error reading module: C:\Users\Admin\.m2\repository\org\bytedeco\tesseract\4.1.0-1.5.1\tesseract-4.1.0-1.5.1.jar Caused by: java.lang.module.InvalidModuleDescriptorException: Package org.bytedeco.teeseract.presets not found in module

I have deleted the tesserac folder and it downloaded again, but still got the same issue, Im not using this library in my app.

@saudet
Copy link
Member

saudet commented Aug 30, 2019

That's a known issue fixed in 1.5.2-SNAPSHOT: bytedeco/javacpp-presets#772

@MachineIntelligence6
Copy link
Author

MachineIntelligence6 commented Aug 30, 2019

It solve the above issue, but get another error.

Error occurred during initialization of boot layer java.lang.module.ResolutionException: Modules org.bytedeco.opencv and opencv export package org.opencv.core to module eventbus

`
org.bytedeco
javacv
1.5.2-SNAPSHOT

	<dependency>
		<groupId>org.bytedeco</groupId>
		<artifactId>ffmpeg-platform</artifactId>
		<version>4.1.3-1.5.1</version>
	</dependency>`

@saudet
Copy link
Member

saudet commented Aug 30, 2019

Like I said, you'll need to exclude that "opencv" module!

@MachineIntelligence6
Copy link
Author

I have checked the dependency Hierarchy, search pom, check modular and classpath there is no opencv dependency.

@saudet
Copy link
Member

saudet commented Aug 30, 2019

It's coming from somewhere, you'll need to find where.

@MachineIntelligence6
Copy link
Author

Yes you were right, the child module class path had the opencv (manually added), which is added to our video app class path at runtime.

It fixed the above problem but it say it cannot find the opencv module required by child projects.

Error occurred during initialization of boot layer java.lang.module.FindException: Module opencv not found, required by image.group.mi6

image.group.mi6 is a child project also have module.info file which has require opencv in it, which i exclude in the main app.

@saudet
Copy link
Member

saudet commented Aug 30, 2019

I guess the only way around that is by not using the module path...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants