use of com.facebook.react.bridge.WritableArray in project react-native-camera by react-native-community.
the class FacesDetectedEvent method serializeEventData.
private WritableMap serializeEventData() {
WritableArray facesList = Arguments.createArray();
for (int i = 0; i < mFaces.size(); i++) {
Face face = mFaces.valueAt(i);
WritableMap serializedFace = FaceDetectorUtils.serializeFace(face, mScaleX, mScaleY);
if (mImageDimensions.getFacing() == CameraView.FACING_FRONT) {
serializedFace = FaceDetectorUtils.rotateFaceX(serializedFace, mImageDimensions.getWidth(), mScaleX);
} else {
serializedFace = FaceDetectorUtils.changeAnglesDirection(serializedFace);
}
facesList.pushMap(serializedFace);
}
WritableMap event = Arguments.createMap();
event.putString("type", "face");
event.putArray("faces", facesList);
event.putInt("target", getViewTag());
return event;
}
use of com.facebook.react.bridge.WritableArray in project react-native-camera by react-native-community.
the class TextRecognizedEvent method serializeText.
private WritableMap serializeText(Text text) {
WritableMap encodedText = Arguments.createMap();
WritableArray components = Arguments.createArray();
for (Text component : text.getComponents()) {
components.pushMap(serializeText(component));
}
encodedText.putArray("components", components);
encodedText.putString("value", text.getValue());
WritableMap origin = Arguments.createMap();
origin.putDouble("x", text.getBoundingBox().left * this.mScaleX);
origin.putDouble("y", text.getBoundingBox().top * this.mScaleY);
WritableMap size = Arguments.createMap();
size.putDouble("width", text.getBoundingBox().width() * this.mScaleX);
size.putDouble("height", text.getBoundingBox().height() * this.mScaleY);
WritableMap bounds = Arguments.createMap();
bounds.putMap("origin", origin);
bounds.putMap("size", size);
encodedText.putMap("bounds", bounds);
String type_;
if (text instanceof TextBlock) {
type_ = "block";
} else if (text instanceof Line) {
type_ = "line";
} else /*if (text instanceof Element)*/
{
type_ = "element";
}
encodedText.putString("type", type_);
return encodedText;
}
use of com.facebook.react.bridge.WritableArray in project react-native-video by react-native-community.
the class VideoEventEmitter method timedMetadata.
void timedMetadata(Metadata metadata) {
WritableArray metadataArray = Arguments.createArray();
for (int i = 0; i < metadata.length(); i++) {
Id3Frame frame = (Id3Frame) metadata.get(i);
String value = "";
if (frame instanceof TextInformationFrame) {
TextInformationFrame txxxFrame = (TextInformationFrame) frame;
value = txxxFrame.value;
}
String identifier = frame.id;
WritableMap map = Arguments.createMap();
map.putString("identifier", identifier);
map.putString("value", value);
metadataArray.pushMap(map);
}
WritableMap event = Arguments.createMap();
event.putArray(EVENT_PROP_TIMED_METADATA, metadataArray);
receiveEvent(EVENT_TIMED_METADATA, event);
}
use of com.facebook.react.bridge.WritableArray in project react-native-google-places by tolu360.
the class RNGooglePlacesModule method getCurrentPlace.
@ReactMethod
public void getCurrentPlace(final Promise promise) {
PendingResult<PlaceLikelihoodBuffer> results = Places.PlaceDetectionApi.getCurrentPlace(mGoogleApiClient, null);
PlaceLikelihoodBuffer likelyPlaces = results.await(60, TimeUnit.SECONDS);
final Status status = likelyPlaces.getStatus();
if (status.isSuccess()) {
if (likelyPlaces.getCount() == 0) {
WritableArray emptyResult = Arguments.createArray();
likelyPlaces.release();
promise.resolve(emptyResult);
return;
}
WritableArray likelyPlacesList = Arguments.createArray();
for (PlaceLikelihood placeLikelihood : likelyPlaces) {
WritableMap map = propertiesMapForPlace(placeLikelihood.getPlace());
map.putDouble("likelihood", placeLikelihood.getLikelihood());
likelyPlacesList.pushMap(map);
}
// Release the buffer now that all data has been copied.
likelyPlaces.release();
promise.resolve(likelyPlacesList);
} else {
Log.i(TAG, "Error making places detection api call: " + status.getStatusMessage());
likelyPlaces.release();
promise.reject("E_PLACE_DETECTION_API_ERROR", new Error("Error making places detection api call: " + status.getStatusMessage()));
return;
}
}
use of com.facebook.react.bridge.WritableArray in project react-native-camera by lwansbrough.
the class FaceDetectorAsyncTask method serializeEventData.
private WritableArray serializeEventData(List<Face> faces) {
WritableArray facesList = Arguments.createArray();
for (Face face : faces) {
WritableMap serializedFace = FaceDetectorUtils.serializeFace(face, mScaleX, mScaleY, mWidth, mHeight, mPaddingLeft, mPaddingTop);
if (mImageDimensions.getFacing() == CameraView.FACING_FRONT) {
serializedFace = FaceDetectorUtils.rotateFaceX(serializedFace, mImageDimensions.getWidth(), mScaleX);
} else {
serializedFace = FaceDetectorUtils.changeAnglesDirection(serializedFace);
}
facesList.pushMap(serializedFace);
}
return facesList;
}
Aggregations