FIRVisionBarcode.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. #import <CoreGraphics/CoreGraphics.h>
  2. #import <Foundation/Foundation.h>
  3. #import "FIRVisionBarcodeDetectorOptions.h"
  4. NS_ASSUME_NONNULL_BEGIN
  5. /**
  6. * @enum VisionBarcodeValueType
  7. * Barcode's value format. For example, TEXT, PRODUCT, URL, etc.
  8. */
  9. typedef NS_ENUM(NSInteger, FIRVisionBarcodeValueType) {
  10. /**
  11. * Unknown Barcode value types.
  12. */
  13. FIRVisionBarcodeValueTypeUnknown,
  14. /**
  15. * Barcode value type for contact info.
  16. */
  17. FIRVisionBarcodeValueTypeContactInfo,
  18. /**
  19. * Barcode value type for email addresses.
  20. */
  21. FIRVisionBarcodeValueTypeEmail,
  22. /**
  23. * Barcode value type for ISBNs.
  24. */
  25. FIRVisionBarcodeValueTypeISBN,
  26. /**
  27. * Barcode value type for phone numbers.
  28. */
  29. FIRVisionBarcodeValueTypePhone,
  30. /**
  31. * Barcode value type for product codes.
  32. */
  33. FIRVisionBarcodeValueTypeProduct,
  34. /**
  35. * Barcode value type for SMS details.
  36. */
  37. FIRVisionBarcodeValueTypeSMS,
  38. /**
  39. * Barcode value type for plain text.
  40. */
  41. FIRVisionBarcodeValueTypeText,
  42. /**
  43. * Barcode value type for URLs/bookmarks.
  44. */
  45. FIRVisionBarcodeValueTypeURL,
  46. /**
  47. * Barcode value type for Wi-Fi access point details.
  48. */
  49. FIRVisionBarcodeValueTypeWiFi,
  50. /**
  51. * Barcode value type for geographic coordinates.
  52. */
  53. FIRVisionBarcodeValueTypeGeographicCoordinates,
  54. /**
  55. * Barcode value type for calendar events.
  56. */
  57. FIRVisionBarcodeValueTypeCalendarEvent,
  58. /**
  59. * Barcode value type for driver's license data.
  60. */
  61. FIRVisionBarcodeValueTypeDriversLicense,
  62. } NS_SWIFT_NAME(VisionBarcodeValueType);
  63. /**
  64. * @enum VisionBarcodeAddressType
  65. * Address type.
  66. */
  67. typedef NS_ENUM(NSInteger, FIRVisionBarcodeAddressType) {
  68. /**
  69. * Barcode unknown address type.
  70. */
  71. FIRVisionBarcodeAddressTypeUnknown,
  72. /**
  73. * Barcode work address type.
  74. */
  75. FIRVisionBarcodeAddressTypeWork,
  76. /**
  77. * Barcode home address type.
  78. */
  79. FIRVisionBarcodeAddressTypeHome,
  80. } NS_SWIFT_NAME(VisionBarcodeAddressType);
  81. /**
  82. * @enum VisionBarcodeEmailType
  83. * Email type for VisionBarcodeEmail.
  84. */
  85. typedef NS_ENUM(NSInteger, FIRVisionBarcodeEmailType) {
  86. /**
  87. * Unknown email type.
  88. */
  89. FIRVisionBarcodeEmailTypeUnknown,
  90. /**
  91. * Barcode work email type.
  92. */
  93. FIRVisionBarcodeEmailTypeWork,
  94. /**
  95. * Barcode home email type.
  96. */
  97. FIRVisionBarcodeEmailTypeHome,
  98. } NS_SWIFT_NAME(VisionBarcodeEmailType);
  99. /**
  100. * @enum VisionBarcodePhoneType
  101. * Phone type for VisionBarcodePhone.
  102. */
  103. typedef NS_ENUM(NSInteger, FIRVisionBarcodePhoneType) {
  104. /**
  105. * Unknown phone type.
  106. */
  107. FIRVisionBarcodePhoneTypeUnknown,
  108. /**
  109. * Barcode work phone type.
  110. */
  111. FIRVisionBarcodePhoneTypeWork,
  112. /**
  113. * Barcode home phone type.
  114. */
  115. FIRVisionBarcodePhoneTypeHome,
  116. /**
  117. * Barcode fax phone type.
  118. */
  119. FIRVisionBarcodePhoneTypeFax,
  120. /**
  121. * Barcode mobile phone type.
  122. */
  123. FIRVisionBarcodePhoneTypeMobile,
  124. } NS_SWIFT_NAME(VisionBarcodePhoneType);
  125. /**
  126. * @enum VisionBarcodeWiFiEncryptionType
  127. * Wi-Fi encryption type for VisionBarcodeWiFi.
  128. */
  129. typedef NS_ENUM(NSInteger, FIRVisionBarcodeWiFiEncryptionType) {
  130. /**
  131. * Barcode unknown Wi-Fi encryption type.
  132. */
  133. FIRVisionBarcodeWiFiEncryptionTypeUnknown,
  134. /**
  135. * Barcode open Wi-Fi encryption type.
  136. */
  137. FIRVisionBarcodeWiFiEncryptionTypeOpen,
  138. /**
  139. * Barcode WPA Wi-Fi encryption type.
  140. */
  141. FIRVisionBarcodeWiFiEncryptionTypeWPA,
  142. /**
  143. * Barcode WEP Wi-Fi encryption type.
  144. */
  145. FIRVisionBarcodeWiFiEncryptionTypeWEP,
  146. } NS_SWIFT_NAME(VisionBarcodeWiFiEncryptionType);
  147. /**
  148. * An address.
  149. */
  150. NS_SWIFT_NAME(VisionBarcodeAddress)
  151. @interface FIRVisionBarcodeAddress : NSObject
  152. /**
  153. * Formatted address, containing multiple lines when appropriate.
  154. *
  155. * The parsing of address formats is quite limited. Typically all address information will appear
  156. * on the first address line. To handle addresses better, it is recommended to parse the raw data.
  157. * The raw data is available in `FIRVisionBarcode`'s `rawValue` property.
  158. */
  159. @property(nonatomic, readonly, nullable) NSArray<NSString *> *addressLines;
  160. /**
  161. * Address type.
  162. */
  163. @property(nonatomic, readonly) FIRVisionBarcodeAddressType type;
  164. /**
  165. * Unavailable.
  166. */
  167. - (instancetype)init NS_UNAVAILABLE;
  168. @end
  169. /**
  170. * A calendar event extracted from a QR code.
  171. */
  172. NS_SWIFT_NAME(VisionBarcodeCalendarEvent)
  173. @interface FIRVisionBarcodeCalendarEvent : NSObject
  174. /**
  175. * Calendar event description.
  176. */
  177. @property(nonatomic, readonly, nullable) NSString *eventDescription;
  178. /**
  179. * Calendar event location.
  180. */
  181. @property(nonatomic, readonly, nullable) NSString *location;
  182. /**
  183. * Clendar event organizer.
  184. */
  185. @property(nonatomic, readonly, nullable) NSString *organizer;
  186. /**
  187. * Calendar event status.
  188. */
  189. @property(nonatomic, readonly, nullable) NSString *status;
  190. /**
  191. * Calendar event summary.
  192. */
  193. @property(nonatomic, readonly, nullable) NSString *summary;
  194. /**
  195. * Calendar event start date.
  196. */
  197. @property(nonatomic, readonly, nullable) NSDate *start;
  198. /**
  199. * Calendar event end date.
  200. */
  201. @property(nonatomic, readonly, nullable) NSDate *end;
  202. /**
  203. * Unavailable.
  204. */
  205. - (instancetype)init NS_UNAVAILABLE;
  206. @end
  207. /**
  208. * A driver license or ID card data representation.
  209. *
  210. * An ANSI driver license contains more fields than are represented by this class. The
  211. * `FIRVisionBarcode`s `rawValue` property can be used to access the other fields.
  212. */
  213. NS_SWIFT_NAME(VisionBarcodeDriverLicense)
  214. @interface FIRVisionBarcodeDriverLicense : NSObject
  215. /**
  216. * Holder's first name.
  217. */
  218. @property(nonatomic, readonly, nullable) NSString *firstName;
  219. /**
  220. * Holder's middle name.
  221. */
  222. @property(nonatomic, readonly, nullable) NSString *middleName;
  223. /**
  224. * Holder's last name.
  225. */
  226. @property(nonatomic, readonly, nullable) NSString *lastName;
  227. /**
  228. * Holder's gender. 1 is male and 2 is female.
  229. */
  230. @property(nonatomic, readonly, nullable) NSString *gender;
  231. /**
  232. * Holder's city address.
  233. */
  234. @property(nonatomic, readonly, nullable) NSString *addressCity;
  235. /**
  236. * Holder's state address.
  237. */
  238. @property(nonatomic, readonly, nullable) NSString *addressState;
  239. /**
  240. * Holder's street address.
  241. */
  242. @property(nonatomic, readonly, nullable) NSString *addressStreet;
  243. /**
  244. * Holder's address' zipcode.
  245. */
  246. @property(nonatomic, readonly, nullable) NSString *addressZip;
  247. /**
  248. * Holder's birthday. The date format depends on the issuing country.
  249. */
  250. @property(nonatomic, readonly, nullable) NSString *birthDate;
  251. /**
  252. * "DL" for driver licenses, "ID" for ID cards.
  253. */
  254. @property(nonatomic, readonly, nullable) NSString *documentType;
  255. /**
  256. * Driver license ID number.
  257. */
  258. @property(nonatomic, readonly, nullable) NSString *licenseNumber;
  259. /**
  260. * Driver license expiration date. The date format depends on the issuing country.
  261. */
  262. @property(nonatomic, readonly, nullable) NSString *expiryDate;
  263. /**
  264. * The date format depends on the issuing country.
  265. */
  266. @property(nonatomic, readonly, nullable) NSString *issuingDate;
  267. /**
  268. * A country in which DL/ID was issued.
  269. */
  270. @property(nonatomic, readonly, nullable) NSString *issuingCountry;
  271. /**
  272. * Unavailable.
  273. */
  274. - (instancetype)init NS_UNAVAILABLE;
  275. @end
  276. /**
  277. * An email message from a 'MAILTO:' or similar QR Code type.
  278. */
  279. NS_SWIFT_NAME(VisionBarcodeEmail)
  280. @interface FIRVisionBarcodeEmail : NSObject
  281. /**
  282. * Email message address.
  283. */
  284. @property(nonatomic, readonly, nullable) NSString *address;
  285. /**
  286. * Email message body.
  287. */
  288. @property(nonatomic, readonly, nullable) NSString *body;
  289. /**
  290. * Email message subject.
  291. */
  292. @property(nonatomic, readonly, nullable) NSString *subject;
  293. /**
  294. * Email message type.
  295. */
  296. @property(nonatomic, readonly) FIRVisionBarcodeEmailType type;
  297. /**
  298. * Unavailable.
  299. */
  300. - (instancetype)init NS_UNAVAILABLE;
  301. @end
  302. /**
  303. * GPS coordinates from a 'GEO:' or similar QR Code type data.
  304. */
  305. NS_SWIFT_NAME(VisionBarcodeGeoPoint)
  306. @interface FIRVisionBarcodeGeoPoint : NSObject
  307. /**
  308. * A location latitude.
  309. */
  310. @property(nonatomic, readonly) double latitude;
  311. /**
  312. * A location longitude.
  313. */
  314. @property(nonatomic, readonly) double longitude;
  315. /**
  316. * Unavailable.
  317. */
  318. - (instancetype)init NS_UNAVAILABLE;
  319. @end
  320. /**
  321. * A person's name, both formatted and as individual name components.
  322. */
  323. NS_SWIFT_NAME(VisionBarcodePersonName)
  324. @interface FIRVisionBarcodePersonName : NSObject
  325. /**
  326. * Properly formatted name.
  327. */
  328. @property(nonatomic, readonly, nullable) NSString *formattedName;
  329. /**
  330. * First name.
  331. */
  332. @property(nonatomic, readonly, nullable) NSString *first;
  333. /**
  334. * Last name.
  335. */
  336. @property(nonatomic, readonly, nullable) NSString *last;
  337. /**
  338. * Middle name.
  339. */
  340. @property(nonatomic, readonly, nullable) NSString *middle;
  341. /**
  342. * Name prefix.
  343. */
  344. @property(nonatomic, readonly, nullable) NSString *prefix;
  345. /**
  346. * Designates a text string to be set as the kana name in the phonebook.
  347. * Used for Japanese contacts.
  348. */
  349. @property(nonatomic, readonly, nullable) NSString *pronounciation;
  350. /**
  351. * Name suffix.
  352. */
  353. @property(nonatomic, readonly, nullable) NSString *suffix;
  354. /**
  355. * Unavailable.
  356. */
  357. - (instancetype)init NS_UNAVAILABLE;
  358. @end
  359. /**
  360. * A phone number from a 'TEL:' or similar QR Code type.
  361. */
  362. NS_SWIFT_NAME(VisionBarcodePhone)
  363. @interface FIRVisionBarcodePhone : NSObject
  364. /**
  365. * Phone number.
  366. */
  367. @property(nonatomic, readonly, nullable) NSString *number;
  368. /**
  369. * Phone number type.
  370. */
  371. @property(nonatomic, readonly) FIRVisionBarcodePhoneType type;
  372. /**
  373. * Unavailable.
  374. */
  375. - (instancetype)init NS_UNAVAILABLE;
  376. @end
  377. /**
  378. * An SMS message from an 'SMS:' or similar QR Code type.
  379. */
  380. NS_SWIFT_NAME(VisionBarcodeSMS)
  381. @interface FIRVisionBarcodeSMS : NSObject
  382. /**
  383. * An SMS message body.
  384. */
  385. @property(nonatomic, readonly, nullable) NSString *message;
  386. /**
  387. * An SMS message phone number.
  388. */
  389. @property(nonatomic, readonly, nullable) NSString *phoneNumber;
  390. /**
  391. * Unavailable.
  392. */
  393. - (instancetype)init NS_UNAVAILABLE;
  394. @end
  395. /**
  396. * A URL and title from a 'MEBKM:' or similar QR Code type.
  397. */
  398. NS_SWIFT_NAME(VisionBarcodeURLBookmark)
  399. @interface FIRVisionBarcodeURLBookmark : NSObject
  400. /**
  401. * A URL bookmark title.
  402. */
  403. @property(nonatomic, readonly, nullable) NSString *title;
  404. /**
  405. * A URL bookmark url.
  406. */
  407. @property(nonatomic, readonly, nullable) NSString *url;
  408. /**
  409. * Unavailable.
  410. */
  411. - (instancetype)init NS_UNAVAILABLE;
  412. @end
  413. /**
  414. * Wi-Fi network parameters from a 'WIFI:' or similar QR Code type.
  415. */
  416. NS_SWIFT_NAME(VisionBarcodeWifi)
  417. @interface FIRVisionBarcodeWiFi : NSObject
  418. /**
  419. * A Wi-Fi access point SSID.
  420. */
  421. @property(nonatomic, readonly, nullable) NSString *ssid;
  422. /**
  423. * A Wi-Fi access point password.
  424. */
  425. @property(nonatomic, readonly, nullable) NSString *password;
  426. /**
  427. * A Wi-Fi access point encryption type.
  428. */
  429. @property(nonatomic, readonly) FIRVisionBarcodeWiFiEncryptionType type;
  430. /**
  431. * Unavailable.
  432. */
  433. - (instancetype)init NS_UNAVAILABLE;
  434. @end
  435. /**
  436. * A person's or organization's business card. This may come from different underlying formats
  437. * including VCARD and MECARD.
  438. *
  439. * This object represents a simplified view of possible business cards. If you require lossless
  440. * access to the information in the barcode, you should parse the raw data yourself. To access the
  441. * raw data, use the `FIRVisionBarcode`s `rawValue` property.
  442. */
  443. NS_SWIFT_NAME(VisionBarcodeContactInfo)
  444. @interface FIRVisionBarcodeContactInfo : NSObject
  445. /**
  446. * Person's or organization's addresses.
  447. */
  448. @property(nonatomic, readonly, nullable) NSArray<FIRVisionBarcodeAddress *> *addresses;
  449. /**
  450. * Contact emails.
  451. */
  452. @property(nonatomic, readonly, nullable) NSArray<FIRVisionBarcodeEmail *> *emails;
  453. /**
  454. * A person's name.
  455. */
  456. @property(nonatomic, readonly, nullable) FIRVisionBarcodePersonName *name;
  457. /**
  458. * Contact phone numbers.
  459. */
  460. @property(nonatomic, readonly, nullable) NSArray<FIRVisionBarcodePhone *> *phones;
  461. /**
  462. * Contact URLs.
  463. */
  464. @property(nonatomic, readonly, nullable) NSArray<NSString *> *urls;
  465. /**
  466. * A job title.
  467. */
  468. @property(nonatomic, readonly, nullable) NSString *jobTitle;
  469. /**
  470. * A business organization.
  471. */
  472. @property(nonatomic, readonly, nullable) NSString *organization;
  473. /**
  474. * Unavailable.
  475. */
  476. - (instancetype)init NS_UNAVAILABLE;
  477. @end
  478. /**
  479. * A barcode in an image.
  480. */
  481. NS_SWIFT_NAME(VisionBarcode)
  482. @interface FIRVisionBarcode : NSObject
  483. /**
  484. * The rectangle that holds the discovered relative to the detected image in the view
  485. * coordinate system.
  486. */
  487. @property(nonatomic, readonly) CGRect frame;
  488. /**
  489. * A barcode value as it was encoded in the barcode. Structured values are not parsed, for example:
  490. * 'MEBKM:TITLE:Google;URL:https://www.google.com;;'. Does not include the supplemental value.
  491. */
  492. @property(nonatomic, readonly, nullable) NSString *rawValue;
  493. /**
  494. * A barcode value in a user-friendly format. May omit some of the information encoded in the
  495. * barcode. For example, in the case above the display value might be 'https://www.google.com'.
  496. * If valueType == .text, this field will be equal to rawValue. This value may be multiline,
  497. * for example, when line breaks are encoded into the original TEXT barcode value. May include
  498. * the supplement value.
  499. */
  500. @property(nonatomic, readonly, nullable) NSString *displayValue;
  501. /**
  502. * A barcode format; for example, EAN_13. Note that if the format is not in the list,
  503. * VisionBarcodeFormat.unknown would be returned.
  504. */
  505. @property(nonatomic, readonly) FIRVisionBarcodeFormat format;
  506. /**
  507. * The four corner points of the barcode, in clockwise order starting with the top left relative
  508. * to the detected image in the view coordinate system. These are CGPoints boxed in NSValues.
  509. * Due to the possible perspective distortions, this is not necessarily a rectangle.
  510. */
  511. @property(nonatomic, readonly, nullable) NSArray<NSValue *> *cornerPoints;
  512. /**
  513. * A type of the barcode value. For example, TEXT, PRODUCT, URL, etc. Note that if the type is not
  514. * in the list, .unknown would be returned.
  515. */
  516. @property(nonatomic, readonly) FIRVisionBarcodeValueType valueType;
  517. /**
  518. * An email message from a 'MAILTO:' or similar QR Code type. This property is only set if
  519. * valueType is .email.
  520. */
  521. @property(nonatomic, readonly, nullable) FIRVisionBarcodeEmail *email;
  522. /**
  523. * A phone number from a 'TEL:' or similar QR Code type. This property is only set if valueType
  524. * is .phone.
  525. */
  526. @property(nonatomic, readonly, nullable) FIRVisionBarcodePhone *phone;
  527. /**
  528. * An SMS message from an 'SMS:' or similar QR Code type. This property is only set if valueType
  529. * is .sms.
  530. */
  531. @property(nonatomic, readonly, nullable) FIRVisionBarcodeSMS *sms;
  532. /**
  533. * A URL and title from a 'MEBKM:' or similar QR Code type. This property is only set if
  534. * valueType is .url.
  535. */
  536. @property(nonatomic, readonly, nullable) FIRVisionBarcodeURLBookmark *URL;
  537. /**
  538. * Wi-Fi network parameters from a 'WIFI:' or similar QR Code type. This property is only set
  539. * if valueType is .wifi.
  540. */
  541. @property(nonatomic, readonly, nullable) FIRVisionBarcodeWiFi *wifi;
  542. /**
  543. * GPS coordinates from a 'GEO:' or similar QR Code type. This property is only set if valueType
  544. * is .geo.
  545. */
  546. @property(nonatomic, readonly, nullable) FIRVisionBarcodeGeoPoint *geoPoint;
  547. /**
  548. * A person's or organization's business card. For example a VCARD. This property is only set
  549. * if valueType is .contactInfo.
  550. */
  551. @property(nonatomic, readonly, nullable) FIRVisionBarcodeContactInfo *contactInfo;
  552. /**
  553. * A calendar event extracted from a QR Code. This property is only set if valueType is
  554. * .calendarEvent.
  555. */
  556. @property(nonatomic, readonly, nullable) FIRVisionBarcodeCalendarEvent *calendarEvent;
  557. /**
  558. * A driver license or ID card. This property is only set if valueType is .driverLicense.
  559. */
  560. @property(nonatomic, readonly, nullable) FIRVisionBarcodeDriverLicense *driverLicense;
  561. /**
  562. * Unavailable.
  563. */
  564. - (instancetype)init NS_UNAVAILABLE;
  565. @end
  566. NS_ASSUME_NONNULL_END