- This letter presents a method to improve detection for robotic harvesting by changing the task objective in real time in an adaptive thresholding algorithm. The adaptive thresholding algorithm includes three main parts: 3-D adaptive thresholding, object detection, and fusion. Optimal local 3-D thresholds that were previously determined according to changing illumination conditions were expanded in this research to include also changing task objectives. The task objectives describe the relationships between false positive rate, true positive rate, and accuracy in the location. The first task objective aims to maximize detection and minimize false alarms so as to ensure the arm is directed only towards real fruits. The second task objective focuses on high accuracy in the detection. Intensive evaluations were conducted on databases, which contained 240 images acquired in the field with various artificial illumination setups. The difference between the two tasks objectives was on average 0.09 in detection rates and 0.66 cm in the accuracy. Robotic experiments resulted in 26.6% difference in pepper grasping success rate with two different task objectives indicating the importance of changing the task objectives for the fruit detection task.