I once came across to a HMM implementation on top of openCV. http://sourceforge.net/projects/cvhmm/files/, Checking the related CvHMM class, you can see how input data and training data are declared. Here is another project related with structured learning, written with openCV/python: https://github.com/amueller/pystruct
Hallo Priyadharshini Jayakumar. For sure CRF can be used to classify images or for image segmentation. Check this CRF library : Directed Graphical Models (http://research.project-10.de/dgm/doc/a00003.html). It has a very good example on how to classify images including steps of reading in training and validation Images using OpenCV C++ library and also inference algorithms are available there and illustrated.The website also provide example images which you test with for a start as you learn the procedures. The library is also available for download, you just need to configure them in your computer and compiler. You can also have a look at my papers on some work I have done in CRF may be this can serve as an example if it can be suitable for your work.