我使用cwac-library构建了自定义相机应用程序。我正在尝试访问使用前置摄像头捕获的图像的exif数据,但是像TAG_GPS_LATITUDE,TAG_GPS_LATITUDE_REF,TAG_GPS_LONGITUDE,TAG_GPS_LONGITUDE_REF,TAG_MAKE,TAG_MODEL ..这样的exif标记返回null。只有标签工作是TAG_DATETIME。这仅适用于使用前置摄像头拍摄的照片,每个标签都可以完美地返回使用后置摄像头
拍摄的图像的值使用前置摄像头时我遗失的任何东西?
包括代码
自定义相机片段类
public class CustomCameraFragment extends CameraFragment {
static CustomCameraFragment newInstance() {
return new CustomCameraFragment();
}
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
SimpleCameraHost.Builder builder = new SimpleCameraHost.Builder(new CustomCameraHost(getActivity()));
builder.useFullBleedPreview(true);
builder.useFrontFacingCamera(true);
builder.mirrorFFC(true);
setHost(builder.build());
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View cameraView = super.onCreateView(inflater, container, savedInstanceState);
View fragmentView = inflater.inflate(R.layout.camera_fragment, container, false);
FrameLayout cameraPreview = (FrameLayout)fragmentView.findViewById(R.id.camera_preview);
((ViewGroup)cameraPreview).addView(cameraView);
return fragmentView;
}
}
自定义相机主机类
public class CustomCameraHost extends SimpleCameraHost {
public CustomCameraHost(Activity activity) {
super(activity);
}
@Override
public Parameters adjustPictureParameters(PictureTransaction xact, Parameters parameters) {
Location location = LocationUtils.getLastKnownLocation();
parameters.setGpsLatitude(location.getLatitude());
parameters.setGpsLongitude(location.getLongitude());
parameters.setGpsProcessingMethod(location.getProvider().toUpperCase());
if (location.hasAltitude()) {
parameters.setGpsAltitude(location.getAltitude());
} else {
parameters.setGpsAltitude(0);
}
if (location.getTime() != 0) {
// Location.getTime() is UTC in milliseconds. Gps-timestamp is UTC in seconds.
long utcTimeSeconds = location.getTime() / 1000;
parameters.setGpsTimestamp(utcTimeSeconds);
}
return super.adjustPictureParameters(xact, parameters);
}
}