Aims. Our goal is to study the physical properties of the circumstellar environment of young stellar objetcs (YSOs). In particular, the determination of the scattering mechanism can help us to constrain the optical depth of the disk and/or envelope in the near infrared. Methods. We used the IAGPOL imaging polarimeter along with the CamIV infrared camera at the LNA observatory to obtain near infrared polarimetry measurements in the H band of a sample of optically visible YSOs, namely, eleven T Tauri stars and eight Herbig Ae/Be stars. An independent determination of the disk (or jet) orientation was obtained for twelve objects from the literature. The circumstellar optical depth could then be estimated by comparing the integrated polarization position angle (PA) with the direction of the major axis of the disk projected onto the plane of the sky. Optically thin disks have, in general, a polarization PA that is perpendicular to the disk plane. In contrast, optically thick disks have polarization PAs parallel to the disks. Results. Among the T Tauri stars, three are consistent with having optically thin disks (AS 353A, RY Tau and UY Aur) and five with optically thick disks (V536 Aql, DG Tau, DO Tau, HL Tau and LkHα 358). Among the Herbig Ae/Be stars, two stars exhibit evidence of optically thin disks (Hen 3-1191 and VV Ser) and two of optically thick disks (PDS 453 and MWC 297). Our results seem consistent with optically thick disks at near infrared bands, which are more likely to be associated with younger YSOs. Marginal evidence of polarization reversal is found in RY Tau, RY Ori, WW Vul, and UY Aur. In the first three cases, this feature can be associated with the UXOR phenomenon. Correlations with the IRAS colors and the spectral index yielded evidence of an evolutionary segregation in which the disks tend to be optically thin when they are older.