In this paper, we propose a visual tracking approach based on `bag of features` (BoF) algorithm. First we use incremental PCA visual tracking (IVT) in the first few frames and collect image patches randomly sampled within the tracked object region in each frame for constructing the codebook; the tracked object then can be converted to a bag. Second we construct two codebooks using color (RGB) features and local binary pattern (LBP) features instead of only one codebook in traditional BoF, thereby extracting more informative details. We also devise an updating mechanism to deal with pose and appearance changes of objects. In the tracking process, a constant number of candidates are generated by sampling technique in each frame. Image patches are then randomly sampled and candidates are represented as bags by codebooks. Thus, we can compute patch similarity of a candidate with the codewords and bag similarity with trained bags. The actual object is then located by finding the maximal combined similarity of patches and bags. Experiments demonstrate that our approach is robust in handling occlusion, scaling and rotation.