BACKGROUND: Effective pain recognition and treatment in perioperative environments reduce length of stay and decrease risk of delirium and chronic pain. The authors sought to develop and validate preliminary computer vision-based approaches for nociception detection in hospitalized patients. METHODS: This was a prospective observational cohort study using red-green-blue camera detection of perioperative patients. Adults (18 yr or older) admitted for surgical procedures to the San Francisco Veterans Affairs Medical Center (San Francisco, California) were included across two study phases: (1) the algorithm development phase and (2) the internal validation phase. Continuous recordings occurred perioperatively across any postoperative setting. The authors inputted facial images into convolutional neural networks using a pretrained backbone to classify (1) the Critical Care Pain Observation Tool (CPOT) and (2) the numeric rating scale. Outcomes were binary pain/no pain. We performed external validation for CPOT and numerical rating scale classification on data from the University of Northern British Columbia (Prince George, Canada)-McMaster University (Hamilton, Canada) and the Delaware Pain Database. Perturbation models were used for explainability. RESULTS: The study included 130 patients for development, 77 patients for the validation cohort, and 25 patients from University of Northern British Columbia-McMaster University and 229 patients from Delaware datasets for external validation. Model areas under the curve of the receiver operating characteristic for CPOT models were 0.71 (95% CI, 0.70 to 0.74) on the development cohort, 0.91 (95% CI, 0.90 to 0.92) on the San Francisco Veterans Affairs Medical Center validation cohort, 0.91 (95% CI, 0.89 to 0.93) on University of Northern British Columbia-McMaster University, and 0.80 (95% CI, 0.75 to 0.85) on Delaware. The numeric rating scale model had lower performance (area under the receiver operating characteristics curve, 0.58 [95% CI, 0.55 to 0.61]). Brier scores improved after calibration across multiple different techniques. Perturbation models for CPOT models revealed eyebrows, nose, lips, and forehead were most important for model prediction. CONCLUSIONS: Automated nociception detection using computer vision alone is feasible but requires additional testing and validation given the small datasets used. Future multicenter observational studies are required to better understand the potential for automated continuous assessments for nociception detection in hospitalized patients.