Commit Graph

71 Commits

Author SHA1 Message Date
Hendy Irawan
0df72c3114
feat(android): onBarCodeRead should also send raw photo bytes, fixed #2786 (#2923)
* feat: onBarCodeRead should also send raw photo bytes, fixed #2786

* docs: documentation to explain feature #2786
2020-07-23 14:04:18 -03:00
René Fischer
95201574c0 Merge branch 'master' into feat/advanced-camera-settings
# Conflicts:
#	ios/RN/RNCamera.m
#	ios/RNCamera.xcodeproj/project.pbxproj
2020-05-25 09:37:13 +02:00
SimonErm
dc4f65702f
feat(touch): Feature/add on tap events (#2827)
* add TouchEvent on android

* add GestureHandler to detect touches on android

* add property to enable touchDetector on android

* add onTouch event to ios

* add GestureRecognizer to ios

* add onTouch property and js setup

* add missing semicolons

* fix literal notation

* add missing ":"

* fix copy-paste error (wrong var-name)

* pass the native event to the onTouch callback

* replace : with ;

* add onTouch type defs

* add documentation for onTouch property

* scale postion before emitting since the event coordinates are raw pixels

* migrate advanced example to native pinch zoom and onTouch

* split onTouch property into onTap and onDoubleTap
2020-05-12 17:56:42 -03:00
SimonErm
5b32936f00
feat(zoom): Feature/add native zoom (#2815)
* add native zoom on android

* add native zoom on ios

* add useNativeZoom property

* extract compution of maxZoomFactor to a method

* use optional maxZoomFactor for native zoom

* add useNativeZoom Property to typescript declaration

* add doc entry for useNativeZoom
2020-05-05 15:59:56 -03:00
Brent Kelly
45308c1bae
fix(types): updated types as per RN 0.62 version of @types/react-native (#2794)
* fix(types): updated types as per RN 0.62 version of @types/react-native

* chore(cr): reverting version back to 3.23.0
2020-04-15 11:12:01 -03:00
René Fischer
68953bcb14 feat(ios): refactoring
- merged whiteBalance and customWhiteBalance properties into one
- separate methods for custom and normal white balance modes
2020-04-02 17:29:37 +02:00
René Fischer
9e9e12b05a feat(ios): added CustomWhiteBalance type 2020-03-25 14:48:19 +01:00
Aaron Tribou
86e8053160
Fix TrackedTextFeature TS type 2020-03-24 21:13:23 -05:00
René Fischer
8c2100dd63 feat(ios): customize white balance
added possibility to customize white balance settings (temperature, tint, rgb gains offset)
2020-03-20 16:35:13 +01:00
Mateus Andrade
43a7323f83
Merge pull request #2719 from bqwang91/master
Android - Limiting Scanning Area using rectOfInterest
2020-03-13 09:39:55 -03:00
cinjon
d60d201eb2
feat(ios): Expose an ability to change the frames per second via an fps option in record. (#2711) 2020-02-27 14:47:45 -03:00
James Wang
802ce479ff add types 2020-02-27 13:52:57 +11:00
cristianoccazinsp
c7e92b29c8
feature(record): On recording start and end events (#2702)
* This update tries to improve audio recording interruptions on iOS due to phone calls or background music.

- Use a more generic event to handle session interruptions. This removes the need to listen to foreground/background events, and stopping the session this way was actually redundant/wrong (see https://forums.developer.apple.com/thread/61406). This also makes session stopping detection more reliable (calls, suspension due to a call or notification, etc., which would previously not set the recording interrupted flag on every case)

From the above docs: "No, incorrect. You _never_ need to stop your capture session. The capture session automatically stops itself when your app goes to the background and resumes itself when you come back to the foreground."

- Allow for `captureAudio` updates to also update the audio connections internally so the prop can be correctly updated on the fly without remounting.

- add onAudioInterrupted and onAudioConnected events so the UI can handle scenarios where audio is wanted but not available. This should also help in keeping the preview active even if audio is interrupted and we have captureAudio={true}. Lastly, it can be used to detect if we can record audio or not due to the dummy implementation of the audio permission on iOS always returning true.

- check, activate, and release audio sessions (if captureAudio) so we can detect early if audio is available before attempting to connect the input. This will also allow us to detect if we can record even if there was already a call before opening the camera.

- use proper observer for session error instead of of the strong self block. No benefit, but makes code more readable and allows access to instance variables

- getDeviceOrientationWithBlock might fire more than once under some circumstances, ending up taking a picture or video twice. Add a lock and additional check to prevent this.

* no need for change check,

* do not resume audio if we were hinted not to (e.g., music playback happening)

* Move heavy work to a dedicated background thread. Improves camera initial loading and resumes from background.

Details:

- Use a HandlerThread to delegate heavy tasks to background. The thread is managed by the view, and passed down to the implementation in case it also needs to use it. The view will fire start calls and other possibly heavy operations in this thread to avoid ANRs. Some code sent to this thread:
    - start calls: start is extremely heavy and will cause ANRs on some devices, especially when coming back from background
    - Camera1: some preset changes fire a stop/start sequence. These will now happen in the background thread
    - take picture and start recording (from view class) will also start in this thread

- Add some extra null checks

- View was not properly cleaning up itself on destroy (host destroy event was never fired)

* Fix for a possible crash when changing devices and changing focus. If the new device resets the focus, "defocusing" might not be possible if the new device does not support auto focus. For this reason, we need to do a different cleanup on the focus and exposed flags and events.

* start session here also on session queue.

* check for session running before trying to record or capture.
This should fix a possible race condition where both the session start call happens at the same time as the record call

* set preview orientation also in session queue

* no need to set orientation on constructor, and set it on session queue to prevent race conditions

* move device init and checks also to session queue. This prevents possible double initializations.

* catch possible errors when starting camera preview. This might still randomly fail on some devices for some reason.

* delay capture in progress until we have resumed/paused preview.

* do not crash the app if set texture setup failed

* more synchronized checks to prevent crashes due to concurrent camera updates

* remove unused imports

* Handle audio interruption in session queue. This prevents the session isRunning flag from getting corrupted due to concurrent updates to the session.

* Fix possible crash when attempting to retrieve camera parameters.

* Preserve exif/metadata on photo capture. Add a few comments to each step of the capture process

* orientation must be fixed before mirroring

* x/y dimensions are redundantly updated (storing the image sets them automatically). However, orientation must be reset on any image change since the final stored image is automatically rotated when it is modified in place.

* revert mirrorImage order, has to be first since forceUpOrientation adjusts the image afterwards.

* Minor change: also implement `onPictureTaken` for iOS in case anyone needs the early event.

* - Improve Android code so skipProcessing is not needed, the code is more in line with iOS, and is "fast" by default. This means that skipProcessing is no longer needed (nor used), and adding additional options will "slow down" the capture as expected, rather than having always a lot of processing. This shouldn't be a breaking change.

- document the writeExif option, and implement it for iOS as well.

* This is a fix for events possibly being fired not on the main thread, which could cause the whole app to freeze.

* Fire events on the right thread. No need to use UI thread, and fix the still works

* Release CF object which could cause a memleak

* Fix Objects.equals that is only available after API 19

* allow for audio session to be kept even after unmounts

* readme typo

* readme typo

* Make camera ready events to fire also on camera/device change to be consistent with Android. Fire unmount error when session or device fails to start.

* update example app to properly use camera ready event

* Make camera ready events to fire also on camera/device change to be consistent with Android. Fire unmount error when session or device fails to start. Update advanced example app to use camera ready event instead.

* Android crash fixes. Make sure no unsupported aspect ratio is used, and do not crash when there are no cameras available.

* stop/release camera in non-UI thread so we prevent ANRs and UI freezing.

Some phones may take up to a second to release the camera and preview.

* move codec, max duration, and max file size settings to the session queue.

This might prevent a race condition when changing presets/quality.

* android crash fix

* Add onRecordingStart and onRecordingEnd events

* fix for surface destroy and resume events.

* add missing types

* fix for surface destroy and resume events.

* add missing types

Co-authored-by: Cristiano Coelho <cristianocca@hotmail.com>
2020-02-13 23:21:59 -03:00
Jackie Wung
ea05b1449d
add pictureSize type 2020-01-23 14:38:49 -08:00
mauriciopf
cd4c8f24e3 feat(RNCameraManager): expose videoStabilizationMode from native (#2681)
* fix(RNCameraManager) expose videoStabilizationMode from native

* refactor(types): add videoStabilization to the module declaration
2020-01-22 14:42:20 -03:00
cristianoccazinsp
fe5d11d12f feat(iOS): allow for audio session to be kept (#2636)
* allow for audio session to be kept even after unmounts

* readme typo
2019-12-10 11:02:45 -03:00
Kyle Johnson
3f1334c5e0 feat(types): Add "URL" to Barcode types & export additional TS types (#2613)
* Add "URL" to flow types

* add "URL" to barcodes & export additional TS types

* add optional format to flow

* add optionl format prop to TS
2019-11-29 19:00:10 -03:00
Chau Tran
168b3eec8b fix onBarcodeRead (#2604) 2019-11-24 12:30:30 -03:00
cristianoccazinsp
aa22fd1fff feat(exif): Implement writeExif for iOS, Android improvements (#2577)
* - Improve Android code so skipProcessing is not needed, the code is more in line with iOS, and is "fast" by default. This means that skipProcessing is no longer needed (nor used), and adding additional options will "slow down" the capture as expected, rather than having always a lot of processing. This shouldn't be a breaking change.

- document the writeExif option, and implement it for iOS as well.

* Release CF object which could cause a memleak
2019-11-20 00:22:08 -03:00
maderesponsively
eece04a66c feat(ts): Update index.d.ts (#2590)
Added missing googleVisionBarcodeMode prop
2019-11-18 09:53:06 -03:00
cristianoccazinsp
59dfdb649a feat(Ios): handle audio interruptions (#2565)
* This update tries to improve audio recording interruptions on iOS due to phone calls or background music.

- Use a more generic event to handle session interruptions. This removes the need to listen to foreground/background events, and stopping the session this way was actually redundant/wrong (see https://forums.developer.apple.com/thread/61406). This also makes session stopping detection more reliable (calls, suspension due to a call or notification, etc., which would previously not set the recording interrupted flag on every case)

From the above docs: "No, incorrect. You _never_ need to stop your capture session. The capture session automatically stops itself when your app goes to the background and resumes itself when you come back to the foreground."

- Allow for `captureAudio` updates to also update the audio connections internally so the prop can be correctly updated on the fly without remounting.

- add onAudioInterrupted and onAudioConnected events so the UI can handle scenarios where audio is wanted but not available. This should also help in keeping the preview active even if audio is interrupted and we have captureAudio={true}. Lastly, it can be used to detect if we can record audio or not due to the dummy implementation of the audio permission on iOS always returning true.

- check, activate, and release audio sessions (if captureAudio) so we can detect early if audio is available before attempting to connect the input. This will also allow us to detect if we can record even if there was already a call before opening the camera.

- use proper observer for session error instead of of the strong self block. No benefit, but makes code more readable and allows access to instance variables

- getDeviceOrientationWithBlock might fire more than once under some circumstances, ending up taking a picture or video twice. Add a lock and additional check to prevent this.

* no need for change check,

* do not resume audio if we were hinted not to (e.g., music playback happening)

* start session here also on session queue.

* check for session running before trying to record or capture.
This should fix a possible race condition where both the session start call happens at the same time as the record call

* no need to set orientation on constructor, and set it on session queue to prevent race conditions

* move device init and checks also to session queue. This prevents possible double initializations.
2019-11-04 18:39:37 -03:00
Symous
20e04863c7 feat(android): support null object of androidPermissionOptions to avoid request window (#2551) 2019-10-18 08:44:38 -03:00
cristianoccazinsp
6b7d7f4a64 feature(ios): Ios exposure poi (#2514)
* feat: autoexposure on point of interest and defocus on subject change

* Impelement cameraIds for iOS, and various iOS bug fixes.

Summary:

- Implement getCameraIds and cameraId property to manually select a camera device.

- Fix the internal preset being used to properly use a photo and video preset, and check for invalid presets on camera switch.
    - This fixes a bug that would happen after recording. After a recording is complete, the camera preset was set to 4k permanently, and attempting to select any camera that does not support that preset would result in an totally unusable camera. Now, the "Photo" preset is the default which should be the highest quality option for photos, and the previously used "High" preset will be used as video default if no value is provided.
    - This also adds proper support to setting the undocumented "pictureSize" property. Setting this property will change the default photo quality to be that one.

- Minor cleanup to the camera initialization so the same code is not called as many times redundantly (start session / device happening multiple times)
    - The reduced redundant calls to start session and session updates should make the camera startup slightly faster.

- Fix for warnings issued due to misuse of the "isRecording" property. This property was defined as both as a property and a method and was both getting set manually and retrieved with a function. It should now consistently only be retrieved with a function based on the real recording status. Should have no behaivour change, but removes a pesky warning.

- Fix an issue related to the camera getting stuck after a background resume by removing the use of the queue for those two events.

- Fixes a wrong event unsubscription (UIDeviceOrientationDidChangeNotification to UIApplicationDidChangeStatusBarOrientationNotification) from a previous change. Also move event subscriptions to superview changes for consistency and so they are not used/consumed if not needed. After testing, the View of RNCamera is instantiated twice (for some reason I couldn't find) but used only once. RN keeps a reference to the view in memory even after the camera is destroyed, resulting in these events getting fired and handled all the time during the app's lifetime.

* add maxZoom property to iOS.

Android: Not needed as of now. Also, zoom multiplier behaves different on Android and can't be used with the same value as iOS.

* add auto exposure option.
This branch is temporary from the other changes until the proper changes from https://github.com/react-native-community/react-native-camera/pull/2423/files are merged.

* allow for expose POI to also be cleared

* Add ultra-wide lense support. Requires XCode with SDK for iOS 13

* check that video capture device is ready before capturing, fix for string cameraId assignment

* add missing ios 13 camera types and exposure check.

* remove duplicates from camera id list, return its type on IOS, handle WB crash on unsupported devices.

* Do not return virtual devices (we can't really use them with the library), update zoom and flash on preset change so they are maintained while recording/restoring.

* remove redundant duplicates check, add SDK macro check for ultra wide lenses, remove virtual cameras from query

* Add more info about deviceType and iOS camera IDs behaviour.
2019-10-10 12:01:16 -03:00
cristianoccazinsp
58f3b3edbd feat(ios): Add cameraId feature to iOS and various bug fixes (#2510)
* Impelement cameraIds for iOS, and various iOS bug fixes.

Summary:

- Implement getCameraIds and cameraId property to manually select a camera device.

- Fix the internal preset being used to properly use a photo and video preset, and check for invalid presets on camera switch.
    - This fixes a bug that would happen after recording. After a recording is complete, the camera preset was set to 4k permanently, and attempting to select any camera that does not support that preset would result in an totally unusable camera. Now, the "Photo" preset is the default which should be the highest quality option for photos, and the previously used "High" preset will be used as video default if no value is provided.
    - This also adds proper support to setting the undocumented "pictureSize" property. Setting this property will change the default photo quality to be that one.

- Minor cleanup to the camera initialization so the same code is not called as many times redundantly (start session / device happening multiple times)
    - The reduced redundant calls to start session and session updates should make the camera startup slightly faster.

- Fix for warnings issued due to misuse of the "isRecording" property. This property was defined as both as a property and a method and was both getting set manually and retrieved with a function. It should now consistently only be retrieved with a function based on the real recording status. Should have no behaivour change, but removes a pesky warning.

- Fix an issue related to the camera getting stuck after a background resume by removing the use of the queue for those two events.

- Fixes a wrong event unsubscription (UIDeviceOrientationDidChangeNotification to UIApplicationDidChangeStatusBarOrientationNotification) from a previous change. Also move event subscriptions to superview changes for consistency and so they are not used/consumed if not needed. After testing, the View of RNCamera is instantiated twice (for some reason I couldn't find) but used only once. RN keeps a reference to the view in memory even after the camera is destroyed, resulting in these events getting fired and handled all the time during the app's lifetime.

* add maxZoom property to iOS.

Android: Not needed as of now. Also, zoom multiplier behaves different on Android and can't be used with the same value as iOS.
2019-10-08 12:24:21 -03:00
Nathan Heinrich
38a5ffb2eb feat(ios): videoBitrate option for iOS (#2504)
* Update RNCamera.m

Add videoBitrate option for ios, setting video bitrate requires a codec to be set

* Update API documentation

* Update documentation

* Update typings
2019-09-24 09:32:22 -03:00
Dominik Schwarz
c93e92f602 fix(android): use initial exposure value (#2418) 2019-08-07 17:47:43 -03:00
Valentin
c748b4eccc fix(android): Support writing custom Exif tags to modified image file (#2402) 2019-08-02 11:10:10 -03:00
David Castillo
85b6431353
Fixes type of the onStatusChange callback in types/index.d.ts
Currently, the `onStatusChange` has a type of 
```ts
onStatusChange?(event: {
    cameraStatus: CameraStatus;
    recordAudioPermissionStatus: keyof RecordAudioPermissionStatus;
  }): void
```
Which makes it very inconvenient to use with Typescript, having to set the `cameraStatus` field to `any` in the passed function:
```ts
const handleStatusChange = (event: {cameraStatus: any}) => {
    if (event.cameraStatus === 'NOT_AUTHORIZED') {
    }
  }
```
By changing it to
```ts
onStatusChange?(event: {
    cameraStatus: keyof CameraStatus;
    recordAudioPermissionStatus: keyof RecordAudioPermissionStatus;
  }): void
```
we're able to compare the new status against the intended type, autocomplete, and discard the `any`:
```ts

  const handleStatusChange = (event: {cameraStatus: keyof CameraStatus}) => {
    if (event.cameraStatus === 'NOT_AUTHORIZED') {
      onUnauthorized()
    }
  }
```
2019-06-19 12:53:44 -05:00
Valentin
8ad809ee88 feat(android): write Exif tags to modified image file (#2263) 2019-05-15 09:10:03 -03:00
Noitidart
1d8465b555
Add prop of autoFocusPointOfInterest 2019-04-29 11:06:16 -07:00
Jose Grana
b7cd9fe9b1 chore(typescript): add androidCameraPermissionOptions & androidRecordAudioPermissionOptions types 2019-04-26 11:30:02 +02:00
Noitidart
617b632bf9 Extend interface with _cameraRef and _cameraHandle (#2225) 2019-04-24 11:42:21 -03:00
Lerte Smith
0957b5fb4b fix(ts): Update index.d.ts (#2214) 2019-04-17 22:45:32 -03:00
Daniil Ovoshchnikov
1b9fb63e56 feat(mlkit): add mlkit barcode detection ios (#2209)
extend barcode type cases for android
2019-04-16 15:33:46 -03:00
Sankaran Kaliappan
8cc3ca2898 fix(ios): [iOS] Video Interrupted on incoming call fix (#2207)
* [iOS] Video Interrupted on incoming call fix

* Update index.d.ts
2019-04-14 08:47:12 -03:00
Daniil Ovoshchnikov
025e7d97a4 feat(ios): migrate face detection to mlkit (#2193)
add face detection using mlkit
add enable tracking prop
cleanup android set tracking methods
remove old face detection
fix basic example not building on ios
2019-04-11 09:10:19 -03:00
Shashank Kushwah
9d56a21ddc [Android] Expose barcode bounds and source dimension from google vision barcode scanner (#2095)
* added react-navigation

* added barcode scanner example

* exposed barcode bounds and source dimensions in google vision barcode

* updated typescript types for google vision barcode
2019-03-09 11:41:15 -03:00
Dariusz Górak
04ea06a17d fix: introduce refreshAuthorizationStatus method (#2014) 2019-03-08 11:18:39 -03:00
SimonErm
1e64b15cc1 fix: change misspelled upce to upc_e (adjust to native constants) (#2109) 2019-02-15 11:42:15 +01:00
Laurin Quast
45efcdb74d
fix(types): fix onStatusChange callback typescript definitions (#2091), Fixes #2090 2019-02-03 20:33:36 +01:00
Michael Ossareh
4bcf88e99a feat: add onStatusChange callback (#2003) 2019-01-31 09:29:56 +01:00
Laurin Quast
22533ed8e8
feat: allow camera scene when audio permissions are denied (#2048), Fixes #2047, Fixes #2051 2019-01-18 15:58:48 +01:00
Andrew Schenk
d93a6c7e11 feat(android): add videoBitrate option for recordAsync (#2055) [skip release] 2019-01-18 15:48:42 +01:00
Laurin Quast
401c485db3
feat(rn-camera): deviceOrientation, videoOrientation, pictureOrientation
* feat(rn-camera): add deviceOrientation and videoOrientation to record response.

* feat(rn-camera): add deviceOrientation and pictureOrientation to take-picture-response

* fix(rn-camera): unify orientation handling for recording and takeing picture

* fix(types): adjust typescript types

* docs(rn-camra): document new properties

* fix(android): respect actual boolean value instead of only checking if it is present.

* feat(android): implement orientation prop for takePictureAsync

* feat(android): implement orientation prop for recordVideoAsync

* docs(rn-camera): adjust documentation

* fix(types): unmark properties as ios only

* fix(android): use constants
2018-12-12 15:04:08 +01:00
Laurin Quast
26300870ad
chore: format typescript typings with prettier (#1989) [skip ci] 2018-12-12 14:46:04 +01:00
Benas Svipas
54fedeedd3 feat(ios): add new method isRecording (#1969)
* feat: isRecording() to RNCamera which returns boolean

* docs: update RNCamera and typings
2018-12-05 17:38:33 +01:00
Cosmo Wolfe
4f3e4f126d fix(typings): add typescript typing for property defaultVideoQuality (#1907) 2018-11-07 09:19:49 +01:00
Cosmo Wolfe
d69d28b400 feat(qr-code): return raw barcode data if available (#1904) 2018-11-07 08:53:56 +01:00
Robert van Kints
7ee140bbdc feat(android): add inverted google vision barcode scanning (#1896) 2018-11-01 22:27:23 +01:00
João Marins
f0c18b7c20
chore(ts): add doNotSave to ts type definitions 2018-09-21 17:13:16 -03:00