Check if an input image wasn't Image on several functions in CameraFeed

(cherry picked from commit 916e576021)
This commit is contained in:
Kongfa Waroros 2021-03-14 16:47:21 +07:00 committed by Rémi Verschelde
parent 592c0632a1
commit 5f4ac65251
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 10 additions and 6 deletions

View file

@ -172,7 +172,8 @@ CameraFeed::~CameraFeed() {
vs->free(texture[CameraServer::FEED_CBCR_IMAGE]);
}
void CameraFeed::set_RGB_img(Ref<Image> p_rgb_img) {
void CameraFeed::set_RGB_img(const Ref<Image> &p_rgb_img) {
ERR_FAIL_COND(p_rgb_img.is_null());
if (active) {
VisualServer *vs = VisualServer::get_singleton();
@ -192,7 +193,8 @@ void CameraFeed::set_RGB_img(Ref<Image> p_rgb_img) {
}
}
void CameraFeed::set_YCbCr_img(Ref<Image> p_ycbcr_img) {
void CameraFeed::set_YCbCr_img(const Ref<Image> &p_ycbcr_img) {
ERR_FAIL_COND(p_ycbcr_img.is_null());
if (active) {
VisualServer *vs = VisualServer::get_singleton();
@ -212,7 +214,9 @@ void CameraFeed::set_YCbCr_img(Ref<Image> p_ycbcr_img) {
}
}
void CameraFeed::set_YCbCr_imgs(Ref<Image> p_y_img, Ref<Image> p_cbcr_img) {
void CameraFeed::set_YCbCr_imgs(const Ref<Image> &p_y_img, const Ref<Image> &p_cbcr_img) {
ERR_FAIL_COND(p_y_img.is_null());
ERR_FAIL_COND(p_cbcr_img.is_null());
if (active) {
VisualServer *vs = VisualServer::get_singleton();

View file

@ -100,9 +100,9 @@ public:
virtual ~CameraFeed();
FeedDataType get_datatype() const;
void set_RGB_img(Ref<Image> p_rgb_img);
void set_YCbCr_img(Ref<Image> p_ycbcr_img);
void set_YCbCr_imgs(Ref<Image> p_y_img, Ref<Image> p_cbcr_img);
void set_RGB_img(const Ref<Image> &p_rgb_img);
void set_YCbCr_img(const Ref<Image> &p_ycbcr_img);
void set_YCbCr_imgs(const Ref<Image> &p_y_img, const Ref<Image> &p_cbcr_img);
void allocate_texture(int p_width, int p_height, Image::Format p_format, VisualServer::TextureType p_texture_type, FeedDataType p_data_type);
virtual bool activate_feed();