In this paper, a new object oriented probabilistic graphical model, named OPM, and its inference algorithm are proposed to solve the problems of knowledge expression and inference in large Bayesian networks. Firstly, the Bayesian network is segmented into several modules by the name of classes and a kind of object model is used to generate the OPM. OPM can make full use of the conditional independence in the hierarchical structure, which can reduce the complexity of the model construction and knowledge expression effectively. Secondly, an OPM based inference algorithm is proposed via the generalization of the elimination variable inference algorithm to realize the inference mechanism of the OPM. And the parameters in the algorithm can be adjusted according to specific problem to control the computation complexity of the inference process efficiently. And finally, the OPM is used in the automatic detection and location of texts in images to verify its validity. Experimental results show that OPM has not only a ood result, but also a fast detection speed.