I got null parameter in Java when I try to apply OpenCV?
up vote
0
down vote
favorite
public EllipseParam detectAndDisplay(BufferedImage img, CascadeClassifier faceCascade) {
// EllipseParam openCV;
Point center = null;
double width = 0;
double height = 0;
Mat image = ImagePreProcessing.bufferedImageToMat(img);
// -- Detect faces
MatOfRect faces = new MatOfRect();
faceCascade.detectMultiScale(image, faces);
List<Rect> listOfFaces = faces.toList();
for (Rect face : listOfFaces) {
center = new Point(face.x + face.width * 0.5, face.y + face.height * 0.5);
width = face.width*0.5;
height = face.height*0.5;
System.out.println("OpenCV: " +center);
System.out.println("wid:" +width);
System.out.println("hei:" +height);
EllipseParam openCV = new EllipseParam(center, width, height);
System.out.println("value on EllipseParam: " +String.valueOf(openCV));
return openCV;
}
return null;
}
----- in the EllipseParam class
public class EllipseParam {
public double x;
public double y;
public double a;
public double b;
public double theta;
public Point center;
public double width;
public double height;
public EllipseParam(double x,double y,double a,double b,double theta){
this.x = x;
this.y = y;
this.a = a;
this.b = b;
this.theta = theta;
}
public EllipseParam(Point center, double width, double height){
//this.image = image;
this.center = center;
this.width = width;
this.height = height;
}
I try to setting parameter and getting that, but output I got is like this:
OpenCV: {196.5, 156.5}
wid:147.5
hei:147.5
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
value on EllipseParam: entity.EllipseParam@d34c4b
What is wrong with my code?
I read the answer, but its not solve my issue actually. Can you explain to me more?
java opencv error-handling nullpointerexception netbeans-8
add a comment |
up vote
0
down vote
favorite
public EllipseParam detectAndDisplay(BufferedImage img, CascadeClassifier faceCascade) {
// EllipseParam openCV;
Point center = null;
double width = 0;
double height = 0;
Mat image = ImagePreProcessing.bufferedImageToMat(img);
// -- Detect faces
MatOfRect faces = new MatOfRect();
faceCascade.detectMultiScale(image, faces);
List<Rect> listOfFaces = faces.toList();
for (Rect face : listOfFaces) {
center = new Point(face.x + face.width * 0.5, face.y + face.height * 0.5);
width = face.width*0.5;
height = face.height*0.5;
System.out.println("OpenCV: " +center);
System.out.println("wid:" +width);
System.out.println("hei:" +height);
EllipseParam openCV = new EllipseParam(center, width, height);
System.out.println("value on EllipseParam: " +String.valueOf(openCV));
return openCV;
}
return null;
}
----- in the EllipseParam class
public class EllipseParam {
public double x;
public double y;
public double a;
public double b;
public double theta;
public Point center;
public double width;
public double height;
public EllipseParam(double x,double y,double a,double b,double theta){
this.x = x;
this.y = y;
this.a = a;
this.b = b;
this.theta = theta;
}
public EllipseParam(Point center, double width, double height){
//this.image = image;
this.center = center;
this.width = width;
this.height = height;
}
I try to setting parameter and getting that, but output I got is like this:
OpenCV: {196.5, 156.5}
wid:147.5
hei:147.5
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
value on EllipseParam: entity.EllipseParam@d34c4b
What is wrong with my code?
I read the answer, but its not solve my issue actually. Can you explain to me more?
java opencv error-handling nullpointerexception netbeans-8
Please show the complete stack trace. At the moment we can't tell enough about where the exception is being thrown.
– Jon Skeet
Nov 11 at 12:20
Why do you return null from the method?
– Michael Dz
Nov 11 at 12:21
@JonSkeet oke I try.
– Winda Agusthia Netto
Nov 11 at 12:27
@MichaelDz I tried to apply somecode for different result from my original code I made...but the reason I not really know
– Winda Agusthia Netto
Nov 11 at 12:27
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
public EllipseParam detectAndDisplay(BufferedImage img, CascadeClassifier faceCascade) {
// EllipseParam openCV;
Point center = null;
double width = 0;
double height = 0;
Mat image = ImagePreProcessing.bufferedImageToMat(img);
// -- Detect faces
MatOfRect faces = new MatOfRect();
faceCascade.detectMultiScale(image, faces);
List<Rect> listOfFaces = faces.toList();
for (Rect face : listOfFaces) {
center = new Point(face.x + face.width * 0.5, face.y + face.height * 0.5);
width = face.width*0.5;
height = face.height*0.5;
System.out.println("OpenCV: " +center);
System.out.println("wid:" +width);
System.out.println("hei:" +height);
EllipseParam openCV = new EllipseParam(center, width, height);
System.out.println("value on EllipseParam: " +String.valueOf(openCV));
return openCV;
}
return null;
}
----- in the EllipseParam class
public class EllipseParam {
public double x;
public double y;
public double a;
public double b;
public double theta;
public Point center;
public double width;
public double height;
public EllipseParam(double x,double y,double a,double b,double theta){
this.x = x;
this.y = y;
this.a = a;
this.b = b;
this.theta = theta;
}
public EllipseParam(Point center, double width, double height){
//this.image = image;
this.center = center;
this.width = width;
this.height = height;
}
I try to setting parameter and getting that, but output I got is like this:
OpenCV: {196.5, 156.5}
wid:147.5
hei:147.5
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
value on EllipseParam: entity.EllipseParam@d34c4b
What is wrong with my code?
I read the answer, but its not solve my issue actually. Can you explain to me more?
java opencv error-handling nullpointerexception netbeans-8
public EllipseParam detectAndDisplay(BufferedImage img, CascadeClassifier faceCascade) {
// EllipseParam openCV;
Point center = null;
double width = 0;
double height = 0;
Mat image = ImagePreProcessing.bufferedImageToMat(img);
// -- Detect faces
MatOfRect faces = new MatOfRect();
faceCascade.detectMultiScale(image, faces);
List<Rect> listOfFaces = faces.toList();
for (Rect face : listOfFaces) {
center = new Point(face.x + face.width * 0.5, face.y + face.height * 0.5);
width = face.width*0.5;
height = face.height*0.5;
System.out.println("OpenCV: " +center);
System.out.println("wid:" +width);
System.out.println("hei:" +height);
EllipseParam openCV = new EllipseParam(center, width, height);
System.out.println("value on EllipseParam: " +String.valueOf(openCV));
return openCV;
}
return null;
}
----- in the EllipseParam class
public class EllipseParam {
public double x;
public double y;
public double a;
public double b;
public double theta;
public Point center;
public double width;
public double height;
public EllipseParam(double x,double y,double a,double b,double theta){
this.x = x;
this.y = y;
this.a = a;
this.b = b;
this.theta = theta;
}
public EllipseParam(Point center, double width, double height){
//this.image = image;
this.center = center;
this.width = width;
this.height = height;
}
I try to setting parameter and getting that, but output I got is like this:
OpenCV: {196.5, 156.5}
wid:147.5
hei:147.5
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
value on EllipseParam: entity.EllipseParam@d34c4b
What is wrong with my code?
I read the answer, but its not solve my issue actually. Can you explain to me more?
java opencv error-handling nullpointerexception netbeans-8
java opencv error-handling nullpointerexception netbeans-8
edited Nov 11 at 12:33
asked Nov 11 at 12:18
Winda Agusthia Netto
155
155
Please show the complete stack trace. At the moment we can't tell enough about where the exception is being thrown.
– Jon Skeet
Nov 11 at 12:20
Why do you return null from the method?
– Michael Dz
Nov 11 at 12:21
@JonSkeet oke I try.
– Winda Agusthia Netto
Nov 11 at 12:27
@MichaelDz I tried to apply somecode for different result from my original code I made...but the reason I not really know
– Winda Agusthia Netto
Nov 11 at 12:27
add a comment |
Please show the complete stack trace. At the moment we can't tell enough about where the exception is being thrown.
– Jon Skeet
Nov 11 at 12:20
Why do you return null from the method?
– Michael Dz
Nov 11 at 12:21
@JonSkeet oke I try.
– Winda Agusthia Netto
Nov 11 at 12:27
@MichaelDz I tried to apply somecode for different result from my original code I made...but the reason I not really know
– Winda Agusthia Netto
Nov 11 at 12:27
Please show the complete stack trace. At the moment we can't tell enough about where the exception is being thrown.
– Jon Skeet
Nov 11 at 12:20
Please show the complete stack trace. At the moment we can't tell enough about where the exception is being thrown.
– Jon Skeet
Nov 11 at 12:20
Why do you return null from the method?
– Michael Dz
Nov 11 at 12:21
Why do you return null from the method?
– Michael Dz
Nov 11 at 12:21
@JonSkeet oke I try.
– Winda Agusthia Netto
Nov 11 at 12:27
@JonSkeet oke I try.
– Winda Agusthia Netto
Nov 11 at 12:27
@MichaelDz I tried to apply somecode for different result from my original code I made...but the reason I not really know
– Winda Agusthia Netto
Nov 11 at 12:27
@MichaelDz I tried to apply somecode for different result from my original code I made...but the reason I not really know
– Winda Agusthia Netto
Nov 11 at 12:27
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248684%2fi-got-null-parameter-in-java-when-i-try-to-apply-opencv%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please show the complete stack trace. At the moment we can't tell enough about where the exception is being thrown.
– Jon Skeet
Nov 11 at 12:20
Why do you return null from the method?
– Michael Dz
Nov 11 at 12:21
@JonSkeet oke I try.
– Winda Agusthia Netto
Nov 11 at 12:27
@MichaelDz I tried to apply somecode for different result from my original code I made...but the reason I not really know
– Winda Agusthia Netto
Nov 11 at 12:27