Compare commits
1 Commits
videoseg-p
...
videorecog
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5590f7808b |
@@ -1,3 +1,6 @@
|
||||
2021-02-01 Version: patch
|
||||
- Release UnderstandVideoContent.
|
||||
|
||||
2021-02-01 Version: patch
|
||||
- Release SegmentGreenScreenVideo.
|
||||
|
||||
|
||||
@@ -26,7 +26,9 @@ set(videorecog_public_header_model
|
||||
include/alibabacloud/videorecog/model/GenerateVideoCoverRequest.h
|
||||
include/alibabacloud/videorecog/model/GenerateVideoCoverResult.h
|
||||
include/alibabacloud/videorecog/model/GetAsyncJobResultRequest.h
|
||||
include/alibabacloud/videorecog/model/GetAsyncJobResultResult.h )
|
||||
include/alibabacloud/videorecog/model/GetAsyncJobResultResult.h
|
||||
include/alibabacloud/videorecog/model/UnderstandVideoContentRequest.h
|
||||
include/alibabacloud/videorecog/model/UnderstandVideoContentResult.h )
|
||||
|
||||
set(videorecog_src
|
||||
src/VideorecogClient.cc
|
||||
@@ -35,7 +37,9 @@ set(videorecog_src
|
||||
src/model/GenerateVideoCoverRequest.cc
|
||||
src/model/GenerateVideoCoverResult.cc
|
||||
src/model/GetAsyncJobResultRequest.cc
|
||||
src/model/GetAsyncJobResultResult.cc )
|
||||
src/model/GetAsyncJobResultResult.cc
|
||||
src/model/UnderstandVideoContentRequest.cc
|
||||
src/model/UnderstandVideoContentResult.cc )
|
||||
|
||||
add_library(videorecog ${LIB_TYPE}
|
||||
${videorecog_public_header}
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "model/GenerateVideoCoverResult.h"
|
||||
#include "model/GetAsyncJobResultRequest.h"
|
||||
#include "model/GetAsyncJobResultResult.h"
|
||||
#include "model/UnderstandVideoContentRequest.h"
|
||||
#include "model/UnderstandVideoContentResult.h"
|
||||
|
||||
|
||||
namespace AlibabaCloud
|
||||
@@ -46,6 +48,9 @@ namespace AlibabaCloud
|
||||
typedef Outcome<Error, Model::GetAsyncJobResultResult> GetAsyncJobResultOutcome;
|
||||
typedef std::future<GetAsyncJobResultOutcome> GetAsyncJobResultOutcomeCallable;
|
||||
typedef std::function<void(const VideorecogClient*, const Model::GetAsyncJobResultRequest&, const GetAsyncJobResultOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetAsyncJobResultAsyncHandler;
|
||||
typedef Outcome<Error, Model::UnderstandVideoContentResult> UnderstandVideoContentOutcome;
|
||||
typedef std::future<UnderstandVideoContentOutcome> UnderstandVideoContentOutcomeCallable;
|
||||
typedef std::function<void(const VideorecogClient*, const Model::UnderstandVideoContentRequest&, const UnderstandVideoContentOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UnderstandVideoContentAsyncHandler;
|
||||
|
||||
VideorecogClient(const Credentials &credentials, const ClientConfiguration &configuration);
|
||||
VideorecogClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
|
||||
@@ -60,6 +65,9 @@ namespace AlibabaCloud
|
||||
GetAsyncJobResultOutcome getAsyncJobResult(const Model::GetAsyncJobResultRequest &request)const;
|
||||
void getAsyncJobResultAsync(const Model::GetAsyncJobResultRequest& request, const GetAsyncJobResultAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
GetAsyncJobResultOutcomeCallable getAsyncJobResultCallable(const Model::GetAsyncJobResultRequest& request) const;
|
||||
UnderstandVideoContentOutcome understandVideoContent(const Model::UnderstandVideoContentRequest &request)const;
|
||||
void understandVideoContentAsync(const Model::UnderstandVideoContentRequest& request, const UnderstandVideoContentAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
UnderstandVideoContentOutcomeCallable understandVideoContentCallable(const Model::UnderstandVideoContentRequest& request) const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<EndpointProvider> endpointProvider_;
|
||||
|
||||
@@ -35,14 +35,14 @@ namespace AlibabaCloud
|
||||
GetAsyncJobResultRequest();
|
||||
~GetAsyncJobResultRequest();
|
||||
|
||||
bool getAsync()const;
|
||||
void setAsync(bool async);
|
||||
std::string getJobId()const;
|
||||
void setJobId(const std::string& jobId);
|
||||
bool getAsync()const;
|
||||
void setAsync(bool async);
|
||||
|
||||
private:
|
||||
bool async_;
|
||||
std::string jobId_;
|
||||
bool async_;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_VIDEORECOG_MODEL_UNDERSTANDVIDEOCONTENTREQUEST_H_
|
||||
#define ALIBABACLOUD_VIDEORECOG_MODEL_UNDERSTANDVIDEOCONTENTREQUEST_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <alibabacloud/core/RpcServiceRequest.h>
|
||||
#include <alibabacloud/videorecog/VideorecogExport.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Videorecog
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_VIDEORECOG_EXPORT UnderstandVideoContentRequest : public RpcServiceRequest
|
||||
{
|
||||
|
||||
public:
|
||||
UnderstandVideoContentRequest();
|
||||
~UnderstandVideoContentRequest();
|
||||
|
||||
bool getAsync()const;
|
||||
void setAsync(bool async);
|
||||
std::string getVideoURL()const;
|
||||
void setVideoURL(const std::string& videoURL);
|
||||
|
||||
private:
|
||||
bool async_;
|
||||
std::string videoURL_;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_VIDEORECOG_MODEL_UNDERSTANDVIDEOCONTENTREQUEST_H_
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_VIDEORECOG_MODEL_UNDERSTANDVIDEOCONTENTRESULT_H_
|
||||
#define ALIBABACLOUD_VIDEORECOG_MODEL_UNDERSTANDVIDEOCONTENTRESULT_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <alibabacloud/core/ServiceResult.h>
|
||||
#include <alibabacloud/videorecog/VideorecogExport.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Videorecog
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_VIDEORECOG_EXPORT UnderstandVideoContentResult : public ServiceResult
|
||||
{
|
||||
public:
|
||||
struct Data
|
||||
{
|
||||
struct VideoInfo
|
||||
{
|
||||
float fps;
|
||||
long duration;
|
||||
long height;
|
||||
long width;
|
||||
};
|
||||
std::string tagInfo;
|
||||
VideoInfo videoInfo;
|
||||
};
|
||||
|
||||
|
||||
UnderstandVideoContentResult();
|
||||
explicit UnderstandVideoContentResult(const std::string &payload);
|
||||
~UnderstandVideoContentResult();
|
||||
std::string getMessage()const;
|
||||
Data getData()const;
|
||||
std::string getCode()const;
|
||||
|
||||
protected:
|
||||
void parse(const std::string &payload);
|
||||
private:
|
||||
std::string message_;
|
||||
Data data_;
|
||||
std::string code_;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_VIDEORECOG_MODEL_UNDERSTANDVIDEOCONTENTRESULT_H_
|
||||
@@ -159,3 +159,39 @@ VideorecogClient::GetAsyncJobResultOutcomeCallable VideorecogClient::getAsyncJob
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
VideorecogClient::UnderstandVideoContentOutcome VideorecogClient::understandVideoContent(const UnderstandVideoContentRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
if (!endpointOutcome.isSuccess())
|
||||
return UnderstandVideoContentOutcome(endpointOutcome.error());
|
||||
|
||||
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return UnderstandVideoContentOutcome(UnderstandVideoContentResult(outcome.result()));
|
||||
else
|
||||
return UnderstandVideoContentOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void VideorecogClient::understandVideoContentAsync(const UnderstandVideoContentRequest& request, const UnderstandVideoContentAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
handler(this, request, understandVideoContent(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
VideorecogClient::UnderstandVideoContentOutcomeCallable VideorecogClient::understandVideoContentCallable(const UnderstandVideoContentRequest &request) const
|
||||
{
|
||||
auto task = std::make_shared<std::packaged_task<UnderstandVideoContentOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
return this->understandVideoContent(request);
|
||||
});
|
||||
|
||||
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,17 +27,6 @@ GetAsyncJobResultRequest::GetAsyncJobResultRequest() :
|
||||
GetAsyncJobResultRequest::~GetAsyncJobResultRequest()
|
||||
{}
|
||||
|
||||
bool GetAsyncJobResultRequest::getAsync()const
|
||||
{
|
||||
return async_;
|
||||
}
|
||||
|
||||
void GetAsyncJobResultRequest::setAsync(bool async)
|
||||
{
|
||||
async_ = async;
|
||||
setBodyParameter("Async", async ? "true" : "false");
|
||||
}
|
||||
|
||||
std::string GetAsyncJobResultRequest::getJobId()const
|
||||
{
|
||||
return jobId_;
|
||||
@@ -49,3 +38,14 @@ void GetAsyncJobResultRequest::setJobId(const std::string& jobId)
|
||||
setBodyParameter("JobId", jobId);
|
||||
}
|
||||
|
||||
bool GetAsyncJobResultRequest::getAsync()const
|
||||
{
|
||||
return async_;
|
||||
}
|
||||
|
||||
void GetAsyncJobResultRequest::setAsync(bool async)
|
||||
{
|
||||
async_ = async;
|
||||
setBodyParameter("Async", async ? "true" : "false");
|
||||
}
|
||||
|
||||
|
||||
@@ -40,16 +40,16 @@ void GetAsyncJobResultResult::parse(const std::string &payload)
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
auto dataNode = value["Data"];
|
||||
if(!dataNode["JobId"].isNull())
|
||||
data_.jobId = dataNode["JobId"].asString();
|
||||
if(!dataNode["Status"].isNull())
|
||||
data_.status = dataNode["Status"].asString();
|
||||
if(!dataNode["Result"].isNull())
|
||||
data_.result = dataNode["Result"].asString();
|
||||
if(!dataNode["ErrorCode"].isNull())
|
||||
data_.errorCode = dataNode["ErrorCode"].asString();
|
||||
if(!dataNode["ErrorMessage"].isNull())
|
||||
data_.errorMessage = dataNode["ErrorMessage"].asString();
|
||||
if(!dataNode["JobId"].isNull())
|
||||
data_.jobId = dataNode["JobId"].asString();
|
||||
if(!dataNode["Result"].isNull())
|
||||
data_.result = dataNode["Result"].asString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
51
videorecog/src/model/UnderstandVideoContentRequest.cc
Normal file
51
videorecog/src/model/UnderstandVideoContentRequest.cc
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <alibabacloud/videorecog/model/UnderstandVideoContentRequest.h>
|
||||
|
||||
using AlibabaCloud::Videorecog::Model::UnderstandVideoContentRequest;
|
||||
|
||||
UnderstandVideoContentRequest::UnderstandVideoContentRequest() :
|
||||
RpcServiceRequest("videorecog", "2020-03-20", "UnderstandVideoContent")
|
||||
{
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
UnderstandVideoContentRequest::~UnderstandVideoContentRequest()
|
||||
{}
|
||||
|
||||
bool UnderstandVideoContentRequest::getAsync()const
|
||||
{
|
||||
return async_;
|
||||
}
|
||||
|
||||
void UnderstandVideoContentRequest::setAsync(bool async)
|
||||
{
|
||||
async_ = async;
|
||||
setBodyParameter("Async", async ? "true" : "false");
|
||||
}
|
||||
|
||||
std::string UnderstandVideoContentRequest::getVideoURL()const
|
||||
{
|
||||
return videoURL_;
|
||||
}
|
||||
|
||||
void UnderstandVideoContentRequest::setVideoURL(const std::string& videoURL)
|
||||
{
|
||||
videoURL_ = videoURL;
|
||||
setBodyParameter("VideoURL", videoURL);
|
||||
}
|
||||
|
||||
75
videorecog/src/model/UnderstandVideoContentResult.cc
Normal file
75
videorecog/src/model/UnderstandVideoContentResult.cc
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <alibabacloud/videorecog/model/UnderstandVideoContentResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Videorecog;
|
||||
using namespace AlibabaCloud::Videorecog::Model;
|
||||
|
||||
UnderstandVideoContentResult::UnderstandVideoContentResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
UnderstandVideoContentResult::UnderstandVideoContentResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
UnderstandVideoContentResult::~UnderstandVideoContentResult()
|
||||
{}
|
||||
|
||||
void UnderstandVideoContentResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
auto dataNode = value["Data"];
|
||||
if(!dataNode["TagInfo"].isNull())
|
||||
data_.tagInfo = dataNode["TagInfo"].asString();
|
||||
auto videoInfoNode = dataNode["VideoInfo"];
|
||||
if(!videoInfoNode["Fps"].isNull())
|
||||
data_.videoInfo.fps = std::stof(videoInfoNode["Fps"].asString());
|
||||
if(!videoInfoNode["Duration"].isNull())
|
||||
data_.videoInfo.duration = std::stol(videoInfoNode["Duration"].asString());
|
||||
if(!videoInfoNode["Height"].isNull())
|
||||
data_.videoInfo.height = std::stol(videoInfoNode["Height"].asString());
|
||||
if(!videoInfoNode["Width"].isNull())
|
||||
data_.videoInfo.width = std::stol(videoInfoNode["Width"].asString());
|
||||
if(!value["Message"].isNull())
|
||||
message_ = value["Message"].asString();
|
||||
if(!value["Code"].isNull())
|
||||
code_ = value["Code"].asString();
|
||||
|
||||
}
|
||||
|
||||
std::string UnderstandVideoContentResult::getMessage()const
|
||||
{
|
||||
return message_;
|
||||
}
|
||||
|
||||
UnderstandVideoContentResult::Data UnderstandVideoContentResult::getData()const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
std::string UnderstandVideoContentResult::getCode()const
|
||||
{
|
||||
return code_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user