|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
OpenCV-Devel: Fetch color, intensity and texture of an imageHi
I'm new to OpenCV and just started sifting through the APIs. I intend to fetch the color, intensity and texture values of each pixel constituting the image. I was fiddling with the structure - IplImage to start with but couldn't make much progress.
A friend suggested me to try the following snippet-
#include <iostream.h>
#include <math.h> #include <cv.h> #include <highgui.h> int main( int argc, char** argv ) { // Load the image Mat M = imread("..//secondfig.png");
// Display namedWindow("Lena",CV_WINDOW_AUTOSIZE); imshow("Lena",M);
waitKey(); // Crop out rectangle from (100,100) of size (200,200) of the red channel
const int offset[2] = {100,100}; const int dims[2] = {200,200}; Mat Red(dims[0],dims[1],CV_8UC1);
// Read it from M into Red uchar* lena = M.data; for(int i=0;i<dims[0];++i)
for(int j=0;j<dims[0];++j) { // P = i*rows*channels + j*channels + c
Red.at<uchar>(i,j) = *(lena + (i+offset[0])*M.rows*M.channels() + (j+offset[1])*M.channels()+0); }
//Display namedWindow("RedRect",CV_WINDOW_AUTOSIZE); imshow("RedRect",Red);
waitKey(); } I tried to compile it using - g++ test.cpp -o test -I /usr/include/opencv/ -L /usr/local/lib -lm -lcv -lhighgui -lcvaux -Wno-deprecated
and I get the following errors: test.cpp: In function ‘int main(int, char**)’: test.cpp:11: error: ‘Mat’ was not declared in this scope
test.cpp:11: error: expected `;' before ‘M’ test.cpp:13: error: ‘namedWindow’ was not declared in this scope test.cpp:14: error: ‘M’ was not declared in this scope
test.cpp:14: error: ‘imshow’ was not declared in this scope test.cpp:15: error: ‘waitKey’ was not declared in this scope test.cpp:20: error: expected `;' before ‘Red’
test.cpp:28: error: ‘Red’ was not declared in this scope test.cpp:28: error: expected primary-expression before ‘>’ token test.cpp:33: error: ‘Red’ was not declared in this scope
Is imread() only supported by the latest version of OpenCV? opencv-devel installed in our labs on RHEL machines. Is there a way to find the version of the installed library?
I would really appreciate any help in this regard. Thanks for your time and help. Regards Graduate Student Department of Computer Science Indiana University, Bloomington ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Opencvlibrary-devel mailing list Opencvlibrary-devel@... https://lists.sourceforge.net/lists/listinfo/opencvlibrary-devel |
|
|
Re: OpenCV-Devel: Fetch color, intensity and texture of an imageHi,
all opencv functions are prefixed with cv, and structures with Cv Mat M = ... should be CvMat M = ... but you probably want to use IplImage M = cvLoadImage("../secondfig.png"); imread and imshow are matlab functions I believe. they do not exist in opencv. check out the documentation at http://opencv.willowgarage.com/documentation/index.html cheers, nils On Saturday 10 October 2009 23:30:31 Arun A K wrote: > Hi > I'm new to OpenCV and just started sifting through the APIs. I intend to > fetch the color, intensity and texture values of each pixel constituting > the image. I was fiddling with the structure - IplImage to start with but > couldn't make much progress. > > A friend suggested me to try the following snippet- > > *#include <iostream.h>* > *#include <math.h>* > *#include <cv.h>* > *#include <highgui.h>* > * > * > *int main( int argc, char** argv )* > *{* > *// Load the image* > * Mat M = imread("..//secondfig.png");* > * // Display* > * namedWindow("Lena",CV_WINDOW_AUTOSIZE);* > * imshow("Lena",M);* > * waitKey(); * > * > * > * // Crop out rectangle from (100,100) of size (200,200) of the red > channel * > * const int offset[2] = {100,100};* > * const int dims[2] = {200,200}; * > * Mat Red(dims[0],dims[1],CV_8UC1);* > * > * > * // Read it from M into Red* > * uchar* lena = M.data;* > * for(int i=0;i<dims[0];++i)* > * for(int j=0;j<dims[0];++j)* > * {* > * // P = i*rows*channels + j*channels + c* > * Red.at<uchar>(i,j) = *(lena + > (i+offset[0])*M.rows*M.channels() + (j+offset[1])*M.channels()+0);* > * }* > * > * > * //Display* > * namedWindow("RedRect",CV_WINDOW_AUTOSIZE);* > * imshow("RedRect",Red);* > * waitKey();* > *}* > > I tried to compile it using - *g++ test.cpp -o test -I /usr/include/opencv/ > -L /usr/local/lib -lm -lcv -lhighgui -lcvaux -Wno-deprecated* > > and I get the following errors: > test.cpp: In function ‘int main(int, char**)’: > test.cpp:11: error: ‘Mat’ was not declared in this scope > test.cpp:11: error: expected `;' before ‘M’ > test.cpp:13: error: ‘namedWindow’ was not declared in this scope > test.cpp:14: error: ‘M’ was not declared in this scope > test.cpp:14: error: ‘imshow’ was not declared in this scope > test.cpp:15: error: ‘waitKey’ was not declared in this scope > test.cpp:20: error: expected `;' before ‘Red’ > test.cpp:28: error: ‘Red’ was not declared in this scope > test.cpp:28: error: expected primary-expression before ‘>’ token > test.cpp:33: error: ‘Red’ was not declared in this scope > > Is imread() only supported by the latest version of OpenCV? > opencv-devel installed in our labs on RHEL machines. Is there a way to find > the version of the installed library? > > I would really appreciate any help in this regard. > > Thanks for your time and help. > > Regards > Arun A K > Graduate Student > Department of Computer Science > Indiana University, Bloomington ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Opencvlibrary-devel mailing list Opencvlibrary-devel@... https://lists.sourceforge.net/lists/listinfo/opencvlibrary-devel |
|
|
Re: OpenCV-Devel: Fetch color, intensity and texture of an imageOn Sat, Oct 10, 2009 at 3:50 PM, Nils Hasler <nils.hasler@...> wrote:
> Hi, > > all opencv functions are prefixed with cv, and structures with Cv > > Mat M = ... > should be > CvMat M = ... > > but you probably want to use > > IplImage M = cvLoadImage("../secondfig.png"); > > imread and imshow are matlab functions I believe. they do not exist in opencv. > check out the documentation at > http://opencv.willowgarage.com/documentation/index.html No, they are part of the new C++ interface in head (see {highgui,cv,cxcore,cvaux}.hpp). The cv prefix has also been replaced with cv namespace. >> Is imread() only supported by the latest version of OpenCV? >> opencv-devel installed in our labs on RHEL machines. Is there a way to find >> the version of the installed library? Yes, the new interface is only available since quite recently. So either you should find and install latest packages or build from sources/svn. The so files should have a suffix w/ version number, eg, libcv.so.2.0. rpm will also tell you package version. Xavier ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Opencvlibrary-devel mailing list Opencvlibrary-devel@... https://lists.sourceforge.net/lists/listinfo/opencvlibrary-devel |
|
|
Re: OpenCV-Devel: Fetch color, intensity and texture of an imageOn Sat, Oct 10, 2009 at 2:30 PM, Arun A K <arnkrishn@...> wrote:
> Hi > I'm new to OpenCV and just started sifting through the APIs. I intend to > fetch the color, intensity and texture values of each pixel constituting the > image. I was fiddling with the structure - IplImage to start with but > couldn't make much progress. > A friend suggested me to try the following snippet- > #include <iostream.h> > #include <math.h> > #include <cv.h> > #include <highgui.h> Also you should add using namespace cv; here or prefix Mat and other opencv C++ symbols with cv:: . Xavier > int main( int argc, char** argv ) > { > // Load the image > Mat M = imread("..//secondfig.png"); > // Display > namedWindow("Lena",CV_WINDOW_AUTOSIZE); > imshow("Lena",M); > waitKey(); > // Crop out rectangle from (100,100) of size (200,200) of the red > channel > const int offset[2] = {100,100}; > const int dims[2] = {200,200}; > Mat Red(dims[0],dims[1],CV_8UC1); > // Read it from M into Red > uchar* lena = M.data; > for(int i=0;i<dims[0];++i) > for(int j=0;j<dims[0];++j) > { > // P = i*rows*channels + j*channels + c > Red.at<uchar>(i,j) = *(lena + > (i+offset[0])*M.rows*M.channels() + (j+offset[1])*M.channels()+0); > } > //Display > namedWindow("RedRect",CV_WINDOW_AUTOSIZE); > imshow("RedRect",Red); > waitKey(); > } > I tried to compile it using - g++ test.cpp -o test -I /usr/include/opencv/ > -L /usr/local/lib -lm -lcv -lhighgui -lcvaux -Wno-deprecated > and I get the following errors: > test.cpp: In function ‘int main(int, char**)’: > test.cpp:11: error: ‘Mat’ was not declared in this scope > test.cpp:11: error: expected `;' before ‘M’ > test.cpp:13: error: ‘namedWindow’ was not declared in this scope > test.cpp:14: error: ‘M’ was not declared in this scope > test.cpp:14: error: ‘imshow’ was not declared in this scope > test.cpp:15: error: ‘waitKey’ was not declared in this scope > test.cpp:20: error: expected `;' before ‘Red’ > test.cpp:28: error: ‘Red’ was not declared in this scope > test.cpp:28: error: expected primary-expression before ‘>’ token > test.cpp:33: error: ‘Red’ was not declared in this scope > Is imread() only supported by the latest version of OpenCV? > opencv-devel installed in our labs on RHEL machines. Is there a way to find > the version of the installed library? > I would really appreciate any help in this regard. > Thanks for your time and help. > Regards > Arun A K > Graduate Student > Department of Computer Science > Indiana University, Bloomington > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Opencvlibrary-devel mailing list > Opencvlibrary-devel@... > https://lists.sourceforge.net/lists/listinfo/opencvlibrary-devel > > ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Opencvlibrary-devel mailing list Opencvlibrary-devel@... https://lists.sourceforge.net/lists/listinfo/opencvlibrary-devel |
|
|
Re: OpenCV-Devel: Fetch color, intensity and texture of an imageI'm using this code to crop image,
it works on images in opencv/samples/c/ folder, like lena.jpg, etc. but it doesn't work on my own jpg files, some of the cropped results are like missing every other line. anybody has thoughts?? Thanks very much! |
| Free embeddable forum powered by Nabble | Forum Help |