In this study, we compare an ensemble based variational method (En4DVar) proposed by Liu et al, 2008 with a classic strong and weak dynamic constraint 4DVar assimilation. The En4DVar aims at combining the respective advantages of ensemble Kalman filters (EnKF) and 4DVar. In the same way as 4DVar, it is formulated as the minimization of an objective function, but introduces an empirical ensemble-based background-error covariance similarly as EnKF. Thus it functions in a off-line smoothing mode rather than as a sequential filter. In the meantime, the En4DVar avoids the use of tangent linear and adjoint model, which are necessary for standard 4DVar. As the background error covariance matrix plays a key role in the variational process, our study particularly focuses on the generation of the analysis ensemble state with localization techniques. The latter En4DVar technique is then compared to a reference 4DVar technique partially built by an Automatic Differentiation tool. Eventually, we can push the comparison further by considering, in the classic 4DVar technique, the same ensemble-based background-error covariance as defined in the En4DVar framework. We carry out the En4DVar comparison by using a 2D shallow water model. We consider a rectangular shaped tank that we initially tilt then put back in the horizontal position. Our goal is to reconstruct the free surface height and velocity by applying both methods. The comparisons are at first lead with synthetic data, which provide height and velocity observations of the free surface. Both methods are then compared with experimental data of the free surface height observations supplied by a depth sensor camera (Kinect). Two discrete schemes of the Shallow water are also compared in this study. In particular, we examine the ability of weak dynamic constraint 4DVar to cope with a simple centered and strongly diffusive dynamics scheme.