Agriculture robot by mechanical harvesting requires automatic detection and counting of fruits in tree canopy. Because of color similarity, shape irregularity, and background complex, fruit identification turns to be a very difficult task and not to mention to execute pick action. Therefore, green cucumber detection within complex background is a challenging task due to all the above-mentioned problems. In this paper, a technique based on texture analysis and color analysis is proposed for detecting cucumber in greenhouse. RGB image was converted to gray-scale image and HSI image to perform algorithm, respectively. Color analysis was carried out in the first stage to remove background, such as soil, branches, and sky, while keeping green fruit pixels presented cucumbers and leaves as many as possible. In parallel, MSER and HOG were applied to texture analysis in gray-scale image. We can obtain some candidate regions by MSER to obtain the candidate including cucumber. The support vector machine is the classifier used for the identification task. In order to further remove false positives, key points were detected by a SIFT algorithm. Then, the results of color analysis and texture analysis were merged to get candidate cucumber regions. In the last stage, the mathematical morphology operation was applied to get complete cucumber.