Opencv Cascade classification instead of detection
I have trained my classifiers by using Cascade classification from opencv for object classification.
I have three classes and I have got three *.xml files.
I know one region of the image must be one of the three classes.
However by using opencv, only detectMultiScale function is provided, I must scan the image (or ROI) to find all possible objects in it.
Is there method to classify whether one image(or roi) is matching a specified object or not?
Thank you!
python c++ opencv haar-classifier
add a comment |
I have trained my classifiers by using Cascade classification from opencv for object classification.
I have three classes and I have got three *.xml files.
I know one region of the image must be one of the three classes.
However by using opencv, only detectMultiScale function is provided, I must scan the image (or ROI) to find all possible objects in it.
Is there method to classify whether one image(or roi) is matching a specified object or not?
Thank you!
python c++ opencv haar-classifier
add a comment |
I have trained my classifiers by using Cascade classification from opencv for object classification.
I have three classes and I have got three *.xml files.
I know one region of the image must be one of the three classes.
However by using opencv, only detectMultiScale function is provided, I must scan the image (or ROI) to find all possible objects in it.
Is there method to classify whether one image(or roi) is matching a specified object or not?
Thank you!
python c++ opencv haar-classifier
I have trained my classifiers by using Cascade classification from opencv for object classification.
I have three classes and I have got three *.xml files.
I know one region of the image must be one of the three classes.
However by using opencv, only detectMultiScale function is provided, I must scan the image (or ROI) to find all possible objects in it.
Is there method to classify whether one image(or roi) is matching a specified object or not?
Thank you!
python c++ opencv haar-classifier
python c++ opencv haar-classifier
edited Nov 13 at 12:42
asked Nov 12 at 12:35
Summer Fang
15211
15211
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
From your question I understand that you want to classify three separate ROIs of an image. You might want to create three crops for the defined ROIs:
import cv2
img = cv2.imread("full_image.png")
crop_img1 = img[y:y+h, x:x+w]
#create crop_img2 and crop_img3 analogously
And apply a classifier on each of the three cropped images.
2
It's worth adding that ROI doesn't mean copying data.
– Yuriy
Nov 12 at 12:46
Thank you for your answer but it is not about how to extract an ROI, but how to use Cascade Haar classifier to classify whether an ROI belongs to a class or not. I will try to improve my description also.
– Summer Fang
Nov 13 at 12:38
Yes, I make the assumption that you already know the three ROIs (that is, the coordinatesy
,x
as well as height and widthw
,h
of each region). Do I understand correctly from your comment that you want to rather know how to use the built-in classifier in general?
– jrsh
Nov 13 at 16:43
Generally, I would like to point out the difference between classification and detection. The task you want to perform is classification of an image (an ROI would also be an image). Classification would be the assignment of one single class label to such picture. OpenCV'sdetectMultiScale
method is used for detection, that is the localization of zero or more object bounding boxes in an image (for example, all human faces in a given input image).
– jrsh
Nov 13 at 17:17
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2f53262345%2fopencv-cascade-classification-instead-of-detection%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
From your question I understand that you want to classify three separate ROIs of an image. You might want to create three crops for the defined ROIs:
import cv2
img = cv2.imread("full_image.png")
crop_img1 = img[y:y+h, x:x+w]
#create crop_img2 and crop_img3 analogously
And apply a classifier on each of the three cropped images.
2
It's worth adding that ROI doesn't mean copying data.
– Yuriy
Nov 12 at 12:46
Thank you for your answer but it is not about how to extract an ROI, but how to use Cascade Haar classifier to classify whether an ROI belongs to a class or not. I will try to improve my description also.
– Summer Fang
Nov 13 at 12:38
Yes, I make the assumption that you already know the three ROIs (that is, the coordinatesy
,x
as well as height and widthw
,h
of each region). Do I understand correctly from your comment that you want to rather know how to use the built-in classifier in general?
– jrsh
Nov 13 at 16:43
Generally, I would like to point out the difference between classification and detection. The task you want to perform is classification of an image (an ROI would also be an image). Classification would be the assignment of one single class label to such picture. OpenCV'sdetectMultiScale
method is used for detection, that is the localization of zero or more object bounding boxes in an image (for example, all human faces in a given input image).
– jrsh
Nov 13 at 17:17
add a comment |
From your question I understand that you want to classify three separate ROIs of an image. You might want to create three crops for the defined ROIs:
import cv2
img = cv2.imread("full_image.png")
crop_img1 = img[y:y+h, x:x+w]
#create crop_img2 and crop_img3 analogously
And apply a classifier on each of the three cropped images.
2
It's worth adding that ROI doesn't mean copying data.
– Yuriy
Nov 12 at 12:46
Thank you for your answer but it is not about how to extract an ROI, but how to use Cascade Haar classifier to classify whether an ROI belongs to a class or not. I will try to improve my description also.
– Summer Fang
Nov 13 at 12:38
Yes, I make the assumption that you already know the three ROIs (that is, the coordinatesy
,x
as well as height and widthw
,h
of each region). Do I understand correctly from your comment that you want to rather know how to use the built-in classifier in general?
– jrsh
Nov 13 at 16:43
Generally, I would like to point out the difference between classification and detection. The task you want to perform is classification of an image (an ROI would also be an image). Classification would be the assignment of one single class label to such picture. OpenCV'sdetectMultiScale
method is used for detection, that is the localization of zero or more object bounding boxes in an image (for example, all human faces in a given input image).
– jrsh
Nov 13 at 17:17
add a comment |
From your question I understand that you want to classify three separate ROIs of an image. You might want to create three crops for the defined ROIs:
import cv2
img = cv2.imread("full_image.png")
crop_img1 = img[y:y+h, x:x+w]
#create crop_img2 and crop_img3 analogously
And apply a classifier on each of the three cropped images.
From your question I understand that you want to classify three separate ROIs of an image. You might want to create three crops for the defined ROIs:
import cv2
img = cv2.imread("full_image.png")
crop_img1 = img[y:y+h, x:x+w]
#create crop_img2 and crop_img3 analogously
And apply a classifier on each of the three cropped images.
edited Nov 12 at 12:47
answered Nov 12 at 12:43
jrsh
1169
1169
2
It's worth adding that ROI doesn't mean copying data.
– Yuriy
Nov 12 at 12:46
Thank you for your answer but it is not about how to extract an ROI, but how to use Cascade Haar classifier to classify whether an ROI belongs to a class or not. I will try to improve my description also.
– Summer Fang
Nov 13 at 12:38
Yes, I make the assumption that you already know the three ROIs (that is, the coordinatesy
,x
as well as height and widthw
,h
of each region). Do I understand correctly from your comment that you want to rather know how to use the built-in classifier in general?
– jrsh
Nov 13 at 16:43
Generally, I would like to point out the difference between classification and detection. The task you want to perform is classification of an image (an ROI would also be an image). Classification would be the assignment of one single class label to such picture. OpenCV'sdetectMultiScale
method is used for detection, that is the localization of zero or more object bounding boxes in an image (for example, all human faces in a given input image).
– jrsh
Nov 13 at 17:17
add a comment |
2
It's worth adding that ROI doesn't mean copying data.
– Yuriy
Nov 12 at 12:46
Thank you for your answer but it is not about how to extract an ROI, but how to use Cascade Haar classifier to classify whether an ROI belongs to a class or not. I will try to improve my description also.
– Summer Fang
Nov 13 at 12:38
Yes, I make the assumption that you already know the three ROIs (that is, the coordinatesy
,x
as well as height and widthw
,h
of each region). Do I understand correctly from your comment that you want to rather know how to use the built-in classifier in general?
– jrsh
Nov 13 at 16:43
Generally, I would like to point out the difference between classification and detection. The task you want to perform is classification of an image (an ROI would also be an image). Classification would be the assignment of one single class label to such picture. OpenCV'sdetectMultiScale
method is used for detection, that is the localization of zero or more object bounding boxes in an image (for example, all human faces in a given input image).
– jrsh
Nov 13 at 17:17
2
2
It's worth adding that ROI doesn't mean copying data.
– Yuriy
Nov 12 at 12:46
It's worth adding that ROI doesn't mean copying data.
– Yuriy
Nov 12 at 12:46
Thank you for your answer but it is not about how to extract an ROI, but how to use Cascade Haar classifier to classify whether an ROI belongs to a class or not. I will try to improve my description also.
– Summer Fang
Nov 13 at 12:38
Thank you for your answer but it is not about how to extract an ROI, but how to use Cascade Haar classifier to classify whether an ROI belongs to a class or not. I will try to improve my description also.
– Summer Fang
Nov 13 at 12:38
Yes, I make the assumption that you already know the three ROIs (that is, the coordinates
y
, x
as well as height and width w
, h
of each region). Do I understand correctly from your comment that you want to rather know how to use the built-in classifier in general?– jrsh
Nov 13 at 16:43
Yes, I make the assumption that you already know the three ROIs (that is, the coordinates
y
, x
as well as height and width w
, h
of each region). Do I understand correctly from your comment that you want to rather know how to use the built-in classifier in general?– jrsh
Nov 13 at 16:43
Generally, I would like to point out the difference between classification and detection. The task you want to perform is classification of an image (an ROI would also be an image). Classification would be the assignment of one single class label to such picture. OpenCV's
detectMultiScale
method is used for detection, that is the localization of zero or more object bounding boxes in an image (for example, all human faces in a given input image).– jrsh
Nov 13 at 17:17
Generally, I would like to point out the difference between classification and detection. The task you want to perform is classification of an image (an ROI would also be an image). Classification would be the assignment of one single class label to such picture. OpenCV's
detectMultiScale
method is used for detection, that is the localization of zero or more object bounding boxes in an image (for example, all human faces in a given input image).– jrsh
Nov 13 at 17:17
add a comment |
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%2f53262345%2fopencv-cascade-classification-instead-of-detection%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