API של חיפוש תמונה הפוכה

אנו נרגשים להודיע לכם על התכונות החדשות שהוצגו ב- Aspose.Imaging Cloud API. עכשיו הוא תומך במקור תמונה מבוסס אינטרנט עבור חיפוש תמונה הפוכה. תכונת תיקון הזווית של התמונה גם עושה את ה- API ללא תחרות. אנו עובדים ומשפרים continuamente כדי להציע לכם את הפתרונות הטובים ביותר האפשריים.

Reverse image search is useful for finding duplicate or similar images. It can also help to monitor obscene or graphic content. You can also counter copyrights violations or trademark counterfeit by searching digitally signed images with the reverse search. Moreover, image deskewing is another feature that adds value to Aspose.Imaging Cloud API. It is also relevant to scanned PDF documents where skewed images often exist. Such PDF documents are frequently converted to searchable PDF documents where the results can be improved by deskewing the images. Let us dissect these features below.

חיפוש תמונות הפוך באמצעות Aspose.Imaging Cloud SDK עבור Python

מספר SDKs זמינים לתקשורת עם Aspose.Imaging Cloud API. ה-SDKs דואגים לכל הפרטים הקטנים כך שתוכל להמשיך בדרישות שלך ללא בעיות. ה-SDKs כוללים .NET, Java, Python, PHP, Ruby, Android, ו-Node.js. כאן נעבוד עם דוגמת Python:

ראשית כל, תצטרך sign up חינם ב-Aspose.Cloud. התקן Python 2.7 or later ולאחר מכן הוסף את PyPi package הבא לקובץ requirements.txt שלך.

aspose-imaging-cloud>=20.1

עכשיו ייבא את התלויות כפי שמתואר:

import aspose-imaging-cloud

עכשיו, אתה יכול להשתמש בקוד פייתון למטה כדי לקרוא ל-APIs ולבחון את הפיצ’ר:

    def search_image_from_web_source(self):
        """Finds the similar images from the URL source"""
        print('Finds similar images from URL:')

        similarity_threshold = 30.0
        max_count = 3
        folder = ImagingAiBase.CLOUD_PATH  # Folder with image to process
        storage = None  # We are using default Cloud Storage

        # הוסף תמונות מהאתר להקשר החיפוש
        image_source_url = urllib.quote_plus('https://www.f1news.ru/interview/hamilton/140909.shtml')
        self._imaging_api.create_web_site_image_features(
            requests.CreateWebSiteImageFeaturesRequest(self._search_context_id, image_source_url, folder, storage))

        self._wait_idle(self._search_context_id)

        # הורד את התמונה מהאתר
        image_data = req.get('https://cdn.f1ne.ws/userfiles/hamilton/140909.jpg')
        path = os.path.abspath(os.path.join(ImagingAiBase.OUTPUT_FOLDER, 'WebSearchSample.jpg'))
        with open(path, "wb") as f:
            f.write(image_data.content)

        # שנה את גודל התמונה שהורדת כדי להדגים את יכולות מנוע החיפוש
        resized_image = self._imaging_api.create_resized_image(requests.CreateResizedImageRequest(
            path, 600, 400, "jpg", storage=storage))

        # העלה תמונה לענן
        image_name = 'ReverseSearch.jpg'
        self._imaging_api.upload_file(requests.UploadFileRequest(ImagingAiBase.CLOUD_PATH + "/" + image_name,
                                                                 resized_image, storage))

        # מצא תמונות דומות בהקשר החיפוש
        find_response = self._imaging_api.find_similar_images(
            requests.FindSimilarImagesRequest(self._search_context_id, similarity_threshold, max_count,
                                              image_id=ImagingAiBase.CLOUD_PATH + "/" + image_name,
                                              folder=folder, storage=storage))

        print('Similar images found: ' + str(len(find_response.results)))
        print('Similar image id: ' + find_response.results[0].image_id)
        print('Similarity: ' + str(find_response.results[0].similarity))

The website-based image source for reverse image search is well elaborated in this example. It includes an additional step of resizing the image to demonstrate the efficiency of API. Image dimensions may differ but the API will produce reliable and accurate results. Following is the screenshot of the output:

כפי שתוכל לשים לב, מספר הדימויים הדומים, ה- URL ואחוז ההקבלה מוצגים על ידי הפרמטרים בתשובת ה- API.

שיפור זווית תמונה באמצעות Aspose.Imaging Cloud SDK עבור .NET

תמונות מכילות המון מידע ועיבוד תמונה הפך לחשוב מאוד בימינו. שימוש נפוץ מאוד הוא תמונות מעוותות בתמונות PDF סרוקות או לעיתים בתמונות ממצלמות טלפון נייד. ה- Aspose.Imaging Cloud API כולל כעת את תכונת תיקון העיוותים בתמונות. אתה יכול לתקן את העיוותים בתמונות בפורמטים BMP, GIF, JPEG, JPEG2000, PSD, TIFF, WEBP, ו- PNG. בוא נ рассмотр пример ב .NET לתיקון עיוותים בתמונה בפורמט TIFF.

using System;
using System.IO;
using Aspose.Imaging.Cloud.Sdk.Api;
using Aspose.Imaging.Cloud.Sdk.Model.Requests;

namespace AsposeImagingCloudSdkExamples
{
    /// <summary>
    /// דוגמה לתיקון הטיית תמונה.
    /// </summary>
    /// <seealso cref=\"AsposeImagingCloudSDKExamples.ImagingBase\" />
    class DeskewImage : ImagingBase
    {
        /// <summary>
        /// יוזם מופע חדש של מחלקת <see cref=\"DeskewImage\"/> .
        /// </summary>
        /// <param name=\"imagingApi\">API הדמיה.</param>
        public DeskewImage(ImagingApi imagingApi) : base(imagingApi)
        {
            PrintHeader("Deskew image example:");
        }

        /// <summary>
        /// מקבל את השם של קובץ התמונה לדוגמה.
        /// </summary>
        /// <value>
        /// שם הקובץ של תמונת הדוגמה.
        /// </value>
        /// <remarks>
        /// פורמטים של קלט עשויים להיות אחד מהבאים:
        /// BMP, GIF, JPEG, JPEG2000, PSD, TIFF, WEBP, PNG
        /// </remarks>
        protected override string SampleImageFileName => "Sample_05_Scan1_SkewToLeft.tif";

        private const string SaveImageFormat = "tif";

        /// <summary>
        /// מסדר תמונה מאחסון בענן.
        /// </summary>
        public void DeskewImageFromStorage()
        {
            Console.WriteLine("Deskew the image from cloud storage");

            UploadSampleImageToCloud();

            bool resizeProportionally = true;
            string bkColor = "white";
            string folder = CloudPath; // Input file is saved at the Examples folder in the storage
            string storage = null; // We are using default Cloud Storage

            var request = new DeskewImageRequest(SampleImageFileName, resizeProportionally, bkColor, folder, storage);

            Console.WriteLine($"Call DeskewImage with params: resizeProportionally:{resizeProportionally}, bkColor:{bkColor}");

            using (Stream updatedImage = this.ImagingApi.DeskewImage(request))
            {
                SaveUpdatedSampleImageToOutput(updatedImage, false, SaveImageFormat);
            }

            Console.WriteLine();
        }

        /// <summary>
        /// לתקן הטיה של תמונה קיימת, ולהעלות את התמונה המעודכנת לאחסון בענן.
        /// </summary>
        public void DeskewImageAndUploadToStorage()
        {
            Console.WriteLine("Deskews the image and upload to cloud storage");

            UploadSampleImageToCloud();

            bool resizeProportionally = true;
            string bkColor = null;
            string folder = CloudPath; // Input file is saved at the Examples folder in the storage
            string storage = null; // We are using default Cloud Storage

            var request = new DeskewImageRequest(SampleImageFileName, resizeProportionally, bkColor, folder, storage);

            Console.WriteLine($"Call DeskewImage with params: resizeProportionally:{resizeProportionally}, bkColor:{bkColor}");

            using (Stream updatedImage = this.ImagingApi.DeskewImage(request))
            {
                UploadImageToCloud(GetModifiedSampleImageFileName(false, SaveImageFormat), updatedImage);
            }

            Console.WriteLine();
        }

        /// <summary>
        /// מסדר תמונה. נתוני התמונה מועברים בזרם הבקשה.
        /// </summary>
        public void CreateDeskewedImageFromRequestBody()
        {
            Console.WriteLine("Deskews the image from request body");

            using (FileStream inputImageStream = File.OpenRead(Path.Combine(ExampleImagesFolder, SampleImageFileName)))
            {
                bool resizeProportionally = true;
                string bkColor = "white";
                string storage = null; // We are using default Cloud Storage
                string outPath = null; // Path to updated file (if this is empty, response contains streamed image)

                var request = new CreateDeskewedImageRequest(inputImageStream, resizeProportionally, bkColor, outPath, storage);

                Console.WriteLine($"Call DeskewImage with params: resizeProportionally:{resizeProportionally}, bkColor:{bkColor}");

                using (Stream updatedImage = this.ImagingApi.CreateDeskewedImage(request))
                {
                    SaveUpdatedSampleImageToOutput(updatedImage, true, SaveImageFormat);
                }
            }

            Console.WriteLine();
        }
    }
}

דוגמה זו מעלה תמונת דוגמה לאחסון ענן, מסדרת אותה מחדש ומעלה את התמונה המעודכנת לאחסון ענן. להלן הצילומים של תמונות TIFF הקלט ופלט.

הזן תמונת TIFF

פלט תמונת TIFF (מכוון מחדש)

Aspose.Imaging Cloud SDK for Ruby

עוד תוספת חשובה בקו המוצרים של ה-SDK היא שפרסמנו Aspose.Imaging Cloud SDK for Ruby. הוא מאפשר לך לשלב תכונות עיבוד תמונות חזקות באפליקציות Ruby שלך.

אנו מעודדים אותך לנסות את התכונות היעילות של ה- API ולשתף את חוויותיך איתנו. אנא יידע אותנו אם יש לך המלצות או שאלות. אנו מצפים לשמוע ממך דרך Free Support Forums.

מאמר קשור:

Introducing Aspose.Imaging Cloud V3