/** * @file KglStream.h * * Copyright (c) 2019 Keyence Corporation. * All rights reserved. * */ #pragma once #include #include #include #include #include namespace Keyence { class KglDevice; class KglStreamEventSink; class KglGenParameterArray; //------------------------------------------------------------------------- class KglBuffer; namespace Impl { class KglStreamImpl; } //------------------------------------------------------------ /** * \~English @brief Acquires image data from the camera. * \~Japanese @brief カメラから画像データを取得するためのクラスです。 */ class KGLLIB_API KglStream { public: friend class Impl::KglStreamImpl; //------------------------------------------------------------ /** * \~English @brief Default constructor. * \~Japanese @brief デフォルトコンストラクタ。 */ KglStream(); //------------------------------------------------------------ /** * \~English @brief Destructor. * \~Japanese @brief デストラクタ。 */ ~KglStream(); //------------------------------------------------------------ /** * \~English @brief Open a stream. * \~Japanese @brief ストリームを開きます。 * \~English @param [in] device Camera whose stream is to be opened. * \~Japanese @param [in] device ストリームを開くカメラ。 * \~English @retval KGL_ERR_INVALID_PARAMETER An invalid parameter has been passed to the argument. * \~Japanese @retval KGL_ERR_INVALID_PARAMETER 引数に不正なパラメータが渡されました * \~English @retval KGL_NOT_ENOUGH_MEMORY Allocation failed. * \~Japanese @retval KGL_NOT_ENOUGH_MEMORY アロケートに失敗しました。 * \~English @retval KGL_DEVICE_NOT_CONNECT No camera is connected. * \~Japanese @retval KGL_DEVICE_NOT_CONNECT カメラが接続されていません。 * \~English @retval KGL_BAD_VERSION The driver version is invalid. * \~Japanese @retval KGL_BAD_VERSION ドライババージョンが正しくありません。 * \~English @retval KGL_ERR_TIMEOUT A timeout has occurred when the destination of a stream was set. * \~Japanese @retval KGL_ERR_TIMEOUT ストリームの宛先を設定時にタイムアウトが発生しました。 * \~English @retval KGL_GENERIC_ERROR An unexpected exception has occurred. * \~Japanese @retval KGL_GENERIC_ERROR 予期しない例外が発生しました。 * \~English @retval KGL_SUCCESS Success. * \~Japanese @retval KGL_SUCCESS 成功。 */ KglResult open(KglDevice& device); //------------------------------------------------------------ /** * \~English @brief Closes a stream. * \~Japanese @brief ストリームを閉じます。 * \~English @param [in] device Camera whose steam is to be closed. * \~Japanese @param [in] device ストリームを閉じるカメラ。 * \~English @retval KGL_ERR_INVALID_PARAMETER An invalid parameter has been passed to the argument. * \~Japanese @retval KGL_ERR_INVALID_PARAMETER 引数に不正なパラメータが渡されました。 * \~English @retval KGL_DEVICE_NOT_CONNECT No camera is connected. * \~Japanese @retval KGL_DEVICE_NOT_CONNECT カメラが接続されていません。 * \~English @retval KGL_SUCCESS Success. * \~Japanese @retval KGL_SUCCESS 成功。 */ KglResult close(KglDevice& device); //------------------------------------------------------------ /** * \~English @brief Retrieves whether the stream is open. * \~Japanese @brief ストリームが開いているか否かを取得します。 * \~English @retval true The stream is open. * \~Japanese @retval true ストリームは開いています。 * \~English @retval false The stream is closed. * \~Japanese @retval false ストリームは閉じています。 */ bool isOpen() const; //------------------------------------------------------------ /** * \~English @brief Retrieves the features for a stream. * \~Japanese @brief ストリームのFeatureを取得します。 * \~English @return Pointer to the KglGenParameterArray object. Returns NULL if not available. * \~Japanese @return KglGenParameterArrayオブジェクトへのポインタ。取得できない場合はNULLを返します。 */ KglGenParameterArray* getStreamParameters(); //------------------------------------------------------------ /** * \~English @brief Retrieves the number of buffers being queued. * \~Japanese @brief キューイングされているバッファ数を取得します。 * \~English @return Number of buffers. * \~Japanese @return バッファ数。 */ uint32_t getQueuedBufferCount() const; //------------------------------------------------------------ /** * \~English @brief Retrieves the number of buffers being queued. * \~Japanese @brief キューイングされているバッファ数を取得します。 * \~English @return Number of buffers. * \~Japanese @return バッファ数。 */ uint32_t getQueuedBufferMaximum() const; //------------------------------------------------------------ /** * \~English @brief Queues the buffer for receiving the stream. * \~Japanese @brief ストリームを受信するバッファをキューイングします。 * \~English @param [in] pBuffer Buffer for receiving the stream. * \~Japanese @param [in] pBuffer ストリーム受信バッファ。 * \~English @retval KGL_ERR_INVALID_PARAMETER An invalid parameter has been passed to the argument. * \~Japanese @retval KGL_ERR_INVALID_PARAMETER 引数に不正なパラメータが渡されました。 * \~English @retval KGL_DEVICE_NOT_CONNECT The camera or stream is not connected. * \~Japanese @retval KGL_DEVICE_NOT_CONNECT カメラもしくはストリームが未接続です。 * \~English @retval KGL_NOT_ENOUGH_MEMORY Memory is insufficient. * \~Japanese @retval KGL_NOT_ENOUGH_MEMORY メモリが不足しています。 * \~English @retval KGL_NO_MORE_ENTRY No more buffer entries are available. * \~Japanese @retval KGL_NO_MORE_ENTRY バッファのエントリーがこれ以上ありません。 * \~English @retval KGL_GENERIC_ERROR An unexpected exception has occurred. * \~Japanese @retval KGL_GENERIC_ERROR 予期しない例外が発生しました。 * \~English @retval KGL_PENDING The buffer has been queued. * \~Japanese @retval KGL_PENDING バッファをキューに入れました。 */ KglResult queueBuffer(KglBuffer* pBuffer); //------------------------------------------------------------ /** * \~English @brief Starts acquiring images. To acquire the captured images, use retrieveBuffer(). * To stop acquiring images, call stopAcquisition(). * \~Japanese @brief 画像の取り込みを開始します。取り込んだ画像は retrieveBuffer() から取得してください。 * 終了は stopAcquisition() を呼び終了してください。 * \~English @param [in] device Camera to which the stream is to be connected. * \~Japanese @param [in] device ストリーム接続先のカメラ。 * \~English @retval KGL_ERR_INVALID_PARAMETER An invalid parameter has been passed to the argument. * \~Japanese @retval KGL_ERR_INVALID_PARAMETER 引数に不正なパラメータが渡されました。 * \~English @retval KGL_DEVICE_NOT_CONNECT The camera is not connected. Or connecting the stream failed. * \~Japanese @retval KGL_DEVICE_NOT_CONNECT カメラが未接続。または、ストリームの接続に失敗しました。 * \~English @retval KGL_GENERIC_ERROR An unexpected exception has occurred. * \~Japanese @retval KGL_GENERIC_ERROR 予期しない例外が発生しました。 * \~English @retval KGL_SUCCESS Success. * \~Japanese @retval KGL_SUCCESS 成功。 */ KglResult startAcquisition(KglDevice& device); //------------------------------------------------------------ /** * \~English @brief Stops acquiring images. * \~Japanese @brief 画像の取り込みを停止します。 * \~English @param [in] device Camera to which the stream is to be connected. * \~Japanese @param [in] device ストリーム接続先のカメラ。 * \~English @retval KGL_ERR_INVALID_PARAMETER An invalid parameter has been passed to the argument. * \~Japanese @retval KGL_ERR_INVALID_PARAMETER 引数に不正なパラメータが渡されました。 * \~English @retval KGL_DEVICE_NOT_CONNECT The camera or stream is not connected. * \~Japanese @retval KGL_DEVICE_NOT_CONNECT カメラもしくはストリームが未接続です。 * \~English @retval KGL_GENERIC_ERROR An unexpected exception has occurred. * \~Japanese @retval KGL_GENERIC_ERROR 予期しない例外が発生しました。 * \~English @retval KGL_SUCCESS Success. * \~Japanese @retval KGL_SUCCESS 成功。 */ KglResult stopAcquisition(KglDevice& device); //------------------------------------------------------------ /** * \~English @brief Retrieves the buffer for receiving the stream. * \~Japanese @brief ストリームを受信したバッファを取得します。 * \~English @param [in] ppBuffer Buffer for receiving the stream. * \~Japanese @param [in] ppBuffer ストリーム受信バッファ。 * \~English @param [out] operationResult Result of buffer retrieval. See KglResult.h. * - KGL_SUCCESS * - KGL_ERR_NOT_INITIALIZED * - KGL_ERR_TIMEOUT * - KGL_ABORTED * - KGL_MISSING_PACKETS * - KGL_BUFFER_TOO_SMALL * - KGL_IMAGE_ERROR * - KGL_RESENDS_FAILURE * - KGL_TOO_MANY_RESENDS * - KGL_TOO_MANY_CONSECUTIVE_RESENDS * - KGL_INVALID_DATA_FORMAT * - KGL_AUTO_ABORTED * - KGL_ERR_OVERFLOW * \~Japanese @param [out] operationResult バッファ取得結果です。各出力値についてはKglResult.hをご参照ください。 * - KGL_SUCCESS * - KGL_ERR_NOT_INITIALIZED * - KGL_ERR_TIMEOUT * - KGL_ABORTED * - KGL_MISSING_PACKETS * - KGL_BUFFER_TOO_SMALL * - KGL_IMAGE_ERROR * - KGL_RESENDS_FAILURE * - KGL_TOO_MANY_RESENDS * - KGL_TOO_MANY_CONSECUTIVE_RESENDS * - KGL_INVALID_DATA_FORMAT * - KGL_AUTO_ABORTED * - KGL_ERR_OVERFLOW * \~English @param [in] time_out Timeout duration. * \~Japanese @param [in] time_out タイムアウト時間。 * \~English @retval KGL_ERR_INVALID_PARAMETER An invalid parameter has been passed to the argument. * \~Japanese @retval KGL_ERR_INVALID_PARAMETER 引数に不正なパラメータが渡されました。 * \~English @retval KGL_DEVICE_NOT_CONNECT The camera or stream is not connected. * \~Japanese @retval KGL_DEVICE_NOT_CONNECT カメラもしくはストリームが未接続です。 * \~English @retval KGL_ERR_TIMEOUT A timeout has occurred. * \~Japanese @retval KGL_ERR_TIMEOUT タイムアウトが発生しました。 * \~English @retval KGL_NO_MORE_ENTRY No buffer can be retrieved. * \~Japanese @retval KGL_NO_MORE_ENTRY 取得できるバッファがありません。 * \~English @retval KGL_ERR_BUSY The status is busy. * \~Japanese @retval KGL_ERR_BUSY ビジー状態です。 * \~English @retval KGL_GENERIC_ERROR An unexpected exception has occurred. * \~Japanese @retval KGL_GENERIC_ERROR 予期しない例外が発生しました。 * \~English @retval KGL_SUCCESS Success. * \~Japanese @retval KGL_SUCCESS 成功。 */ KglResult retrieveBuffer(KglBuffer** ppBuffer, KglResult& operationResult, uint32_t time_out = 0xFFFFFFFF); //------------------------------------------------------------ /** * \~English @brief Imports the stream settings from a file to the camera. The settings are applied to the values of features that can be retrieved by getStreamParameters(). * \~Japanese @brief ストリームの設定をファイルからカメラへインポートします。 getStreamParameters() で取得できるFeatureの値へ反映されます。 * \~English @param [in] filePath Path of the communication settings file to be imported. * \~Japanese @param [in] filePath インポート元の通信設定ファイルパス。 * \~English @retval KGL_DEVICE_NOT_CONNECT Not connected to the camera. * \~Japanese @retval KGL_DEVICE_NOT_CONNECT カメラと接続されていませんでした。 * \~English @retval KGL_CANNOT_OPEN_FILE Failed to open the stream settings file. * \~Japanese @retval KGL_CANNOT_OPEN_FILE ストリームの設定ファイルのOpenに失敗しました。 * \~English @retval KGL_FILE_ERROR Failed to load a stream settings file. * \~Japanese @retval KGL_FILE_ERROR ストリームの設定ファイルの読込に失敗しました。 * \~English @retval KGL_NO_AVAILABLE_DATA The data stored in the stream settings file was invalid. * \~Japanese @retval KGL_NO_AVAILABLE_DATA ストリームの設定ファイルに格納されるデータが不正でした。 * \~English @retval KGL_ERR_INVALID_PARAMETER An invalid parameter has been passed to the argument. One possible cause is that the file path or the extension is not correct. * \~Japanese @retval KGL_ERR_INVALID_PARAMETER 引数に不正なパラメータが渡されました。ファイルパス、拡張子が正しくないなどが理由として考えられます。 * \~English @retval KGL_GENERIC_ERROR An unexpected exception has occurred. * \~Japanese @retval KGL_GENERIC_ERROR 予期しない例外が発生しました。 * \~English @retval KGL_SUCCESS Success. * \~Japanese @retval KGL_SUCCESS 成功。 */ KglResult importStreamParameters(const KglString& filePath); //------------------------------------------------------------ /** * \~English @brief Exports the stream settings from the camera to a file. Outputs the values of features that can be retrieved by getStreamParameters(). * \~Japanese @brief ストリームの設定をカメラからファイルへエクスポートします。 getStreamParameters() で取得できるFeatureの値を出力します。 * \~English @param [in] filePath Path of the communication settings file export destination. * \~Japanese @param [in] filePath エクスポート先の通信設定ファイルパス。 * \~English @retval KGL_DEVICE_NOT_CONNECT Not connected to the camera. * \~Japanese @retval KGL_DEVICE_NOT_CONNECT カメラと接続されていませんでした。 * \~English @retval KGL_CANNOT_OPEN_FILE Failed to open the stream settings file. * \~Japanese @retval KGL_CANNOT_OPEN_FILE ストリームの設定ファイルのOpenに失敗しました。 * \~English @retval KGL_FILE_ERROR Failed to load a stream settings file. * \~Japanese @retval KGL_FILE_ERROR ストリームの設定ファイルの読込に失敗しました。 * \~English @retval KGL_ERR_INVALID_PARAMETER An invalid parameter has been passed to the argument. One possible cause is that the file path or the extension is not correct. * \~Japanese @retval KGL_ERR_INVALID_PARAMETER 引数に不正なパラメータが渡されました。ファイルパス、拡張子が正しくないなどが理由として考えられます。 * \~English @retval KGL_GENERIC_ERROR An unexpected exception has occurred. * \~Japanese @retval KGL_GENERIC_ERROR 予期しない例外が発生しました。 * \~English @retval KGL_SUCCESS Success. * \~Japanese @retval KGL_SUCCESS 成功。 */ KglResult exportStreamParameters(const KglString& filePath); private: Impl::KglStreamImpl* _pImpl; }; }; //end of namespace Keyence