私はルービックのサイドスキャナを使ってキューブの状態を判断しています。私はコンピュータビジョンにはかなり新しいので、ちょっとした挑戦でした。私がこれまで行ってきたことは、ビデオキャプチャを使用し、特定のフレームでそのフレームをキャプチャし、画像処理用に保存することです。ここに、それがどのように見えるかがあります。 画像OpenCVのピクセルのHSV値を取得する
写真を撮ると、キューブは毎回同じ位置にあるので、私はステッカーの位置を心配する必要はありません。 私が問題を抱えているのは、HSVを決定するために各四角形内の小さな範囲のピクセルを取得することです。
私は私がそれをロードし、画像のHSV値を分割した画像をキャプチャしているが、特定のピクセル座標を取得する方法がわからないので、後にHSVの範囲はおよそ
Red = Hue(0...9) AND Hue(151..180)
Orange = Hue(10...15)
Yellow = Hue(16..45)
Green = Hue(46..100)
Blue = Hue(101..150)
White = Saturation(0..20) AND Value(230..255)
いることを知っています画像のどうすればいいですか?
BufferedImage getOneFrame() {
currFrame++;
//At the 90th frame I capture that frame and save that frame
if (currFrame == 120) {
cap.read(mat2Img.mat);
mat2Img.getImage(mat2Img.mat);
Imgcodecs.imwrite("firstImage.png", mat2Img.mat);
}
cap.read(mat2Img.mat);
return mat2Img.getImage(mat2Img.mat);
}
public void splitChannels() {
IplImage firstShot = cvLoadImage("firstImage.png");
//I split the channels so that I can determine the value of the pixel range
IplImage hsv = IplImage.create(firstShot.width(), firstShot.height(), firstShot.depth(), firstShot.nChannels());
IplImage hue = IplImage.create(firstShot.width(), firstShot.height(), firstShot.depth(), CV_8UC1);
IplImage sat = IplImage.create(firstShot.width(), firstShot.height(), firstShot.depth(), CV_8UC1);
IplImage val = IplImage.create(firstShot.width(), firstShot.height(), firstShot.depth(), CV_8UC1);
cvSplit(hsv, hue, sat, val, null);
//How do I get a small range of pixels of my images to determine get their HSV?
}
私が以前に 'Mat'を使っていた' IplImage'を使う特別な理由はありませんでしたが、 'Mat'画像をロードする方法が見つかりませんでした。その画像のカラーチャンネルを分割します。個々のHSVチャネルに – cuber
'imread'と' cvtColor'と、ウェブ上にある多くの例を使ってください。 :) がんばろう! – Nejc
私は 'cvtColor'を使わなければなりません。私は既に私が望む形式でイメージを持っています。 – cuber