From 42eb990eb1ed215635d1c0caba739e624e4a836a Mon Sep 17 00:00:00 2001 From: Zhiyuan Li Date: Mon, 18 Dec 2017 15:36:01 -0800 Subject: [PATCH] OSDK 3.5: Accessing live video from the FPV camera and main camera of M210 and M210 RTK is now possible! --- EULA.txt | 53 ++ License.txt | 466 ++++++++++++++++++ README.md | 19 +- osdk-core/CMakeLists.txt | 16 +- .../DownloadProject.CMakeLists.cmake.in | 17 + .../DownloadProject/DownloadProject.cmake | 182 +++++++ .../External_AdvancedSensing.cmake | 2 +- .../cmake-modules/FindAdvancedSensing.cmake | 8 +- osdk-core/cmake-modules/FindFFMPEG.cmake | 181 +++++++ osdk-core/hal/inc/dji_log.hpp | 16 +- osdk-core/hal/src/dji_log.cpp | 18 + sample/linux/advanced-sensing/CMakeLists.txt | 63 +-- .../CMakeLists.txt | 34 ++ .../camera-stream-callback-sample.cpp | 107 ++++ .../camera_stream_poll_sample/CMakeLists.txt | 33 ++ .../camera-stream-poll-sample.cpp | 144 ++++++ .../CMakeLists.txt | 64 +++ .../target_tracking.cpp | 178 +++++++ .../tracking_utility.cpp | 94 ++++ .../tracking_utility.hpp | 56 +++ .../CMakeLists.txt | 37 ++ .../advanced_sensing_multi_thread_sample.cpp | 0 .../advanced_sensing_multi_thread_sample.hpp | 5 +- .../image_process_container.cpp | 0 .../image_process_container.hpp | 5 +- .../utility_thread.cpp | 0 .../utility_thread.hpp | 0 .../CMakeLists.txt | 34 ++ .../advanced_sensing_sample.cpp | 0 .../advanced_sensing_sample.hpp | 5 +- 30 files changed, 1759 insertions(+), 78 deletions(-) create mode 100644 EULA.txt create mode 100644 License.txt create mode 100644 osdk-core/cmake-modules/DownloadProject/DownloadProject.CMakeLists.cmake.in create mode 100644 osdk-core/cmake-modules/DownloadProject/DownloadProject.cmake create mode 100644 osdk-core/cmake-modules/FindFFMPEG.cmake create mode 100644 sample/linux/advanced-sensing/camera_stream_callback_sample/CMakeLists.txt create mode 100644 sample/linux/advanced-sensing/camera_stream_callback_sample/camera-stream-callback-sample.cpp create mode 100644 sample/linux/advanced-sensing/camera_stream_poll_sample/CMakeLists.txt create mode 100644 sample/linux/advanced-sensing/camera_stream_poll_sample/camera-stream-poll-sample.cpp create mode 100644 sample/linux/advanced-sensing/camera_stream_target_tracking_sample/CMakeLists.txt create mode 100644 sample/linux/advanced-sensing/camera_stream_target_tracking_sample/target_tracking.cpp create mode 100644 sample/linux/advanced-sensing/camera_stream_target_tracking_sample/tracking_utility.cpp create mode 100644 sample/linux/advanced-sensing/camera_stream_target_tracking_sample/tracking_utility.hpp create mode 100644 sample/linux/advanced-sensing/stereo_vision_multi_thread_sample/CMakeLists.txt rename sample/linux/advanced-sensing/{ => stereo_vision_multi_thread_sample}/advanced_sensing_multi_thread_sample.cpp (100%) rename sample/linux/advanced-sensing/{ => stereo_vision_multi_thread_sample}/advanced_sensing_multi_thread_sample.hpp (95%) rename sample/linux/advanced-sensing/{ => stereo_vision_multi_thread_sample}/image_process_container.cpp (100%) rename sample/linux/advanced-sensing/{ => stereo_vision_multi_thread_sample}/image_process_container.hpp (96%) rename sample/linux/advanced-sensing/{ => stereo_vision_multi_thread_sample}/utility_thread.cpp (100%) rename sample/linux/advanced-sensing/{ => stereo_vision_multi_thread_sample}/utility_thread.hpp (100%) create mode 100644 sample/linux/advanced-sensing/stereo_vision_single_thread_sample/CMakeLists.txt rename sample/linux/advanced-sensing/{ => stereo_vision_single_thread_sample}/advanced_sensing_sample.cpp (100%) rename sample/linux/advanced-sensing/{ => stereo_vision_single_thread_sample}/advanced_sensing_sample.hpp (94%) diff --git a/EULA.txt b/EULA.txt new file mode 100644 index 00000000..0749bfae --- /dev/null +++ b/EULA.txt @@ -0,0 +1,53 @@ +END USER LICENSE AGREEMENT +YOU AGREE TO USE THE SDK SOLELY IN ACCORDANCE WITH THE TERMS AND CONDITIONS OF THIS END USER LICENSE AGREEMENT (THE “AGREEMENT”), AND YOU AGREE THAT YOU ARE BOUND BY AND ARE A PARTY TO THIS AGREEMENT. YOU WARRANT THAT YOU ARE AT LEAST EIGHTEEN YEARS OLD AND THAT YOU HAVE THE LEGAL CAPACITY TO ENTER INTO CONTRACTS. IF YOU ARE AGREEING TO BE BOUND BY THIS AGREEMENT ON BEHALF OF A COMPANY, ORGANIZATION, OR OTHER ENTITY, THEN (i) “YOU” INCLUDES YOU AND THAT COMPANY, ORGANIZATION OR ENTITY, AND (ii) YOU REPRESENT AND WARRANT THAT YOU ARE AN AUTHORIZED REPRESENTATIVE OF SUCH COMPANY, ORGANIZATION OR ENTITY WITH THE AUTHORITY TO BIND SUCH COMPANY, ORGANIZATION OR ENTITY TO THIS AGREEMENT. +YOUR USE OF THE SDK IS EXPRESSLY CONDITIONED ON YOUR ACCEPTANCE OF THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT, YOU MAY NOT INSTALL OR USE THE SDK. + 1. About This Agreement. + 1.1 Generally. This Agreement applies to the SDK made available by DJI to you. + 1.2 Additional Terms. Certain additional and/or different terms may apply to certain types of users. If you are a federal, state, or local government entity (including but not limited to any agency or other sub-governmental organization thereof) utilizing the SDK in your official capacity, and to whom DJI has agreed to provide the SDK, then our Government Terms apply to you. + 2. Definitions +“Analytics Data” means information collected from a DJI Product (e.g., a DJI UAV) that is used in connection with an Application and/or devices used to operate the DJI Product (e.g., a mobile device). The Analytics Data may include Header Data and/or Event Data. Analytics Data may be used by DJI for any lawful purpose, including without limitation, for research or to improve its SDK or DJI Products. +“Application” means a software program that is developed by you using the SDK for use with DJI Products. +“Confidential Information” means the SDK and all other information disclosed to you by DJI that would reasonably be considered to be confidential, or is or was considered by DJI to be confidential, except for information which you can demonstrate: (a) is previously rightfully known to you without restriction on disclosure; (b) is or becomes, from no act or failure to act on your part, generally known in the relevant industry or public domain; (c) is disclosed to you by a third-party as a matter of right and without restriction on disclosure; or (d) is or was independently developed by you without access to, use of, or reference to the Confidential Information. +“Documentation” means any online read me, help files, technical specifications, or other related explanatory materials that are contained in the SDK or that accompany the SDK. +“DJI” means SZ DJI TECHNOLOGY CO., LTD. and its affiliates. +“DJI Products” means DJI hardware, software, and services, such as unmanned aerial vehicles (UAVs), flight controllers, sensors, cameras, gimbals, remote controllers, accessories, etc. +“Event Data” means information about time of operation or events, session identification numbers, event types, and flight operation information, including but not limited to GPS data, navigation, operation, speed, distance, modes, mission, command, altitude, takeoff and landing, payload and other component use, battery levels, etc. +“Header Data” means information about the software (including but not limited to installation identification, app key, SDK version of an Application) and hardware (including but not limited to product identifiers and names of UAVs, payloads, remote controllers, etc.). +“Licensee Disclosure” means any information that you may provide to DJI in connection with this Agreement, including, for example, feedback on errors and improvements within or relating to the SDK. +“Privacy Policy” means DJI’s privacy policy located at https://developer.dji.com/policies/privacy/. +“SDK” or “Software Development Kit” means software (source code and object code), applications, tools, sample code, templates, fonts, logos, icons, images, libraries, interfaces, Updates, Documentation, application programming interfaces (APIs), information, data, files, and other materials, whether tangible or intangible, in whatever form or medium provided to you by DJI for use by you in connection with your Application. For the purpose of this Agreement, SDK includes, without limitation, (a) the DJI “Guidance” software development kit (https://developer.dji.com/guidance-sdk/), (b) the DJI “Mobile” software development kit (https://developer.dji.com/mobile-sdk/), and/or (c) the DJI “Onboard” software development kit (https://developer.dji.com/onboard-sdk/). +“Open-Source Component” means software, interfaces and firmware subject to an open-source software license, which means any software license approved as open-source licenses by the Open Source Initiative or any substantially similar licenses, including without limitation any license that, as a condition of distribution of the software licensed under such license, requires that the distributor make the software available in source code format. +“Third-Party Component” means software, interfaces and firmware licensed by DJI from a third-party (e.g., a supplier of DJI) for incorporation into the SDK and distributed as an integral part of the SDK, as applicable. Third-Party Components may include Open-Source Components. +“Updates” means bug fixes, service packs, hot fixes, updates, upgrades, enhancements, modifications, and new releases of versions of the SDK. +“Warranty Logs” means information provided to and/or received by the SDK that is necessary for determining warranty eligibility and product reliability, including without limitation SDK function calls (including without limitation time, function name, results/feedback, etc.), protocol or commands sent from or to a mobile device, an Application, and/or a remote controller (including without limitation time, name, type, command/action, etc.). + + 3. License. + 3.1 License Grants. The SDK is licensed, not sold, to you by DJI and/or, if applicable, its suppliers and licensors. Subject to the terms and conditions of this Agreement, you are hereby granted a limited, worldwide, non-exclusive, non-sublicensable, and nontransferable right to use the SDK solely in the manner described in the Documentation and solely to develop, test, and operate Applications in connection with DJI products. + 3.2 Use Restrictions. You may not use the SDK except as permitted in this Agreement and any additional terms and conditions that DJI provides pursuant to Section 3.1. Except with DJI’s prior written consent or otherwise provided herein, you may not: (a) alter, modify or create any derivative works of the SDK, including the underlying source code, or the Documentation in any way, including without limitation customization, translation or localization; (b) port, reverse compile, reverse assemble, reverse engineer, or otherwise attempt to separate any of the components of the SDK or derive the source code for the SDK (except to the extent applicable laws specifically prohibit such restriction); (c) copy, redistribute, encumber, sell, rent, lease, sublicense, or otherwise transfer rights to the SDK; (d) remove or alter any trademark, logo, copyright or other proprietary notices, legends, symbols or labels in the SDK; (e) block, disable, or otherwise affect any advertising, advertisement banner window, links to other sites and services, or other features that constitute an integral part of the SDK; or (f) use any part of the SDK to develop applications for use with hardware devices that are not DJI Products, unless they are the devices running the applications or are devices connected (directly or indirectly) to DJI Product(s) the SDK interfaces with. You may not release the results of any performance or functional evaluation of any of the SDK to any third-party without prior written approval of DJI for each such release. You may not cause or permit any third-party to do any of the foregoing. + 3.3 Distribution of Object Code. You may distribute your Application with object code of the SDK, provided that you must: (1) distribute such object code of the SDK in execution form only; (2) distribute such code only as a part of your Applications; (3) not distribute any portion of the SDK that is not object code, including but not limited to source code, header files and Documentation; (4) not charge a separate price or fee for the object code of the SDK that is distinct from the fee you charge for your Application; (5) not distribute, link, or integrate the object code of the SDK such that any part of the object code of the SDK becomes subject to an open source license; and (6) include the following copyright notice within your Application’s source code in the same locations as your own copyright notice: “Portions copyright (c) 2014–Present DJI. All rights reserved.”. To the extent that any source code is provided to you as part of the SDK, you may use, modify and compile the source code solely for the purposes of developing your Applications. + 3.4 Third-Party Components. You acknowledge that the SDK may contain Third-Party Components. All third-party licensors and suppliers retain all right, title and interest in and to such Third-Party Components and all copies thereof, including all copyright and other intellectual property rights. Your use of any Third-Party Components shall be subject to, and you shall comply with, the terms and conditions of this Agreement, and the applicable restrictions and other terms and conditions set forth in any Third-Party Components documentation or printed materials, including without limitation an end user license agreement. + 3.5 Open-Source Components. The SDK may include Open-Source Components that are subject to open-source software licenses. The Documentation accompanying the SDK includes copies of the licenses applicable to the Open-Source Components. To the extent there is conflict between the license terms covering the Open-Source Components and this Agreement, the terms of such licenses will apply in lieu of the terms of this Agreement. To the extent the terms of the licenses applicable to Open-Source Components prohibit any of the restrictions in this Agreement with respect to such Open-Source Component, such restrictions will not apply to such Open-Source Component. + 4. Reservation of Rights. DJI and its licensors reserve all rights, including but not limited to ownership and intellectual property rights, including in the SDK, not expressly granted to you. DJI’s licensors are the intended third-party beneficiaries of this Agreement and have the express right to rely upon and directly enforce the terms set forth herein. There are no implied licenses granted by DJI under this Agreement. Except as specified above, you shall have no rights to the SDK. You acknowledge and agree that the form and nature of the SDK that DJI provides may change without prior notice to you and that future versions of the SDK may be incompatible with Applications developed on previous versions of the SDK. You acknowledge and agree that DJI may stop providing the SDK or any features of the SDK permanently or temporarily to you or users generally at DJI’s sole discretion, without prior notice to you. If the SDK is a “beta” release, you acknowledge and agree that the SDK is a “beta” release for evaluation purposes only and may contain bugs, defects and errors and that the SDK may fail, return inaccurate results, and/or be subject to other malfunctions. + 5. Your Applications and Use of the SDK. + 5.1 Rights in Your Applications. Subject to Section 4 above, DJI agrees that it obtains no right, title, or interest from you (or your licensors) under this Agreement in or to any Applications that you develop using the SDK, including any sole and separate intellectual property rights of yours that subsist in those Applications. + 5.2 Permitted Applications. You agree to use the SDK and develop Applications solely for purposes that are permitted by: (a) this Agreement; (b) the DJI Developer Policy available at https://developer.dji.com/policies/developer/; and (c) any applicable law, rule, regulation, or generally accepted practice or guideline in the relevant jurisdiction, including but not limited to laws, rules, or regulations regarding the export of data or software to and from the United States or other relevant countries, and national, public, and personal security. + 5.3 Your Responsibilities. You agree that you are solely responsible for, and that DJI has no responsibility to you or any third-party for, or access to: (a) any data, content, or resources that you create, transmit, or display through the Applications you develop on or with the SDK (whether originating with you or a third-party), and for the consequences of your actions (including any loss or damage suffered by DJI) by doing so; and (b) any breach of your obligations under this Agreement, any applicable third-party contract or terms of service, or any applicable law, rule, or regulation, and for the consequences (including any loss or damage suffered by DJI) of any such breach. + 5.4 Compliance with Law; Safety. For the avoidance of doubt, you agree that you shall at all times strictly comply with all applicable laws, rules and regulations and shall not threaten the safety of national security, public security, or the health, privacy, or safety of any person. + 6. Privacy and Automatically Collected Information. + 6.1 SDK Use and User Information. In order to continually improve the SDK, DJI may automatically collect certain usage statistics including, but not limited to, unique identifiers, associated IP address, and other information on which tools and services in the SDK are being used and how they are being used. This data is collected in the aggregate to improve the SDK and is maintained in accordance with DJI’s Privacy Policy. We may also collect certain personal information from you, including but not limited to your legal name, mailing address, phone number, email address, and other contact or personal information. We may also collect additional information in order to verify your identity or provide certain functions. This information will be maintained in accordance with DJI’s Privacy Policy, and you hereby agree that we may share this information with our third-party business partners for purposes of verifying your identity or provide certain functions and as otherwise permitted by our Privacy Policy. + 6.2 Application User Information. The SDK may automatically collect Analytics Data, such as Header Data and/or Event Data. The Analytics Data may be provided to DJI and used by DJI for any use in research or improving its SDK or DJI Products. The Analytics Data may be used by DJI for any lawful purpose, including without limitation, for research or to improve its SDK or DJI Products. Certain SDK (e.g., Mobile SDK) may also automatically collect Warranty Log information, for example, for the purpose of determining warranty eligibility and product reliability. The Warranty Logs are stored locally on a device running the Application (e.g., mobile device) and are not automatically transmitted to DJI without prior user consent. You may be required to make the Warranty Logs available to DJI to support any warranty claims regarding the SDK. By using the SDK and creating an Application, you represent and warrant that you will provide clear and conspicuous notice to each user of the Application of the automatic collection, storage, and DJI’s use of the Analytics Data and Warranty Logs, and that you will obtain any legally-required consents for DJI to receive and use the Analytics Data and Warranty Logs for the purposes specified herein. The Application User Information is maintained in accordance with DJI’s Privacy Policy located at https://developer.dji.com/policies/privacy/. + 7. Proprietary Rights. You acknowledge and agree that the SDK belongs to DJI or its licensors. You agree that you neither own nor hereby acquire any claim or right of ownership to the SDK or to any related patents, copyrights, trademarks, or other intellectual property. DJI and its licensors retain all right, title, and interest in and to all copies of the SDK at all times, regardless of the form or media in or on which the original or other copies may subsequently exist. This license is not a sale of the original or any subsequent copy. The SDK is protected by copyright and other intellectual property laws and by international treaties. You may not make any copies of the SDK except as otherwise permitted by this Agreement. Any and all other copies of the SDK made by you are in violation of this license. All content accessed through the SDK is the property of the applicable content owner and may be protected by applicable copyright law. This license gives you no rights to such content. All trademarks used in connection with the SDK are owned by DJI, its affiliates and/or its licensors and other suppliers, and no license to use any such trademarks is provided hereunder. + 8. Information Submitted to DJI Not Deemed Confidential. DJI works with many application developers and some of their products may be similar to or compete with Your Applications. DJI may also be developing its own similar or competing applications, or may decide to do so in the future. To avoid potential misunderstandings, DJI CANNOT AGREE, AND EXPRESSLY DISCLAIMS, ANY CONFIDENTIALITY OBLIGATIONS OR USE RESTRICTIONS, EXPRESS OR IMPLIED, WITH RESPECT TO ANY LICENSEE DISCLOSURE. Such licensee disclosure may include, for example, feedback on errors and improvements within or relating to the SDK. You agree any such licensee disclosure will be non-confidential. DJI will be free to use and disclose any licensee disclosure on an unrestricted basis without notifying or compensating you. You release DJI from all liability and obligations that may arise from the receipt, review, use, or disclosure of any portion of any licensee disclosure. Any physical materials you submit to DJI will become DJI property and DJI will have no obligation to return those materials to you or to certify their destruction. + 9. No Support. This Agreement does not entitle you to receive from DJI or its licensors hard-copy documentation, support, telephone assistance, or enhancements or updates to the SDK. + 10. Term and Termination. This Agreement and your right to use the SDK may be terminated by you or by DJI at any time upon written notice. This Agreement automatically terminates if you fail to comply with its terms and conditions. Immediately upon termination, you shall return or destroy all copies of the SDK in your possession, custody, or control and, if requested by DJI, you shall certify to DJI in writing that such return or destruction has occurred. The following Sections of this Agreement survive any expiration or termination hereof: 1, 2, 3.2, 3.3, 3.4, 3.5, and 4 through 18 (inclusive). + 11. No warranty. YOU AGREE THAT THE SDK IS PROVIDED “AS IS” AND THAT DJI AND ITS LICENSORS MAKE NO OTHER WARRANTY AS TO THE SDK, INCLUDING, BUT NOT LIMITED TO, UNINTERRUPTED USE, ACCURACY, AND DATA LOSS. DJI AND ITS LICENSORS DISCLAIM ALL OTHER WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, PRIVACY, SECURITY, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE (EVEN IF DJI KNOWS OR SHOULD HAVE KNOWN OF SUCH PURPOSE), RELATED TO THE SDK, ITS USE OR ANY INABILITY TO USE IT, THE RESULTS OF ITS USE AND THIS AGREEMENT. DJI AND ITS LICENSORS DO NOT WARRANT THAT THE SDK OR ANY RESULTS OF USE THEREOF WILL BE FREE OF DEFECTS, ERRORS OR VIRUSES, RELIABLE OR ABLE TO OPERATE ON AN UNINTERRUPTED BASIS OR IN A PARTICULAR ENVIRONMENT OR THAT ERRORS THEREIN, IF ANY, WILL BE CORRECTED. + 12. Limitation of Liability. TO THE FULLEST EXTENT PERMITTED BY LAW, DJI AND ITS AFFILIATES AND LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES, WHETHER IN CONTRACT OR TORT (INCLUDING NEGLIGENCE) OR ANY OTHER LEGAL OR EQUITABLE THEORY, ARISING FROM THIS AGREEMENT AND/OR YOUR USE OF THE SDK OR DEVELOPMENT OR DISTRIBUTION OF ANY APPLICATION, INCLUDING WITHOUT LIMITATION ANY INDIRECT, CONSEQUENTIAL, SPECIAL, EXEMPLARY, INCIDENTAL DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. YOU AGREE THAT YOU SHALL HAVE THE SOLE RESPONSIBILITY FOR PROTECTING YOUR DATA, BY PERIODIC BACKUP OR OTHERWISE, USED IN CONNECTION WITH THE SDK. IN ANY CASE, DJI AND ITS AFFILIATES AND LICENSORS’ SOLE LIABILITY AND YOUR EXCLUSIVE REMEDY UNDER ANY PROVISION OF THIS AGREEMENT SHALL BE TO STOP USING THE SDK, WITH THE EXCEPTION OF DEATH OR PERSONAL INJURY CAUSED BY THE SOLE NEGLIGENCE OF DJI, AND SOLELY TO THE EXTENT APPLICABLE LAW PROHIBITS THE LIMITATION OF DAMAGES IN SUCH CASES. + 13. Indemnification. TO THE MAXIMUM EXTENT PERMITTED BY LAW, YOU AGREE TO DEFEND, INDEMNIFY, AND HOLD HARMLESS DJI, ITS AFFILIATES AND THEIR RESPECTIVE DIRECTORS, OFFICERS, EMPLOYEES, AND AGENTS FROM AND AGAINST ANY AND ALL CLAIMS, ACTIONS, SUITS, OR PROCEEDINGS, AS WELL AS ANY AND ALL LOSSES, LIABILITIES, DAMAGES, COSTS, AND EXPENSES (INCLUDING REASONABLE ATTORNEYS’ FEES) ARISING OUT OF OR ACCRUING FROM: (A) YOUR USE OF THE SDK, INCLUDING THIRD-PARTY SOFTWARE AND/OR DOCUMENTATION; (B) ANY APPLICATION YOU DEVELOP ON OR WITH THE SDK THAT IS ALLEGED TO OR DETERMINED TO INFRINGE ANY PATENT, COPYRIGHT, TRADEMARK, OR OTHER INTELLECTUAL PROPERTY OR PROPRIETARY RIGHT OF A THIRD PARTY; AND (C) YOUR NONCOMPLIANCE WITH ANY TERM OF THIS AGREEMENT, EXCEPT FOR DEATH OR PERSONAL INJURY CAUSED BY THE SOLE NEGLIGENCE OF DJI. + 14. Confidentiality. You shall use your best efforts to preserve and protect the confidentiality of the Confidential Information at all times, both during the term hereof and for a period of at least 3 years after termination of this Agreement, provided, however, that any source code you receive shall be held in confidence in perpetuity. You shall not disclose, disseminate, or otherwise publish or communicate Confidential Information to any person, firm, corporation or other third-party without the prior written consent of DJI. You shall not use any Confidential Information other than in the course of the activities permitted hereunder. You agree to use your best efforts to prevent and protect the contents of the SDK from unauthorized disclosure or use. You shall notify DJI in writing immediately upon discovery of any unauthorized use or disclosure of Confidential Information or any other breach of this Agreement, and will cooperate with DJI in every reasonable way to regain possession of Confidential Information and prevent any further unauthorized use. +If you are legally compelled to disclose any of the Confidential Information, then, prior to such disclosure, you will (i) immediately notify DJI prior to such disclosure to allow DJI an opportunity to contest the disclosure, (ii) assert the privileged and confidential nature of the Confidential Information, and (iii) cooperate fully with DJI in protecting against any such disclosure and/or obtaining a protective order narrowing the scope of such disclosure and/or use of the Confidential Information. In the event such protection is not obtained, you shall disclose the Confidential Information only to the extent necessary to comply with the applicable legal requirements. + 15. Injunctive Relief. You acknowledge and agree that your breach or threatened breach of this Agreement shall cause DJI irreparable damage for which recovery of money damages would be inadequate and that DJI therefore may obtain timely injunctive relief to protect its rights under this Agreement in addition to any and all other remedies available at law or in equity. + 16. Export Controls. The SDK and the underlying information and technology may not be downloaded or otherwise exported or re-exported (a) into (or to a national or resident of) any country to which the U.S. has embargoed goods; or (b) to or through or involve any party on any U.S. government screening or prohibited list (including those as updated from time-to-time on the U.S. Consolidated Screening List (available at http://export.gov/ecr/eg_main_023148.asp). By downloading or using the SDK and/or Documentation, you are agreeing to the foregoing and you represent and warrant that you are not located in, under the control of, or a national or resident of any such country or on any such list and you agree to comply with all export laws and other applicable laws. + 17. Miscellaneous. (a) This Agreement, together with any amendments and any additional agreements you may enter into with DJI in connection with the use of SDK, shall constitute the entire agreement between the parties concerning the subject matter hereof, which may only be modified by a written amendment signed by an authorized executive of DJI. (b) Any dispute, controversy, difference or claim arising out of or relating to this contract, including the existence, validity, interpretation, performance, breach or termination thereof or any dispute regarding non-contractual obligations arising out of or relating to it shall be referred to and finally resolved by arbitration administered by the Hong Kong International Arbitration Centre (“HKIAC”) under the HKIAC Administered Arbitration Rules in force when the Notice of Arbitration is submitted. The law of this arbitration clause shall be Hong Kong law, excluding its conflict of law provisions. The seat of arbitration shall be Hong Kong. The number of arbitrators shall be three (3) in accordance with such rules. The arbitration proceedings shall be conducted in English. Any awards of shall be final and binding upon the applicable parties. (c) This Agreement shall not be governed by the United Nations Convention on Contracts for the International Sale of Goods. (d) If any part of this Agreement is held invalid or unenforceable, that part shall be construed to reflect the parties' original intent, and the remaining portions remain in full force and effect, or DJI may at its option terminate this Agreement. (e) The controlling language of this Agreement is English. If you have received a translation into another language, it has been provided for your convenience only. (f) A waiver by either party of any term or condition of this Agreement or any breach thereof, in any one instance, shall not waive such term or condition or any subsequent breach thereof. (g) You may not assign or otherwise transfer by operation of law or otherwise this Agreement or any rights or obligations herein. DJI may assign this Agreement to any entity at its sole discretion. (h) This Agreement shall be binding upon and shall inure to the benefit of the parties, their successors and permitted assigns. + 18. User Outside the People’s Republic of China. If you are using the SDK outside the People’s Republic of China, then the following shall apply: (a) You confirm that this Agreement and all related documentation is and will be in the English language; (b) you are responsible for complying with any local laws in your jurisdiction which might impact your right to import, export or use the SDK, and you represent that you have complied with any regulations or registration procedures required by applicable law to make this license enforceable. + +This End User License Agreement was last modified on December 11, 2017. diff --git a/License.txt b/License.txt new file mode 100644 index 00000000..7136d4dd --- /dev/null +++ b/License.txt @@ -0,0 +1,466 @@ +The following portions of the DJI’s Onboard SDK (“Software” referred to in the terms below) are made available to you under the terms of the MIT License provided below. + +Onboard-SDK +├── CMakeLists.txt +├── contrib +│   └── DJIConfig.cmake +├── osdk-core +│   ├── api +│   │   ├── inc +│   │   │   ├── dji_ack.hpp +│   │   │   ├── dji_broadcast.hpp +│   │   │   ├── dji_camera.hpp +│   │   │   ├── dji_command.hpp +│   │   │   ├── dji_control.hpp +│   │   │   ├── dji_error.hpp +│   │   │   ├── dji_gimbal.hpp +│   │   │   ├── dji_hardware_sync.hpp +│   │   │   ├── dji_hotpoint.hpp +│   │   │   ├── dji_mfio.hpp +│   │   │   ├── dji_mission_base.hpp +│   │   │   ├── dji_mission_manager.hpp +│   │   │   ├── dji_mission_type.hpp +│   │   │   ├── dji_mobile_communication.hpp +│   │   │   ├── dji_status.hpp +│   │   │   ├── dji_subscription.hpp +│   │   │   ├── dji_telemetry.hpp +│   │   │   ├── dji_type.hpp +│   │   │   ├── dji_vehicle_callback.hpp +│   │   │   ├── dji_vehicle.hpp +│   │   │   ├── dji_version.hpp +│   │   │   ├── dji_virtual_rc.hpp +│   │   │   └── dji_waypoint.hpp +│   │   └── src +│   │   ├── dji_ack.cpp +│   │   ├── dji_broadcast.cpp +│   │   ├── dji_camera.cpp +│   │   ├── dji_command.cpp +│   │   ├── dji_control.cpp +│   │   ├── dji_error.cpp +│   │   ├── dji_gimbal.cpp +│   │   ├── dji_hardware_sync.cpp +│   │   ├── dji_hotpoint.cpp +│   │   ├── dji_mfio.cpp +│   │   ├── dji_mission_manager.cpp +│   │   ├── dji_mobile_communication.cpp +│   │   ├── dji_subscription.cpp +│   │   ├── dji_vehicle.cpp +│   │   ├── dji_version.cpp +│   │   ├── dji_virtual_rc.cpp +│   │   └── dji_waypoint.cpp +│   ├── CMakeLists.txt +│   ├── cmake-modules +│   │   ├── DJIOSDKConfig.cmake +│   │   ├── DJIOSDKConfig.cmake.in +│   │   ├── DJIOSDKConfigVersion.cmake +│   │   ├── DJIOSDKConfigVersion.cmake.in +│   │   ├── External_AdvancedSensing.cmake +│   │   ├── FindAdvancedSensing.cmake +│   │   ├── FindFFMPEG.cmake +│   │   └── FindLibUSB.cmake +│   ├── config_example.json +│   ├── hal +│   │   ├── inc +│   │   │   ├── dji_hard_driver.hpp +│   │   │   ├── dji_log.hpp +│   │   │   ├── dji_memory.hpp +│   │   │   ├── dji_platform_manager.hpp +│   │   │   └── dji_thread_manager.hpp +│   │   └── src +│   │   ├── dji_hard_driver.cpp +│   │   ├── dji_log.cpp +│   │   ├── dji_memory.cpp +│   │   ├── dji_platform_manager.cpp +│   │   └── dji_thread_manager.cpp +│   ├── platform +│   │   ├── default +│   │   │   ├── inc +│   │   │   │   └── dji_memory_default.hpp +│   │   │   ├── readme.md +│   │   │   └── src +│   │   │   └── dji_memory_default.cpp +│   │   ├── linux +│   │   │   ├── inc +│   │   │   │   ├── linux_serial_device.hpp +│   │   │   │   ├── posix_thread.hpp +│   │   │   │   └── posix_thread_manager.hpp +│   │   │   └── src +│   │   │   ├── linux_serial_device.cpp +│   │   │   ├── posix_thread.cpp +│   │   │   └── posix_thread_manager.cpp +│   │   ├── manifold +│   │   │   ├── inc +│   │   │   │   ├── DJI_HardDriver_Manifold.h +│   │   │   │   └── DJIHardDriverManifold.h +│   │   │   └── src +│   │   │   └── DJIHardDriverManifold.cpp +│   │   ├── qt +│   │   │   ├── inc +│   │   │   │   ├── qt_serial_device.hpp +│   │   │   │   └── qt_thread.hpp +│   │   │   └── src +│   │   │   ├── qt_serial_device.cpp +│   │   │   └── qt_thread.cpp +│   │   ├── Readme.md +│   │   └── STM32 +│   │   ├── inc +│   │   │   ├── STM32F4DataGuard.h +│   │   │   ├── STM32F4SerialDriver.h +│   │   └── src +│   │   ├── STM32F4DataGuard.cpp +│   │   └── STM32F4SerialDriver.cpp +│   ├── protocol +│   │   ├── inc +│   │   │   ├── dji_aes.hpp +│   │   │   ├── dji_crc.hpp +│   │   │   ├── dji_open_protocol.hpp +│   │   │   └── dji_protocol_base.hpp +│   │   └── src +│   │   ├── dji_aes.cpp +│   │   ├── dji_open_protocol.cpp +│   │   └── dji_protocol_base.cpp +│   ├── README.md +│   └── utility +│   ├── inc +│   │   ├── dji_circular_buffer.hpp +│   │   └── dji_singleton.hpp +│   └── src +│   ├── dji_circular_buffer.cpp +│   └── dji_singleton.cpp +└── sample + ├── linux + │   ├── advanced-sensing + │   │   ├── camera_stream_callback_sample + │   │   │   ├── camera-stream-callback-sample.cpp + │   │   │   └── CMakeLists.txt + │   │   ├── camera_stream_poll_sample + │   │   │   ├── camera-stream-poll-sample.cpp + │   │   │   └── CMakeLists.txt + │   │   ├── camera_stream_target_tracking_sample + │   │   │   ├── CMakeLists.txt + │   │   │   ├── target_tracking.cpp + │   │   │   ├── tracking_utility.cpp + │   │   │   └── tracking_utility.hpp + │   │   ├── CMakeLists.txt + │   │   ├── stereo_vision_multi_thread_sample + │   │   │   ├── advanced_sensing_multi_thread_sample.cpp + │   │   │   ├── advanced_sensing_multi_thread_sample.hpp + │   │   │   ├── CMakeLists.txt + │   │   │   ├── image_process_container.cpp + │   │   │   ├── image_process_container.hpp + │   │   │   ├── utility_thread.cpp + │   │   │   └── utility_thread.hpp + │   │   └── stereo_vision_single_thread_sample + │   │   ├── advanced_sensing_sample.cpp + │   │   ├── advanced_sensing_sample.hpp + │   │   └── CMakeLists.txt + │   ├── camera-gimbal + │   │   ├── camera_gimbal_sample.cpp + │   │   ├── camera_gimbal_sample.hpp + │   │   ├── CMakeLists.txt + │   │   └── main.cpp + │   ├── CMakeLists.txt + │   ├── common + │   │   ├── dji_linux_environment.cpp + │   │   ├── dji_linux_environment.hpp + │   │   ├── dji_linux_helpers.cpp + │   │   ├── dji_linux_helpers.hpp + │   │   └── UserConfig.txt + │   ├── flight-control + │   │   ├── CMakeLists.txt + │   │   ├── flight_control_sample.cpp + │   │   ├── flight_control_sample.hpp + │   │   └── main.cpp + │   ├── logging + │   │   ├── CMakeLists.txt + │   │   ├── logging_sample.cpp + │   │   ├── logging_sample.hpp + │   │   └── main.cpp + │   ├── mfio + │   │   ├── CMakeLists.txt + │   │   ├── main.cpp + │   │   ├── mfio_sample.cpp + │   │   └── mfio_sample.hpp + │   ├── missions + │   │   ├── CMakeLists.txt + │   │   ├── main.cpp + │   │   ├── mission_sample.cpp + │   │   └── mission_sample.hpp + │   ├── mobile + │   │   ├── CMakeLists.txt + │   │   ├── main.cpp + │   │   ├── mobile_sample.cpp + │   │   └── mobile_sample.hpp + │   └── telemetry + │   ├── CMakeLists.txt + │   ├── main.cpp + │   ├── telemetry_sample.cpp + │   └── telemetry_sample.hpp + ├── Qt + │   ├── djiosdk-qt-sample + │   │   ├── Broadcast + │   │   │   ├── broadcast.cpp + │   │   │   ├── broadcast.hpp + │   │   │   ├── broadcast.pri + │   │   │   └── broadcast.ui + │   │   ├── CameraGimbalControl + │   │   │   ├── camera_gimbal_control_panel.cpp + │   │   │   ├── camera_gimbal_control_panel.hpp + │   │   │   ├── camera_gimbal_control_panel.pri + │   │   │   └── camera_gimbal_control_panel.ui + │   │   ├── CMakeLists.txt + │   │   ├── djiosdk-qt-sample.pro + │   │   ├── FlightControl + │   │   │   ├── flight_control_panel.cpp + │   │   │   ├── flight_control_panel.hpp + │   │   │   ├── flight_control_panel.pri + │   │   │   └── flight_control_panel.ui + │   │   ├── images + │   │   │   ├── caret-down.png + │   │   │   ├── check-square.png + │   │   │   └── dji_logo_gray.png + │   │   ├── main.cpp + │   │   ├── MFIO + │   │   │   ├── mfio_panel.cpp + │   │   │   ├── mfio_panel.hpp + │   │   │   ├── mfio_panel.pri + │   │   │   └── mfio_panel.ui + │   │   ├── Missions + │   │   │   ├── hotpoint_panel.cpp + │   │   │   ├── hotpoint_panel.hpp + │   │   │   ├── hotpoint_panel.ui + │   │   │   ├── Missions.pri + │   │   │   ├── qwaypoints.cpp + │   │   │   ├── qwaypoints.hpp + │   │   │   ├── qwaypoints.ui + │   │   │   └── sdk_widgets.hpp + │   │   ├── qtosdk.cpp + │   │   ├── qtosdk.hpp + │   │   ├── qtosdk.ui + │   │   ├── resources.qrc + │   │   ├── stylesheets + │   │   │   └── material-blue.qss + │   │   ├── Subscribe + │   │   │   ├── subscribe_panel.cpp + │   │   │   ├── subscribe_panel.hpp + │   │   │   ├── SubscribePanel.pri + │   │   │   └── subscribe_panel.ui + │   │   └── UserConfig.txt + │   └── README.md + └── STM32 + ├── OnBoardSDK_STM32 + │   ├── Bsp + │   │   ├── bsp.cpp + │   │   ├── bsp.h + │   │   ├── BspUsart.cpp + │   │   ├── BspUsart.h + │   │   ├── timer.cpp + │   │   └── timer.h + │   ├── doc + │   │   └── readme.txt + │   ├── keilkilll.bat + │   ├── Project + │   │   ├── OnBoardSDK_STM32.uvprojx + │   │   └── RTE + │   │   └── _DJI_LIB + │   │   └── RTE_Components.h + │   ├── Project_Gcc + │   │   ├── Makefile + │   │   ├── setup_and_build.sh + │   │   ├── startup_stm32f40xx.s + │   │   ├── stm32_flash.ld + │   │   └── syscalls.c + │   ├── RTE + │   │   └── RTE_Components.h + │   └── User + │   ├── Activate.cpp + │   ├── Activate.h + │   ├── CameraGimbalSample.cpp + │   ├── CameraGimbalSample.h + │   ├── cppforstm32.cpp + │   ├── cppforstm32.h + │   ├── FlightControlSample.cpp + │   ├── FlightControlSample.h + │   ├── main.cpp + │   ├── main.h + │   ├── MissionSample.cpp + │   ├── MissionSample.h + │   ├── MobileSample.cpp + │   ├── MobileSample.h + │   ├── Receive.cpp + │   ├── Receive.h + │   ├── stm32f4xx_conf.h + │   ├── TelemetrySample.cpp + │   └── TelemetrySample.h + └── README.md + +Unless otherwise agreed, all other portions of DJI’s Onboard SDK are and will be made available under the SDK End User License Agreement (EULA). A copy of the SDK EULA is distributed with this software and is available at https://developer.dji.com/policies/eula/. +------------------------------------------------------------- +Copyright (c) 2017-2018 DJI. +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +=============================================================== +DJI’s Onboard SDK uses unmodified libraries of UDT version 4 (http://udt.sourceforge.net/), which is licensed under BSD license. A copy of the BSD license is provided below and is also available at http://udt.sourceforge.net/LICENSE.txt. + +------------------------------------------------------------- +Copyright (c) 2001 - 2009, The Board of Trustees of the University of Illinois. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + +* Redistributions in binary form must reproduce the + above copyright notice, this list of conditions + and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the University of Illinois + nor the names of its contributors may be used to + endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +=============================================================== +DJI’s Onboard SDK dynamically links to unmodified libraries of FFmpeg (https://ffmpeg.org/), which is licensed under LGPL 2.1. A copy of the LGPL 2.1 license is provided below and is also available at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +------------------------------------------------------------- +GNU LESSER GENERAL PUBLIC LICENSE +Version 2.1, February 1999 +Copyright (C) 1991, 1999 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] +Preamble +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. +This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. +When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. +To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. +For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. +We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. +To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. +Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. +Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. +When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. +We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. +For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. +In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. +Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. +The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". +A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. +The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) +"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. +1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. +2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: +• a) The modified work must itself be a software library. +• b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. +• c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. +• d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. +(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. +In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. +3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. +Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. +This option is useful when you wish to copy part of the code of the Library into a program that is not a library. +4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. +If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. +5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. +However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. +When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. +If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) +Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. +6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. +You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: +• a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) +• b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. +• c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. +• d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. +• e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. +For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. +It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. +7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: +• a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. +• b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. +8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. +9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. +10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. +11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. +12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. +13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. +Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. +14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. +NO WARRANTY +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +END OF TERMS AND CONDITIONS +How to Apply These Terms to Your New Libraries +If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). +To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. +one line to give the library's name and an idea of what it does. +Copyright (C) year name of author + +This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +Also add information on how to contact you by electronic and paper mail. +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: +Yoyodyne, Inc., hereby disclaims all copyright interest in +the library `Frob' (a library for tweaking knobs) written +by James Random Hacker. + +signature of Ty Coon, 1 April 1990 +Ty Coon, President of Vice +That's all there is to it! + +=============================================================== +DJI’s Onboard SDK uses unmodified libraries of DownloadProject (https://github.com/Crascit/DownloadProject.git), which is licensed under MIT license. A copy of the MIT license is provided below and is also available at https://raw.githubusercontent.com/Crascit/DownloadProject/master/LICENSE. + +The MIT License (MIT) + +Copyright (c) 2015 Crascit + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + diff --git a/README.md b/README.md index 8e2cacbe..bc6932e3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# DJI Onboard SDK (OSDK) 3.4 +# DJI Onboard SDK (OSDK) 3.5 [![Join the chat at https://gitter.im/dji-sdk/Onboard-SDK](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dji-sdk/Onboard-SDK?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) @@ -7,34 +7,33 @@ The DJI Onboard SDK allows you to connect your own Onboard Computer to a [supported](https://developer.dji.com/onboard-sdk/documentation/introduction/osdk-hardware-introduction.html#supported-products) DJI vehicle or flight controller using a serial port (TTL UART). For full documentation, please visit the [DJI Developer Site](https://developer.dji.com/onboard-sdk/documentation/). Documentation regarding the code can be found in the [OSDK API Reference](https://developer.dji.com/onboard-api-reference/index.html) section of the developer website. ## Latest Release -OSDK 3.4.2 was released on 13 Dec 2017. Along with OSDK 3.4.1, this is a bugfix release fixing build issues for STM32, Qt, and resolving issues #212 and #221. Additionally, MIT license verbiage has been added to the open source components of OSDK. Links to DJI EULA have been added for headers accompanying closed-source binaries. +OSDK 3.5 was released on 15 Dec 2017. This release brings new features for the Matrice 210 and 210 RTK aircraft. Developers will now have access to the live streams of the main (Zenmuse X4 and X5S) and FPV cameras. Additionally, more complete license information is added to the repository. ## Last Major Release - -OSDK 3.4 was released on 22 Nov 2017. This release introduces support for Matrice 210 and 210 RTK. Developers will now have access to previously unavailable data such as front-facing and downward-facing stereo camera feeds through USB. Please see the [release notes](https://developer.dji.com/onboard-sdk/documentation/appendix/releaseNotes.html) for more information. +OSDK 3.4 was released on 22 Nov 2017. This release introduces support for Matrice 210 and 210 RTK. Developers will now have access to previously unavailable data such as front-facing and downward-facing stereo camera feeds through USB. Please see the [release notes](https://developer.dji.com/onboard-sdk/documentation/appendix/releaseNotes.html) for more information. OSDK 3.4.2 hotfix release fixes some bugs present in 3.4. ## Firmware Compatibility | Aircraft/FC | Firmware Package Version | Flight Controller Version | OSDK Branch | Notes | |-------------------|--------------------------|---------------------------|------------------------|-----------------------------------------------------------------------| -| **M210/M210 RTK** | **1.1.0410+** | **3.2.39.12+** | **OSDK 3.4 (Current)** | Requires DJI Assistant 2 version 1.1.8 | +| **M210/M210 RTK** | **1.1.0410+** | **3.2.39.12+** | **OSDK 3.4+ ** | Requires DJI Assistant 2 version 1.1.8 | | | | | | | -| **M600/M600 Pro** | **1.0.1.65** | **3.2.41.9** | **OSDK 3.4 (Current)** | | +| **M600/M600 Pro** | **1.0.1.65** | **3.2.41.9** | **OSDK 3.4+ ** | | | | *1.0.1.65* | *3.2.41.9* | OSDK 3.3 | Firmware released 10/24/17 | | | *1.0.1.60* | *3.2.41.5* | *Not Supported* | Firmware pulled due to instability | -| | **1.0.1.20** | **3.2.15.62** | **OSDK 3.3 (Current)** | 3.3 backward compatiblity released 10/18 | +| | **1.0.1.20** | **3.2.15.62** | **OSDK 3.3 ** | 3.3 backward compatiblity released 10/18 | | | 1.0.0.80 | 3.2.15.00 | OSDK 3.2 | | | | | | | | -| **A3/A3 Pro** | **1.7.1.5** | **3.2.36.8** | **OSDK 3.4 (Current)** | | +| **A3/A3 Pro** | **1.7.1.5** | **3.2.36.8** | **OSDK 3.4+ ** | | | | 1.7.1.5 | 3.2.36.8 | OSDK 3.3 | | | | 1.7.0.5 | 3.2.15.50 | OSDK 3.2 | | | | 1.7.0.0 | 3.2.15.37 | OSDK 3.2 | | | | | | | | -| **N3** | **1.7.1.5** | **3.2.36.8** | **OSDK 3.4 (Current)** | | +| **N3** | **1.7.1.5** | **3.2.36.8** | **OSDK 3.4+ ** | | | | 1.7.1.5 | 3.2.36.8 | OSDK 3.3 | | | | 1.7.0.0 | 3.2.15.37 | OSDK 3.2 | | | | | | | | -| **M100** | 1.3.1.0 | 3.1.10.0 | **OSDK 3.4 (Current)** | | +| **M100** | 1.3.1.0 | 3.1.10.0 | **OSDK 3.4 ** | | diff --git a/osdk-core/CMakeLists.txt b/osdk-core/CMakeLists.txt index c1d9e308..da80b479 100644 --- a/osdk-core/CMakeLists.txt +++ b/osdk-core/CMakeLists.txt @@ -129,6 +129,15 @@ if(ADVANCED_SENSING) add_dependencies(${PROJECT_NAME} advanced-sensing) endif() + find_package(FFMPEG REQUIRED) + + if(FFMPEG_FOUND) + message("Found FFMPEG FFMPEG_INCLUDE_DIR = ${FFMPEG_INCLUDE_DIR}") + message("Found FFMPEG FFMPEG_LIBRARIES = ${FFMPEG_LIBRARIES}") + else() + message("Cannot Find FFMPEG") + endif(FFMPEG_FOUND) + target_include_directories(${PROJECT_NAME} PUBLIC $) target_link_libraries(${PROJECT_NAME} PRIVATE ${ADVANCED_SENSING_LIBRARY}) @@ -137,7 +146,10 @@ if(ADVANCED_SENSING) target_include_directories(${PROJECT_NAME} PUBLIC ${LIBUSB_1_INCLUDE_DIRS}) target_link_libraries(${PROJECT_NAME} PUBLIC ${LIBUSB_1_LIBRARIES}) - set(OSDK_INTERFACE_LIBS ${OSDK_INTERFACE_LIBS} ${LIBUSB_1_LIBRARIES}) + target_include_directories(${PROJECT_NAME} PUBLIC ${FFMPEG_INCLUDE_DIR}) + target_link_libraries(${PROJECT_NAME} PUBLIC ${FFMPEG_LIBRARIES}) + + set(OSDK_INTERFACE_LIBS ${OSDK_INTERFACE_LIBS} ${LIBUSB_1_LIBRARIES} ${FFMPEG_LIBRARIES}) set(MODULE_BUILD_INTERFACE ${MODULE_BUILD_INTERFACE} ${ADVANCED_SENSING_LIBRARY}) set(MODULE_INSTALL_INTERFACE ${MODULE_INSTALL_INTERFACE} $/lib/libadvanced-sensing.a) @@ -222,6 +234,8 @@ if(ADVANCED_SENSING) ${ADVANCED_SENSING_INCLUDE_DIRS}/dji_advanced_sensing.hpp ${ADVANCED_SENSING_INCLUDE_DIRS}/dji_advanced_sensing_protocol.hpp ${ADVANCED_SENSING_INCLUDE_DIRS}/linux_usb_device.hpp + ${ADVANCED_SENSING_INCLUDE_DIRS}/dji_camera_image.hpp + ${ADVANCED_SENSING_INCLUDE_DIRS}/dji_camera_stream.hpp ) endif() diff --git a/osdk-core/cmake-modules/DownloadProject/DownloadProject.CMakeLists.cmake.in b/osdk-core/cmake-modules/DownloadProject/DownloadProject.CMakeLists.cmake.in new file mode 100644 index 00000000..89be4fdd --- /dev/null +++ b/osdk-core/cmake-modules/DownloadProject/DownloadProject.CMakeLists.cmake.in @@ -0,0 +1,17 @@ +# Distributed under the OSI-approved MIT License. See accompanying +# file LICENSE or https://github.com/Crascit/DownloadProject for details. + +cmake_minimum_required(VERSION 2.8.2) + +project(${DL_ARGS_PROJ}-download NONE) + +include(ExternalProject) +ExternalProject_Add(${DL_ARGS_PROJ}-download + ${DL_ARGS_UNPARSED_ARGUMENTS} + SOURCE_DIR "${DL_ARGS_SOURCE_DIR}" + BINARY_DIR "${DL_ARGS_BINARY_DIR}" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +) diff --git a/osdk-core/cmake-modules/DownloadProject/DownloadProject.cmake b/osdk-core/cmake-modules/DownloadProject/DownloadProject.cmake new file mode 100644 index 00000000..e300f426 --- /dev/null +++ b/osdk-core/cmake-modules/DownloadProject/DownloadProject.cmake @@ -0,0 +1,182 @@ +# Distributed under the OSI-approved MIT License. See accompanying +# file LICENSE or https://github.com/Crascit/DownloadProject for details. +# +# MODULE: DownloadProject +# +# PROVIDES: +# download_project( PROJ projectName +# [PREFIX prefixDir] +# [DOWNLOAD_DIR downloadDir] +# [SOURCE_DIR srcDir] +# [BINARY_DIR binDir] +# [QUIET] +# ... +# ) +# +# Provides the ability to download and unpack a tarball, zip file, git repository, +# etc. at configure time (i.e. when the cmake command is run). How the downloaded +# and unpacked contents are used is up to the caller, but the motivating case is +# to download source code which can then be included directly in the build with +# add_subdirectory() after the call to download_project(). Source and build +# directories are set up with this in mind. +# +# The PROJ argument is required. The projectName value will be used to construct +# the following variables upon exit (obviously replace projectName with its actual +# value): +# +# projectName_SOURCE_DIR +# projectName_BINARY_DIR +# +# The SOURCE_DIR and BINARY_DIR arguments are optional and would not typically +# need to be provided. They can be specified if you want the downloaded source +# and build directories to be located in a specific place. The contents of +# projectName_SOURCE_DIR and projectName_BINARY_DIR will be populated with the +# locations used whether you provide SOURCE_DIR/BINARY_DIR or not. +# +# The DOWNLOAD_DIR argument does not normally need to be set. It controls the +# location of the temporary CMake build used to perform the download. +# +# The PREFIX argument can be provided to change the base location of the default +# values of DOWNLOAD_DIR, SOURCE_DIR and BINARY_DIR. If all of those three arguments +# are provided, then PREFIX will have no effect. The default value for PREFIX is +# CMAKE_BINARY_DIR. +# +# The QUIET option can be given if you do not want to show the output associated +# with downloading the specified project. +# +# In addition to the above, any other options are passed through unmodified to +# ExternalProject_Add() to perform the actual download, patch and update steps. +# The following ExternalProject_Add() options are explicitly prohibited (they +# are reserved for use by the download_project() command): +# +# CONFIGURE_COMMAND +# BUILD_COMMAND +# INSTALL_COMMAND +# TEST_COMMAND +# +# Only those ExternalProject_Add() arguments which relate to downloading, patching +# and updating of the project sources are intended to be used. Also note that at +# least one set of download-related arguments are required. +# +# If using CMake 3.2 or later, the UPDATE_DISCONNECTED option can be used to +# prevent a check at the remote end for changes every time CMake is run +# after the first successful download. See the documentation of the ExternalProject +# module for more information. It is likely you will want to use this option if it +# is available to you. Note, however, that the ExternalProject implementation contains +# bugs which result in incorrect handling of the UPDATE_DISCONNECTED option when +# using the URL download method or when specifying a SOURCE_DIR with no download +# method. Fixes for these have been created, the last of which is scheduled for +# inclusion in CMake 3.8.0. Details can be found here: +# +# https://gitlab.kitware.com/cmake/cmake/commit/bdca68388bd57f8302d3c1d83d691034b7ffa70c +# https://gitlab.kitware.com/cmake/cmake/issues/16428 +# +# If you experience build errors related to the update step, consider avoiding +# the use of UPDATE_DISCONNECTED. +# +# EXAMPLE USAGE: +# +# include(DownloadProject) +# download_project(PROJ googletest +# GIT_REPOSITORY https://github.com/google/googletest.git +# GIT_TAG master +# UPDATE_DISCONNECTED 1 +# QUIET +# ) +# +# add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) +# +#======================================================================================== + + +set(_DownloadProjectDir "${CMAKE_CURRENT_LIST_DIR}") + +include(CMakeParseArguments) + +function(download_project) + + set(options QUIET) + set(oneValueArgs + PROJ + PREFIX + DOWNLOAD_DIR + SOURCE_DIR + BINARY_DIR + # Prevent the following from being passed through + CONFIGURE_COMMAND + BUILD_COMMAND + INSTALL_COMMAND + TEST_COMMAND + ) + set(multiValueArgs "") + + cmake_parse_arguments(DL_ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # Hide output if requested + if (DL_ARGS_QUIET) + set(OUTPUT_QUIET "OUTPUT_QUIET") + else() + unset(OUTPUT_QUIET) + message(STATUS "Downloading/updating ${DL_ARGS_PROJ}") + endif() + + # Set up where we will put our temporary CMakeLists.txt file and also + # the base point below which the default source and binary dirs will be. + # The prefix must always be an absolute path. + if (NOT DL_ARGS_PREFIX) + set(DL_ARGS_PREFIX "${CMAKE_BINARY_DIR}") + else() + get_filename_component(DL_ARGS_PREFIX "${DL_ARGS_PREFIX}" ABSOLUTE + BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") + endif() + if (NOT DL_ARGS_DOWNLOAD_DIR) + set(DL_ARGS_DOWNLOAD_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-download") + endif() + + # Ensure the caller can know where to find the source and build directories + if (NOT DL_ARGS_SOURCE_DIR) + set(DL_ARGS_SOURCE_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-src") + endif() + if (NOT DL_ARGS_BINARY_DIR) + set(DL_ARGS_BINARY_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-build") + endif() + set(${DL_ARGS_PROJ}_SOURCE_DIR "${DL_ARGS_SOURCE_DIR}" PARENT_SCOPE) + set(${DL_ARGS_PROJ}_BINARY_DIR "${DL_ARGS_BINARY_DIR}" PARENT_SCOPE) + + # The way that CLion manages multiple configurations, it causes a copy of + # the CMakeCache.txt to be copied across due to it not expecting there to + # be a project within a project. This causes the hard-coded paths in the + # cache to be copied and builds to fail. To mitigate this, we simply + # remove the cache if it exists before we configure the new project. It + # is safe to do so because it will be re-generated. Since this is only + # executed at the configure step, it should not cause additional builds or + # downloads. + file(REMOVE "${DL_ARGS_DOWNLOAD_DIR}/CMakeCache.txt") + + # Create and build a separate CMake project to carry out the download. + # If we've already previously done these steps, they will not cause + # anything to be updated, so extra rebuilds of the project won't occur. + # Make sure to pass through CMAKE_MAKE_PROGRAM in case the main project + # has this set to something not findable on the PATH. + configure_file("${_DownloadProjectDir}/DownloadProject.CMakeLists.cmake.in" + "${DL_ARGS_DOWNLOAD_DIR}/CMakeLists.txt") + execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" + -D "CMAKE_MAKE_PROGRAM:FILE=${CMAKE_MAKE_PROGRAM}" + . + RESULT_VARIABLE result + ${OUTPUT_QUIET} + WORKING_DIRECTORY "${DL_ARGS_DOWNLOAD_DIR}" + ) + if(result) + message(FATAL_ERROR "CMake step for ${DL_ARGS_PROJ} failed: ${result}") + endif() + execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE result + ${OUTPUT_QUIET} + WORKING_DIRECTORY "${DL_ARGS_DOWNLOAD_DIR}" + ) + if(result) + message(FATAL_ERROR "Build step for ${DL_ARGS_PROJ} failed: ${result}") + endif() + +endfunction() diff --git a/osdk-core/cmake-modules/External_AdvancedSensing.cmake b/osdk-core/cmake-modules/External_AdvancedSensing.cmake index 4d93fa40..0f0680cf 100644 --- a/osdk-core/cmake-modules/External_AdvancedSensing.cmake +++ b/osdk-core/cmake-modules/External_AdvancedSensing.cmake @@ -1,7 +1,7 @@ include(ExternalProject) message( STATUS "External library - DJI Advanced Sensing for stereo cameras" ) -set(VERSION "1.0.0") +set(VERSION "2.0.0") set(LIB_NAME advanced-sensing) set(LIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_NAME}-${VERSION}) diff --git a/osdk-core/cmake-modules/FindAdvancedSensing.cmake b/osdk-core/cmake-modules/FindAdvancedSensing.cmake index 94a50a29..44f6e1da 100644 --- a/osdk-core/cmake-modules/FindAdvancedSensing.cmake +++ b/osdk-core/cmake-modules/FindAdvancedSensing.cmake @@ -13,8 +13,8 @@ else (ADVANCED_SENSING_LIBRARY AND ADVANCED_SENSING_INCLUDE_DIRS) NAMES dji_advanced_sensing_protocol.hpp PATHS - ${CMAKE_CURRENT_SOURCE_DIR}/advanced-sensing-1.0.0/inc - ${EXECUTABLE_OUTPUT_PATH}/advanced-sensing-1.0.0/inc + ${CMAKE_CURRENT_SOURCE_DIR}/advanced-sensing-2.0.0/inc + ${EXECUTABLE_OUTPUT_PATH}/advanced-sensing-2.0.0/inc PATH_SUFFIXES advanced-sensing ) @@ -23,8 +23,8 @@ else (ADVANCED_SENSING_LIBRARY AND ADVANCED_SENSING_INCLUDE_DIRS) NAMES advanced-sensing PATHS - ${CMAKE_CURRENT_SOURCE_DIR}/advanced-sensing-1.0.0/lib - ${EXECUTABLE_OUTPUT_PATH}/advanced-sensing-1.0.0/lib + ${CMAKE_CURRENT_SOURCE_DIR}/advanced-sensing-2.0.0/lib + ${EXECUTABLE_OUTPUT_PATH}/advanced-sensing-2.0.0/lib NO_DEFAULT_PATH ) diff --git a/osdk-core/cmake-modules/FindFFMPEG.cmake b/osdk-core/cmake-modules/FindFFMPEG.cmake new file mode 100644 index 00000000..81ca8d07 --- /dev/null +++ b/osdk-core/cmake-modules/FindFFMPEG.cmake @@ -0,0 +1,181 @@ +# +# Find the native FFMPEG includes and library +# +# This module defines +# FFMPEG_INCLUDE_DIR, where to find avcodec.h, avformat.h ... +# FFMPEG_LIBRARIES, the libraries to link against to use FFMPEG. +# FFMPEG_FOUND, If false, do not try to use FFMPEG. + +# also defined, but not for general use are +# FFMPEG_avformat_LIBRARY and FFMPEG_avcodec_LIBRARY, where to find the FFMPEG library. +# This is useful to do it this way so that we can always add more libraries +# if needed to FFMPEG_LIBRARIES if ffmpeg ever changes... + +# if ffmpeg headers are all in one directory +FIND_PATH(FFMPEG_INCLUDE_DIR avformat.h + PATHS + $ENV{FFMPEG_DIR}/include + $ENV{OSGDIR}/include + $ENV{OSG_ROOT}/include + ~/Library/Frameworks + /Library/Frameworks + /usr/local/include + /usr/include + /sw/include # Fink + /opt/local/include # DarwinPorts + /opt/csw/include # Blastwave + /opt/include + /usr/freeware/include + PATH_SUFFIXES ffmpeg + DOC "Location of FFMPEG Headers" +) + +# if ffmpeg headers are seperated to each of libavformat, libavcodec etc.. +IF( NOT FFMPEG_INCLUDE_DIR ) + FIND_PATH(FFMPEG_INCLUDE_DIR libavformat/avformat.h + PATHS + $ENV{FFMPEG_DIR}/include + $ENV{OSGDIR}/include + $ENV{OSG_ROOT}/include + ~/Library/Frameworks + /Library/Frameworks + /usr/local/include + /usr/include + /sw/include # Fink + /opt/local/include # DarwinPorts + /opt/csw/include # Blastwave + /opt/include + /usr/freeware/include + PATH_SUFFIXES ffmpeg + DOC "Location of FFMPEG Headers" +) + +ENDIF( NOT FFMPEG_INCLUDE_DIR ) + +# we want the -I include line to use the parent directory of ffmpeg as +# ffmpeg uses relative includes such as or +get_filename_component(FFMPEG_INCLUDE_DIR ${FFMPEG_INCLUDE_DIR} ABSOLUTE) + +FIND_LIBRARY(FFMPEG_avformat_LIBRARY avformat + /usr/local/lib + /usr/lib +) + +FIND_LIBRARY(FFMPEG_avcodec_LIBRARY avcodec + /usr/local/lib + /usr/lib +) + +FIND_LIBRARY(FFMPEG_avutil_LIBRARY avutil + /usr/local/lib + /usr/lib +) + +FIND_LIBRARY(FFMPEG_vorbis_LIBRARY vorbis + /usr/local/lib + /usr/lib +) + +FIND_LIBRARY(FFMPEG_dc1394_LIBRARY dc1394_control + /usr/local/lib + /usr/lib +) + +FIND_LIBRARY(FFMPEG_vorbisenc_LIBRARY vorbisenc + /usr/local/lib + /usr/lib +) + +FIND_LIBRARY(FFMPEG_theora_LIBRARY theora + /usr/local/lib + /usr/lib +) + +FIND_LIBRARY(FFMPEG_dts_LIBRARY dts + /usr/local/lib + /usr/lib +) + +FIND_LIBRARY(FFMPEG_gsm_LIBRARY gsm + /usr/local/lib + /usr/lib +) + +FIND_LIBRARY(FFMPEG_swscale_LIBRARY swscale + /usr/local/lib + /usr/lib +) + +FIND_LIBRARY(FFMPEG_z_LIBRARY z + /usr/local/lib + /usr/lib +) + +SET(FFMPEG_LIBRARIES) +IF(FFMPEG_INCLUDE_DIR) + IF(FFMPEG_avformat_LIBRARY) + IF(FFMPEG_avcodec_LIBRARY) + IF(FFMPEG_avutil_LIBRARY) + SET( FFMPEG_FOUND "YES" ) + SET( FFMPEG_BASIC_LIBRARIES + ${FFMPEG_avcodec_LIBRARY} + ${FFMPEG_avformat_LIBRARY} + ${FFMPEG_avutil_LIBRARY} + ) + + # swscale is always a part of newer ffmpeg distros + IF(FFMPEG_swscale_LIBRARY) + LIST(APPEND FFMPEG_BASIC_LIBRARIES ${FFMPEG_swscale_LIBRARY}) + ENDIF(FFMPEG_swscale_LIBRARY) + + SET(FFMPEG_LIBRARIES ${FFMPEG_BASIC_LIBRARIES}) + + IF(FFMPEG_vorbis_LIBRARY) + LIST(APPEND FFMPEG_LIBRARIES ${FFMPEG_vorbis_LIBRARY}) + ENDIF(FFMPEG_vorbis_LIBRARY) + + IF(FFMPEG_dc1394_LIBRARY) + LIST(APPEND FFMPEG_LIBRARIES ${FFMPEG_dc1394_LIBRARY}) + ENDIF(FFMPEG_dc1394_LIBRARY) + + IF(FFMPEG_vorbisenc_LIBRARY) + LIST(APPEND FFMPEG_LIBRARIES ${FFMPEG_vorbisenc_LIBRARY}) + ENDIF(FFMPEG_vorbisenc_LIBRARY) + + IF(FFMPEG_theora_LIBRARY) + LIST(APPEND FFMPEG_LIBRARIES ${FFMPEG_theora_LIBRARY}) + ENDIF(FFMPEG_theora_LIBRARY) + + IF(FFMPEG_dts_LIBRARY) + LIST(APPEND FFMPEG_LIBRARIES ${FFMPEG_dts_LIBRARY}) + ENDIF(FFMPEG_dts_LIBRARY) + + IF(FFMPEG_gsm_LIBRARY) + LIST(APPEND FFMPEG_LIBRARIES ${FFMPEG_gsm_LIBRARY}) + ENDIF(FFMPEG_gsm_LIBRARY) + + IF(FFMPEG_z_LIBRARY) + LIST(APPEND FFMPEG_LIBRARIES ${FFMPEG_z_LIBRARY}) + ENDIF(FFMPEG_z_LIBRARY) + + SET(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE INTERNAL "All presently found FFMPEG libraries.") + + ENDIF(FFMPEG_avutil_LIBRARY) + ENDIF(FFMPEG_avcodec_LIBRARY) + ENDIF(FFMPEG_avformat_LIBRARY) +ENDIF(FFMPEG_INCLUDE_DIR) + +MARK_AS_ADVANCED( + FFMPEG_INCLUDE_DIR + FFMPEG_avformat_LIBRARY + FFMPEG_avcodec_LIBRARY + FFMPEG_avutil_LIBRARY + FFMPEG_vorbis_LIBRARY + FFMPEG_dc1394_LIBRARY + FFMPEG_vorbisenc_LIBRARY + FFMPEG_theora_LIBRARY + FFMPEG_dts_LIBRARY + FFMPEG_gsm_LIBRARY + FFMPEG_swscale_LIBRARY + FFMPEG_z_LIBRARY + ) diff --git a/osdk-core/hal/inc/dji_log.hpp b/osdk-core/hal/inc/dji_log.hpp index 543b0370..ee4cea6b 100644 --- a/osdk-core/hal/inc/dji_log.hpp +++ b/osdk-core/hal/inc/dji_log.hpp @@ -43,8 +43,13 @@ .title((_title_), #_title_, __func__, __LINE__) \ .print +#define DLOG_PRIVATE(_title_) \ + DJI::OSDK::Log::instance() \ + .title((_title_), #_title_) \ + .print + #define STATUS DJI::OSDK::Log::instance().getStatusLogState() -#define ERROR DJI::OSDK::Log::instance().getErrorLogState() +#define ERRORLOG DJI::OSDK::Log::instance().getErrorLogState() #define DEBUG DJI::OSDK::Log::instance().getDebugLogState() /*! @brief Global Logging macro for status messages @@ -52,18 +57,21 @@ * enable/disable this logging channel */ #define DSTATUS DLOG(STATUS) +#define DSTATUS_PRIVATE DLOG_PRIVATE(STATUS) /*! @brief Global Logging macro for error messages * @details Users can use methods in the DJI::OSDK::Log class to * enable/disable this logging channel */ -#define DERROR DLOG(ERROR) +#define DERROR DLOG(ERRORLOG) +#define DERROR_PRIVATE DLOG_PRIVATE(ERRORLOG) /*! @brief Global Logging macro for debug messages * @details Users can use methods in the DJI::OSDK::Log class to * enable/disable this logging channel */ #define DDEBUG DLOG(DEBUG) +#define DDEBUG_PRIVATE DLOG_PRIVATE(DEBUG) namespace DJI { @@ -88,6 +96,10 @@ public: //! this feature is used for dynamical/statical optional log output Log& title(int level, const char* prefix, const char* func, int line); + //! @note Used for closed source logging, where we don't want to + //! print function name and line number + Log& title(int level, const char* prefix); + Log& print(); /*! diff --git a/osdk-core/hal/src/dji_log.cpp b/osdk-core/hal/src/dji_log.cpp index 14764233..bea11f37 100644 --- a/osdk-core/hal/src/dji_log.cpp +++ b/osdk-core/hal/src/dji_log.cpp @@ -73,6 +73,24 @@ Log::title(int level, const char* prefix, const char* func, int line) return *this; } + +Log& +Log::title(int level, const char* prefix) +{ + if (level) + { + vaild = true; + + const char str[] = "\n%s/%d "; + print(str, prefix, level); + } + else + { + vaild = false; + } + return *this; +} + Log& Log::print() { diff --git a/sample/linux/advanced-sensing/CMakeLists.txt b/sample/linux/advanced-sensing/CMakeLists.txt index f219d760..024eb5c8 100644 --- a/sample/linux/advanced-sensing/CMakeLists.txt +++ b/sample/linux/advanced-sensing/CMakeLists.txt @@ -26,69 +26,24 @@ project(djiosdk-advanced-sensing-sample) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -g -O0") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/osdk-core/cmake-modules/") -set(ADVANCED_SENSING_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../osdk-core/advanced-sensing-1.0.0") find_package(LibUSB REQUIRED) include_directories(${LIBUSB_1_INCLUDE_DIRS}) -# Try to see if user has OpenCV installed -# if yes, default callback will display the image -find_package( OpenCV QUIET ) -if (OpenCV_FOUND) - message( STATUS "Found OpenCV installed in the system, will use it to display image in AdvancedSensing APIs") - add_definitions(-DOPEN_CV_INSTALLED) -else() - message( STATUS "Did not find OpenCV in the system, image data is inside RecvContainer as raw data") -endif () +set(HELPER_FUNCTIONS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../common) -include_directories(${ADVANCED_SENSING_DIR}/inc) include_directories(${ONBOARDSDK_SOURCE}/api/inc) include_directories(${ONBOARDSDK_SOURCE}/utility/inc) include_directories(${ONBOARDSDK_SOURCE}/hal/inc) include_directories(${ONBOARDSDK_SOURCE}/protocol/inc) include_directories(${ONBOARDSDK_SOURCE}/platform/linux/inc) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../common) +include_directories(${HELPER_FUNCTIONS_DIR}) +add_subdirectory(stereo_vision_single_thread_sample) +add_subdirectory(stereo_vision_multi_thread_sample) +add_subdirectory(camera_stream_poll_sample) +add_subdirectory(camera_stream_callback_sample) -## First sample -FILE(GLOB SOURCE_FILES - advanced_sensing_sample.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../common/dji_linux_environment.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../common/dji_linux_helpers.cpp - ) - -add_executable(${PROJECT_NAME} ${SOURCE_FILES}) - -target_link_libraries(${PROJECT_NAME} - djiosdk-core - ${LIBUSB_1_LIBRARIES} - ) - -if (OpenCV_FOUND) - target_link_libraries(${PROJECT_NAME} - ${OpenCV_LIBS} - ) -endif () - -## Second sample -FILE(GLOB MULTI_THREAD_SAMPLE_SOURCE_FILES - advanced_sensing_multi_thread_sample.cpp - utility_thread.cpp - image_process_container.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../common/dji_linux_environment.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../common/dji_linux_helpers.cpp - ) - -add_executable(djiosdk-advanced-sensing-multi-thread-sample - ${MULTI_THREAD_SAMPLE_SOURCE_FILES}) - -target_link_libraries(djiosdk-advanced-sensing-multi-thread-sample - djiosdk-core - ${LIBUSB_1_LIBRARIES} - ) - -if (OpenCV_FOUND) - target_link_libraries(djiosdk-advanced-sensing-multi-thread-sample - ${OpenCV_LIBS} - ) -endif () +if (TARGET_TRACKING_SAMPLE) + add_subdirectory(camera_stream_target_tracking_sample) +endif() diff --git a/sample/linux/advanced-sensing/camera_stream_callback_sample/CMakeLists.txt b/sample/linux/advanced-sensing/camera_stream_callback_sample/CMakeLists.txt new file mode 100644 index 00000000..7b6a3da6 --- /dev/null +++ b/sample/linux/advanced-sensing/camera_stream_callback_sample/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 2.8) +project(camera-stream-callback-sample) + +# Try to see if user has OpenCV installed +# if yes, default callback will display the image +find_package( OpenCV QUIET ) +if (OpenCV_FOUND) + message( "\n${PROJECT_NAME}...") + message( STATUS "Found OpenCV installed in the system, will use it to display image in AdvancedSensing APIs") + message( STATUS "OpenCV_INCLUDE_DIRS= ${OpenCV_INCLUDE_DIRS}") + message( STATUS "OpenCV_LIBRARIES=${OpenCV_LIBRARIES}") + add_definitions(-DOPEN_CV_INSTALLED) +else() + message( STATUS "Did not find OpenCV in the system, image data is inside RecvContainer as raw data") +endif () + +set(HELPER_FUNCTIONS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../common) +add_executable(${PROJECT_NAME} + ${HELPER_FUNCTIONS_DIR}/dji_linux_environment.cpp + ${HELPER_FUNCTIONS_DIR}/dji_linux_helpers.cpp + camera-stream-callback-sample.cpp + ) + +target_include_directories(${PROJECT_NAME} PRIVATE ${OpenCV_INCLUDE_DIRS}) + +target_link_libraries(${PROJECT_NAME} + djiosdk-core + ) + +if (OpenCV_FOUND) + target_link_libraries(${PROJECT_NAME} + ${OpenCV_LIBS} + ) +endif () diff --git a/sample/linux/advanced-sensing/camera_stream_callback_sample/camera-stream-callback-sample.cpp b/sample/linux/advanced-sensing/camera_stream_callback_sample/camera-stream-callback-sample.cpp new file mode 100644 index 00000000..d96485fa --- /dev/null +++ b/sample/linux/advanced-sensing/camera_stream_callback_sample/camera-stream-callback-sample.cpp @@ -0,0 +1,107 @@ +/*! @file camera_stream_poll_sample.cpp + * @version 3.5 + * @date Dec 06 2017 + * + * @brief + * AdvancedSensing, Camera Stream API usage in a Linux environment. + * This sample shows how to use a callback function to process (view) the FPV or + * main camera image. + * (Optional) With OpenCV installed, user can visualize the images + * + * @copyright + * 2016-17 DJI. All rights reserved. + * */ + + +#include "dji_vehicle.hpp" +#include +#include "dji_linux_helpers.hpp" + +#ifdef OPEN_CV_INSTALLED + #include "opencv2/opencv.hpp" + #include "opencv2/highgui/highgui.hpp" +#endif + +using namespace DJI::OSDK; +using namespace cv; +using namespace std; + +void show_rgb(CameraRGBImage img, void *p) +{ + string name = string(reinterpret_cast(p)); + cout << "#### Got image from:\t" << name << endl; +#ifdef OPEN_CV_INSTALLED + Mat mat(img.height, img.width, CV_8UC3, img.rawData.data(), img.width*3); + cvtColor(mat, mat, COLOR_RGB2BGR); + imshow(name,mat); + cv::waitKey(1); +#endif +} + +int main(int argc, char** argv) +{ + bool f = false; + bool m = false; + char c = 0; + cout << "Please enter the type of camera stream you want to view\n" + << "m: Main Camera\n" + << "f: FPV Camera" << endl; + cin >> c; + + switch(c) + { + case 'm': + m=true; break; + case 'f': + f=true; break; + default: + cout << "No camera selected"; + return 1; + } + + // Setup OSDK. + bool enableAdvancedSensing = true; + LinuxSetup linuxEnvironment(argc, argv, enableAdvancedSensing); + Vehicle* vehicle = linuxEnvironment.getVehicle(); + if (vehicle == NULL) + { + std::cout << "Vehicle not initialized, exiting.\n"; + return -1; + } + + char fpvName[] = "FPV_CAM"; + char mainName[] = "MAIN_CAM"; + + bool camResult = false; + if(f) + { + camResult = vehicle->advancedSensing->startFPVCameraStream(&show_rgb, &fpvName); + } + else if(m) + { + camResult = vehicle->advancedSensing->startMainCameraStream(&show_rgb, &mainName); + } + + if(!camResult) + { + cout << "Failed to open selected camera" << endl; + return 1; + } + + CameraRGBImage camImg; + + // main thread just sleep + // callback function will be called whenever a new image is ready + sleep(10); + + if(f) + { + vehicle->advancedSensing->stopFPVCameraStream(); + } + else if(m) + { + vehicle->advancedSensing->stopMainCameraStream(); + } + + return 0; +} diff --git a/sample/linux/advanced-sensing/camera_stream_poll_sample/CMakeLists.txt b/sample/linux/advanced-sensing/camera_stream_poll_sample/CMakeLists.txt new file mode 100644 index 00000000..0fd89840 --- /dev/null +++ b/sample/linux/advanced-sensing/camera_stream_poll_sample/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 2.8) +project(camera-stream-poll-sample) + +# Try to see if user has OpenCV installed +# if yes, default callback will display the image +find_package( OpenCV QUIET ) +if (OpenCV_FOUND) + message( "\n${PROJECT_NAME}...") + message( STATUS "Found OpenCV installed in the system, will use it to display image in AdvancedSensing APIs") + message( STATUS "OpenCV_INCLUDE_DIRS= ${OpenCV_INCLUDE_DIRS}") + message( STATUS "OpenCV_LIBRARIES=${OpenCV_LIBRARIES}") + add_definitions(-DOPEN_CV_INSTALLED) +else() + message( STATUS "Did not find OpenCV in the system, image data is inside RecvContainer as raw data") +endif () + +set(HELPER_FUNCTIONS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../common) +add_executable(${PROJECT_NAME} + ${HELPER_FUNCTIONS_DIR}/dji_linux_environment.cpp + ${HELPER_FUNCTIONS_DIR}/dji_linux_helpers.cpp + camera-stream-poll-sample.cpp + ) +target_include_directories(${PROJECT_NAME} PRIVATE ${OpenCV_INCLUDE_DIRS}) + +target_link_libraries(${PROJECT_NAME} + djiosdk-core + ) + +if (OpenCV_FOUND) + target_link_libraries(${PROJECT_NAME} + ${OpenCV_LIBS} + ) +endif () diff --git a/sample/linux/advanced-sensing/camera_stream_poll_sample/camera-stream-poll-sample.cpp b/sample/linux/advanced-sensing/camera_stream_poll_sample/camera-stream-poll-sample.cpp new file mode 100644 index 00000000..554fe4f9 --- /dev/null +++ b/sample/linux/advanced-sensing/camera_stream_poll_sample/camera-stream-poll-sample.cpp @@ -0,0 +1,144 @@ +/*! @file camera_stream_poll_sample.cpp + * @version 3.5 + * @date Dec 06 2017 + * + * @brief + * AdvancedSensing, Camera Stream API usage in a Linux environment. + * This sample shows how to poll new images from FPV camera or/and + * main camera from the main thread. + * (Optional) With OpenCV installed, user can visualize the images + * + * @copyright + * 2016-17 DJI. All rights reserved. + * */ + + +#include "dji_vehicle.hpp" +#include +#include "dji_linux_helpers.hpp" + +#ifdef OPEN_CV_INSTALLED + #include "opencv2/opencv.hpp" + #include "opencv2/highgui/highgui.hpp" +#endif + +using namespace DJI::OSDK; +using namespace cv; +using namespace std; + +void show_rgb(CameraRGBImage img, char* name) +{ + cout << "#### Got image from:\t" << string(name) << endl; +#ifdef OPEN_CV_INSTALLED + Mat mat(img.height, img.width, CV_8UC3, img.rawData.data(), img.width*3); + cvtColor(mat, mat, COLOR_RGB2BGR); + imshow(name,mat); + cv::waitKey(1); +#endif +} + +int main(int argc, char** argv) +{ + bool f = false; + bool m = false; + char c = 0; + cout << "Please enter the type of camera stream you want to view\n" + << "m: Main Camera\n" + << "f: FPV Camera\n" + << "b: both Cameras" << endl; + cin >> c; + + switch(c) + { + case 'm': + m=true; break; + case 'f': + f=true; break; + case 'b': + f=true; m=true; break; + default: + cout << "No camera selected"; + return 1; + } + + // Setup OSDK. + bool enableAdvancedSensing = true; + LinuxSetup linuxEnvironment(argc, argv, enableAdvancedSensing); + Vehicle* vehicle = linuxEnvironment.getVehicle(); + if (vehicle == NULL) + { + std::cout << "Vehicle not initialized, exiting.\n"; + return -1; + } + + bool fpvCamResult = false; + bool mainCamResult = false; + + if(f) + { + fpvCamResult = vehicle->advancedSensing->startFPVCameraStream(); + if(!fpvCamResult) + { + cout << "Failed to open FPV Camera" << endl; + } + } + + if(m) + { + mainCamResult = vehicle->advancedSensing->startMainCameraStream(); + if(!mainCamResult) + { + cout << "Failed to open Main Camera" << endl; + } + } + + if((!fpvCamResult) && (!mainCamResult)) + { + cout << "Failed to Open Either Cameras, exiting" << endl; + return 1; + } + + CameraRGBImage fpvImg; + CameraRGBImage mainImg; + char fpvName[] = "FPV_CAM"; + char mainName[] = "MAIN_CAM"; + for(int i=0; i<1000; i++) + { + if(f && fpvCamResult && vehicle->advancedSensing->newFPVCameraImageIsReady()) + { + if(vehicle->advancedSensing->getFPVCameraImage(fpvImg)) + { + show_rgb(fpvImg, fpvName); + } + else + { + cout << "Time out" << endl; + } + } + + if(m && mainCamResult && vehicle->advancedSensing->newMainCameraImageReady()) + { + + if(vehicle->advancedSensing->getMainCameraImage(mainImg)) + { + show_rgb(mainImg, mainName); + } + else + { + cout << "Time out" << endl; + } + } + usleep(2e4); + } + + if(f) + { + vehicle->advancedSensing->stopFPVCameraStream(); + } + else if(m) + { + vehicle->advancedSensing->stopMainCameraStream(); + } + + return 0; +} diff --git a/sample/linux/advanced-sensing/camera_stream_target_tracking_sample/CMakeLists.txt b/sample/linux/advanced-sensing/camera_stream_target_tracking_sample/CMakeLists.txt new file mode 100644 index 00000000..1a6fd1cc --- /dev/null +++ b/sample/linux/advanced-sensing/camera_stream_target_tracking_sample/CMakeLists.txt @@ -0,0 +1,64 @@ +cmake_minimum_required(VERSION 2.8) +project(camera-stream-target-tracking-sample) + +# Try to see if user has OpenCV installed +# if yes, default callback will display the image +find_package(OpenCV REQUIRED) +if (OpenCV_FOUND) + message( "\n${PROJECT_NAME}...") + message( STATUS "OpenCV_INCLUDE_DIRS= ${OpenCV_INCLUDE_DIRS}") + message( STATUS "OpenCV_LIBRARIES=${OpenCV_LIBRARIES}") +else() + message( STATUS "OpenCV is required for this sample to do the target tracking") +endif () + + +unset(KCFcpp_DIR) +find_path(KCFcpp_DIR + NAMES + KCFCpp.sh + PATHS + ${CMAKE_CURRENT_SOURCE_DIR}/KCFcpp + ) + +if(NOT KCFcpp_DIR) + message(STATUS "Target Tracking sample depends on KCFcpp library from https://github.com/joaofaro/KCFcpp.git") + message(STATUS "When you run make, we will try to clone the repo") + message(STATUS "This will happen only once as long as you do not delete it") + + include(${CMAKE_MODULE_PATH}/DownloadProject/DownloadProject.cmake) + download_project(PROJ kcf_cpp + GIT_REPOSITORY https://github.com/joaofaro/KCFcpp.git + GIT_TAG master + ${UPDATE_DISCONNECTED_IF_AVAILABLE} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/KCFcpp + ) + +endif() + + + +## To use this this repo, you need to run +## git clone https://github.com/joaofaro/KCFcpp.git +## under the current foler +include_directories(KCFcpp/src) +include_directories(${OpenCV_INCLUDE_DIRS}) + +add_library(kcf_tracker STATIC + KCFcpp/src/fhog.cpp + KCFcpp/src/kcftracker.cpp) +target_link_libraries(kcf_tracker ${OpenCV_LIBRARIES}) + +set(HELPER_FUNCTIONS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../common) +add_executable(${PROJECT_NAME} + ${HELPER_FUNCTIONS_DIR}/dji_linux_environment.cpp + ${HELPER_FUNCTIONS_DIR}/dji_linux_helpers.cpp + target_tracking.cpp + tracking_utility.cpp + ) +target_link_libraries(${PROJECT_NAME} + djiosdk-core + kcf_tracker + ${OpenCV_LIBRARIES} + ) + diff --git a/sample/linux/advanced-sensing/camera_stream_target_tracking_sample/target_tracking.cpp b/sample/linux/advanced-sensing/camera_stream_target_tracking_sample/target_tracking.cpp new file mode 100644 index 00000000..275a85d6 --- /dev/null +++ b/sample/linux/advanced-sensing/camera_stream_target_tracking_sample/target_tracking.cpp @@ -0,0 +1,178 @@ +#include "dji_vehicle.hpp" +#include +#include "dji_linux_helpers.hpp" +#include "tracking_utility.hpp" + +#include "opencv2/imgproc/imgproc.hpp" +#include "opencv2/highgui/highgui.hpp" +#include "kcftracker.hpp" + +#include +#include + +typedef std::chrono::time_point timer; +typedef std::chrono::duration duration; + +using namespace DJI::OSDK; +using namespace std; +using namespace cv; + +int main(int argc, char** argv) +{ + // Setup OSDK. + bool enableAdvancedSensing = true; + LinuxSetup linuxEnvironment(argc, argv, enableAdvancedSensing); + Vehicle* vehicle = linuxEnvironment.getVehicle(); + if (vehicle == NULL) + { + std::cout << "Vehicle not initialized, exiting.\n"; + return -1; + } + + // Initialize variables + int functionTimeout = 1; + // Obtain Control Authority + vehicle->obtainCtrlAuthority(functionTimeout); + + bool mainCamResult = vehicle->advancedSensing->startMainCameraStream(); + if(!mainCamResult) + { + cout << "Failed to Open Camera" << endl; + return 1; + } + + CameraRGBImage mainImg; + const char winName[]="My Camera"; + char message1[100]; + char message2[100]; + Rect roi(0,0,0,0); + + KCFTracker *tracker = NULL; + TrackingUtility tu; + + cv::namedWindow(winName,1); + cv::setMouseCallback(winName,TrackingUtility::mouseCallback, (void*)&tu); + + while(1) + { + char c = cv::waitKey(10); + if(c==27) + { + if(tracker != NULL) + { + delete tracker; + tracker = NULL; + } + break; // Quit if ESC is pressed + } + + tu.getKey(c); //Internal states will be updated based on key pressed. + + if(vehicle->advancedSensing->newMainCameraImageReady()) + { + int dx = 0; + int dy = 0; + int yawRate = 0; + int pitchRate = 0; + timer trackerStartTime, trackerFinishTime; + duration trackerTimeDiff; + + vehicle->advancedSensing->getMainCameraImage(mainImg); + Mat frame(mainImg.height, mainImg.width, CV_8UC3, mainImg.rawData.data(), mainImg.width*3); + + + switch(tu.getState()) + { + case TrackingUtility::STATE_IDLE: + roi = tu.getROI(); + sprintf(message2, "Please select ROI and press g"); + break; + + case TrackingUtility::STATE_INIT: + cout << "g pressed, initialize tracker" << endl; + sprintf(message2, "g pressed, initialize tracker"); + roi = tu.getROI(); + tracker = new KCFTracker(true, true, false, false); + tracker->init(roi, frame); + tu.startTracker(); + break; + + case TrackingUtility::STATE_ONGOING: + trackerStartTime = std::chrono::high_resolution_clock::now(); + roi = tracker->update(frame); + trackerFinishTime = std::chrono::high_resolution_clock::now(); + trackerTimeDiff = trackerFinishTime - trackerStartTime; + sprintf(message2, "Tracking: bounding box update time = %.2f ms\n", trackerTimeDiff.count()*1000.0); + + // send gimbal speed command + dx = (int)(roi.x + roi.width/2 - mainImg.width/2); + dy = (int)(roi.y + roi.height/2 - mainImg.height/2); + + yawRate = dx; + pitchRate = -dy; + + if(abs(dx) < 10) + { + yawRate = 0; + } + + if(abs(dy) < 10) + { + pitchRate = 0; + } + + DJI::OSDK::Gimbal::SpeedData gimbalSpeed; + gimbalSpeed.roll = 0; + gimbalSpeed.pitch = pitchRate; + gimbalSpeed.yaw = yawRate; + gimbalSpeed.gimbal_control_authority = 1; + + vehicle->gimbal->setSpeed(&gimbalSpeed); + + break; + + case TrackingUtility::STATE_STOP: + cout << "s pressed, stop tracker" << endl; + sprintf(message2, "s pressed, stop tracker"); + delete tracker; + tracker = NULL; + tu.stopTracker(); + roi = tu.getROI(); + break; + + default: + break; + } + + dx = roi.x + roi.width/2 - mainImg.width/2; + dy = roi.y + roi.height/2 - mainImg.height/2; + + cv::circle(frame, Point(mainImg.width/2, mainImg.height/2), 5, cv::Scalar(255,0,0), 2, 8); + if(roi.width != 0) + { + cv::circle(frame, Point(roi.x + roi.width/2, roi.y + roi.height/2), 3, cv::Scalar(0,0,255), 1, 8); + + cv::line(frame, Point(mainImg.width/2, mainImg.height/2), + Point(roi.x + roi.width/2, roi.y + roi.height/2), + cv::Scalar(0,255,255)); + } + + cv::rectangle(frame, roi, cv::Scalar(0,255,0), 1, 8, 0 ); + cvtColor(frame, frame, COLOR_RGB2BGR); + sprintf(message1,"dx=%04d, dy=%04d",dx, dy); + putText(frame, message1, Point2f(20,30), FONT_HERSHEY_SIMPLEX, 1, Scalar(0,255,0)); + putText(frame, message2, Point2f(20,60), FONT_HERSHEY_SIMPLEX, 1, Scalar(0,255,0)); + cv::imshow(winName, frame); + + } + } + + vehicle->advancedSensing->stopMainCameraStream(); + + if(tracker) + { + delete tracker; + } + + return 0; +} diff --git a/sample/linux/advanced-sensing/camera_stream_target_tracking_sample/tracking_utility.cpp b/sample/linux/advanced-sensing/camera_stream_target_tracking_sample/tracking_utility.cpp new file mode 100644 index 00000000..53cdcba4 --- /dev/null +++ b/sample/linux/advanced-sensing/camera_stream_target_tracking_sample/tracking_utility.cpp @@ -0,0 +1,94 @@ +// +// Created by zyli on 12/11/17. +// + +#include "tracking_utility.hpp" +#include +void TrackingUtility::mouseCallback(int event, int x, int y, int f, void *p) +{ + TrackingUtility *u = reinterpret_cast(p); + if(u->state != STATE_IDLE) + { + std::cout << "Currently tracking, press s key to stop" << std::endl; + return; + } + + switch(event) + { + case CV_EVENT_LBUTTONDOWN : + u->mouseClicked = true; + u->roiSelected = false; + u->P1 = cv::Point(x,y); + u->P2 = cv::Point(x,y); + break; + + case CV_EVENT_LBUTTONUP : + u->P2 = cv::Point(x,y); + u->mouseClicked=false; + if(u->P2 != u->P1) + { + u->roiSelected = true; + } + break; + + case CV_EVENT_MOUSEMOVE : + if(u->mouseClicked) + { + u->P2 = cv::Point(x,y); + } + break; + + default : + break; + } + + if(u->mouseClicked) + { + u->roi = cv::Rect(u->P1, u->P2); + printf("Current Region of Interest: %d, %d, %d, %d\n", u->roi.tl().x, u->roi.tl().y, u->roi.br().x, u->roi.br().y); + } +} + +cv::Rect TrackingUtility::getROI() +{ + return roi; +} + +TrackingUtility::TrackingState TrackingUtility::getState() +{ + return state; +} + +void TrackingUtility::startTracker() +{ + state = STATE_ONGOING; +} + +void TrackingUtility::stopTracker() +{ + state = STATE_IDLE; +} + +void TrackingUtility::getKey(char c) +{ + switch(c) + { + case 'g': + if( (state == STATE_IDLE) && (roiSelected == true)) + { + state = STATE_INIT; + } + break; + + case 's': + if( state == STATE_ONGOING ) + { + state = STATE_STOP; + roi = cv::Rect(0,0,0,0); //when we press s, should clear bounding box + } + break; + + default: + break; + } +} \ No newline at end of file diff --git a/sample/linux/advanced-sensing/camera_stream_target_tracking_sample/tracking_utility.hpp b/sample/linux/advanced-sensing/camera_stream_target_tracking_sample/tracking_utility.hpp new file mode 100644 index 00000000..4fc6b104 --- /dev/null +++ b/sample/linux/advanced-sensing/camera_stream_target_tracking_sample/tracking_utility.hpp @@ -0,0 +1,56 @@ +// +// Created by zyli on 12/11/17. +// + +#ifndef ONBOARDSDK_TRACKINGUTILITY_HPP +#define ONBOARDSDK_TRACKINGUTILITY_HPP + +#include "opencv2/opencv.hpp" +/*! @brief + * The TrackingUtility Class handles simple start and stop tracking logic + */ +class TrackingUtility +{ +public: + TrackingUtility() + : P1(0,0), + P2(0,0), + roi(0,0,0,0), + mouseClicked(false), + roiSelected(false), + state(STATE_IDLE) + { + } + + typedef enum TrackingState + { + STATE_IDLE, + STATE_INIT, + STATE_ONGOING, + STATE_STOP + } TrackingState; + + static void mouseCallback(int event, int x, int y, int f, void *p); + + cv::Point P1; + cv::Point P2; + bool mouseClicked; + cv::Rect roi; + + /*! + * start_tracking is set true when you select a region and press 'g' + * is set to false when you press 's' + */ + bool roiSelected; + TrackingState state; + TrackingState getState(); + + void startTracker(); + void stopTracker(); + + cv::Rect getROI(); + void getKey(char c); +}; + + +#endif //ONBOARDSDK_TRACKINGUTILITY_HPP diff --git a/sample/linux/advanced-sensing/stereo_vision_multi_thread_sample/CMakeLists.txt b/sample/linux/advanced-sensing/stereo_vision_multi_thread_sample/CMakeLists.txt new file mode 100644 index 00000000..9a21ca5c --- /dev/null +++ b/sample/linux/advanced-sensing/stereo_vision_multi_thread_sample/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 2.8) +project(stereo-vision-multi-thread-sample) + +# Try to see if user has OpenCV installed +# if yes, default callback will display the image +find_package( OpenCV 2 QUIET ) +if (OpenCV_FOUND) + message( "\n${PROJECT_NAME}...") + message( STATUS "Found OpenCV installed in the system, will use it to display image in AdvancedSensing APIs") + message( STATUS "OpenCV_INCLUDE_DIRS= ${OpenCV_INCLUDE_DIRS}") + message( STATUS "OpenCV_LIBRARIES=${OpenCV_LIBRARIES}") + add_definitions(-DOPEN_CV_INSTALLED) +else() + message( STATUS "Did not find OpenCV in the system, image data is inside RecvContainer as raw data") +endif () + +set(HELPER_FUNCTIONS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../common) +add_executable(${PROJECT_NAME} + ${HELPER_FUNCTIONS_DIR}/dji_linux_environment.cpp + ${HELPER_FUNCTIONS_DIR}/dji_linux_helpers.cpp + advanced_sensing_multi_thread_sample.cpp + utility_thread.cpp + image_process_container.cpp + ) + +target_include_directories(${PROJECT_NAME} PRIVATE ${OpenCV_INCLUDE_DIRS}) + +target_link_libraries(${PROJECT_NAME} + djiosdk-core + ) + +if (OpenCV_FOUND) + target_link_libraries(${PROJECT_NAME} + ${OpenCV_LIBRARIES} + ) +endif () + diff --git a/sample/linux/advanced-sensing/advanced_sensing_multi_thread_sample.cpp b/sample/linux/advanced-sensing/stereo_vision_multi_thread_sample/advanced_sensing_multi_thread_sample.cpp similarity index 100% rename from sample/linux/advanced-sensing/advanced_sensing_multi_thread_sample.cpp rename to sample/linux/advanced-sensing/stereo_vision_multi_thread_sample/advanced_sensing_multi_thread_sample.cpp diff --git a/sample/linux/advanced-sensing/advanced_sensing_multi_thread_sample.hpp b/sample/linux/advanced-sensing/stereo_vision_multi_thread_sample/advanced_sensing_multi_thread_sample.hpp similarity index 95% rename from sample/linux/advanced-sensing/advanced_sensing_multi_thread_sample.hpp rename to sample/linux/advanced-sensing/stereo_vision_multi_thread_sample/advanced_sensing_multi_thread_sample.hpp index e83fa39b..5b24b1cf 100644 --- a/sample/linux/advanced-sensing/advanced_sensing_multi_thread_sample.hpp +++ b/sample/linux/advanced-sensing/stereo_vision_multi_thread_sample/advanced_sensing_multi_thread_sample.hpp @@ -40,11 +40,12 @@ #include // Helpers -#include +#include "dji_linux_helpers.hpp" // Third party library #ifdef OPEN_CV_INSTALLED - #include +#include "opencv2/opencv.hpp" +#include "opencv2/highgui/highgui.hpp" #endif // Utility diff --git a/sample/linux/advanced-sensing/image_process_container.cpp b/sample/linux/advanced-sensing/stereo_vision_multi_thread_sample/image_process_container.cpp similarity index 100% rename from sample/linux/advanced-sensing/image_process_container.cpp rename to sample/linux/advanced-sensing/stereo_vision_multi_thread_sample/image_process_container.cpp diff --git a/sample/linux/advanced-sensing/image_process_container.hpp b/sample/linux/advanced-sensing/stereo_vision_multi_thread_sample/image_process_container.hpp similarity index 96% rename from sample/linux/advanced-sensing/image_process_container.hpp rename to sample/linux/advanced-sensing/stereo_vision_multi_thread_sample/image_process_container.hpp index 91b2848b..e7d73f2b 100644 --- a/sample/linux/advanced-sensing/image_process_container.hpp +++ b/sample/linux/advanced-sensing/stereo_vision_multi_thread_sample/image_process_container.hpp @@ -36,7 +36,8 @@ #include "dji_vehicle.hpp" #ifdef OPEN_CV_INSTALLED - #include +#include "opencv2/opencv.hpp" +#include "opencv2/highgui/highgui.hpp" #endif class UtilityThread; @@ -91,4 +92,4 @@ private: }; -#endif //ONBOARDSDK_IMAGE_CONTAINER_H \ No newline at end of file +#endif //ONBOARDSDK_IMAGE_CONTAINER_H diff --git a/sample/linux/advanced-sensing/utility_thread.cpp b/sample/linux/advanced-sensing/stereo_vision_multi_thread_sample/utility_thread.cpp similarity index 100% rename from sample/linux/advanced-sensing/utility_thread.cpp rename to sample/linux/advanced-sensing/stereo_vision_multi_thread_sample/utility_thread.cpp diff --git a/sample/linux/advanced-sensing/utility_thread.hpp b/sample/linux/advanced-sensing/stereo_vision_multi_thread_sample/utility_thread.hpp similarity index 100% rename from sample/linux/advanced-sensing/utility_thread.hpp rename to sample/linux/advanced-sensing/stereo_vision_multi_thread_sample/utility_thread.hpp diff --git a/sample/linux/advanced-sensing/stereo_vision_single_thread_sample/CMakeLists.txt b/sample/linux/advanced-sensing/stereo_vision_single_thread_sample/CMakeLists.txt new file mode 100644 index 00000000..a4ac91c3 --- /dev/null +++ b/sample/linux/advanced-sensing/stereo_vision_single_thread_sample/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 2.8) +project(stereo-vision-single-thread-sample) + +# Try to see if user has OpenCV installed +# if yes, default callback will display the image +find_package( OpenCV QUIET ) +if (OpenCV_FOUND) + message( "\n${PROJECT_NAME}...") + message( STATUS "Found OpenCV installed in the system, will use it to display image in AdvancedSensing APIs") + message( STATUS "OpenCV_INCLUDE_DIRS= ${OpenCV_INCLUDE_DIRS}") + message( STATUS "OpenCV_LIBRARIES=${OpenCV_LIBRARIES}") + add_definitions(-DOPEN_CV_INSTALLED) +else() + message( STATUS "Did not find OpenCV in the system, image data is inside RecvContainer as raw data") +endif () + +set(HELPER_FUNCTIONS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../common) +add_executable(${PROJECT_NAME} + ${HELPER_FUNCTIONS_DIR}/dji_linux_environment.cpp + ${HELPER_FUNCTIONS_DIR}/dji_linux_helpers.cpp + advanced_sensing_sample.cpp + ) + +target_include_directories(${PROJECT_NAME} PRIVATE ${OpenCV_INCLUDE_DIRS}) + +target_link_libraries(${PROJECT_NAME} + djiosdk-core + ) + +if (OpenCV_FOUND) + target_link_libraries(${PROJECT_NAME} + ${OpenCV_LIBRARIES} + ) +endif () diff --git a/sample/linux/advanced-sensing/advanced_sensing_sample.cpp b/sample/linux/advanced-sensing/stereo_vision_single_thread_sample/advanced_sensing_sample.cpp similarity index 100% rename from sample/linux/advanced-sensing/advanced_sensing_sample.cpp rename to sample/linux/advanced-sensing/stereo_vision_single_thread_sample/advanced_sensing_sample.cpp diff --git a/sample/linux/advanced-sensing/advanced_sensing_sample.hpp b/sample/linux/advanced-sensing/stereo_vision_single_thread_sample/advanced_sensing_sample.hpp similarity index 94% rename from sample/linux/advanced-sensing/advanced_sensing_sample.hpp rename to sample/linux/advanced-sensing/stereo_vision_single_thread_sample/advanced_sensing_sample.hpp index 79e5e095..2856d375 100644 --- a/sample/linux/advanced-sensing/advanced_sensing_sample.hpp +++ b/sample/linux/advanced-sensing/stereo_vision_single_thread_sample/advanced_sensing_sample.hpp @@ -39,10 +39,11 @@ #include // Helpers -#include +#include "dji_linux_helpers.hpp" #ifdef OPEN_CV_INSTALLED - #include +#include "opencv2/opencv.hpp" +#include "opencv2/highgui/highgui.hpp" #endif static void stereoImg240pCallback(DJI::OSDK::Vehicle *vehiclePtr, DJI::OSDK::RecvContainer recvFrame, DJI::OSDK::UserData userData);