public ThreadedColorInImageDetection(IImageSource source)
        {
            _source = source;
            _colorsToDetect = new Dictionary<ISelectedColorHandle, DetectedColor>();

            _thread = new Thread(ProcessorThread);
            _thread.IsBackground = true;
        }
 public Controller(int w, int h, int xPixels, int yPixels, IImageSource imageSource)
 {
     this.layout = new Layout(w, h);
     this.xPixels = xPixels;
     this.yPixels = yPixels;
     this.imageSource = imageSource;
     round = 0;
     rounds = new int[w, h];
 }
 public Window(Rectangle bounds, int xSize, Config config, IImageSource imageSource)
 {
     Log.Instance.Write("Creating screen saver window at bounds " + bounds);
     this.bounds = bounds;
     this.xSize = xSize;
     this.config = config;
     this.backgroundstyle = config.BackGroundStyle;
     this.imagestyle = config.ImageStyle;
     //this.theme = theme;
     this.imageSource = imageSource;
     this.SetStyle(
         ControlStyles.AllPaintingInWmPaint |
         ControlStyles.UserPaint |
         ControlStyles.OptimizedDoubleBuffer, true);
 }
        public StreamingController(Uri baseAddress)
        {
            // setting up data source and web service
            _service = new MjpegStreamingService(this);
            _imageSource = new JpegImageSource();

            // setting up a web service point
            _host = new WebServiceHost(_service, baseAddress);
            var bnd = new WebHttpBinding();
            // -important- to stream image, "streamed" transfermode is required.
            bnd.TransferMode = TransferMode.Streamed;
            // streaming session time is restricted to 30-sec in this demonstration code
            bnd.SendTimeout = new TimeSpan(0, 0, 30);
            _host.AddServiceEndpoint(typeof(IMjpegStreamingService), bnd, baseAddress);

            // start streaming
            setFrameRate(10);
            startTimer();
            _host.Open();
        }
 public Task <IImageSourceServiceResult <UIImage> > GetImageAsync(IImageSource imageSource, float scale = 1, CancellationToken cancellationToken = default) =>
 GetImageAsync((ICustomImageSourceStub)imageSource, scale, cancellationToken);
 public static IImageSourceService?GetImageSourceService(this IImageSourceServiceProvider provider, IImageSource imageSource) =>
 provider.GetImageSourceService(imageSource.GetType());
Esempio n. 7
0
 XImage(IImageSource imageSource)
 {
     _source = imageSource;
     _path   = _source.Name;
     Initialize();
 }
Esempio n. 8
0
        /// <summary>
        /// Initiates a new instance of FrmRecoHuman
        /// </summary>
        public HumanRecognizer(IImageSource imageSource)
        {
            if (imageSource == null)
                throw new ArgumentNullException();
            this.imageSource = imageSource;
            LoadKnownFaces();
            lastDetectedFaces = new FaceCollection();

            settings = RecoHumanSettigs.Load("Settings.xml");
            if (settings == null) settings = RecoHumanSettigs.Default;

            //capturedImages = new ProducerConsumer<NImage>(10);

            mainThread = new Thread(new ThreadStart(MainThreadTask));
            mainThread.IsBackground = true;
        }
 private void element_ImageProduced(IImageSource source)
 {
     if ((selectedSourceIndex < 0) || (sources[selectedSourceIndex] != source))
         return;
     Bitmap image = source.GetImage(0);
     if(image != null)
         capturedImages.Produce(image);
 }
Esempio n. 10
0
 public abstract Task <IImageSourceServiceResult <UI.Xaml.Media.ImageSource>?> GetImageSourceAsync(
     IImageSource imageSource,
     float scale = 1,
     CancellationToken cancellationToken = default);
Esempio n. 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MenuItemViewModel"/> class.
 /// </summary>
 /// <param name="header">The header.</param>
 /// <param name="priority">The priority.</param>
 /// <param name="icon">The icon.</param>
 /// <param name="command">The command.</param>
 /// <param name="gesture">The gesture.</param>
 /// <param name="isCheckable">if set to <c>true</c> this menu acts as a checkable menu.</param>
 /// <param name="hideDisabled">if set to <c>true</c> this menu is not visible when disabled.</param>
 /// <param name="container">The container.</param>
 public MenuItemViewModel(string header, int priority, IImageSource icon = null, ICommand command = null,
                          IKeyGesture gesture       = null, bool isCheckable = false, bool hideDisabled = false,
                          IUnityContainer container = null)
     : base(header, priority, icon, command, gesture, isCheckable, hideDisabled)
 {
 }
Esempio n. 12
0
 public unsafe GLTexture(int width, int height)
 {
     _width  = width;
     _height = height;
     _source = null;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MenuItemViewModel"/> class.
 /// </summary>
 /// <param name="header">The header.</param>
 /// <param name="priority">The priority.</param>
 /// <param name="icon">The icon.</param>
 /// <param name="command">The command.</param>
 /// <param name="gesture">The gesture.</param>
 /// <param name="isCheckable">if set to <c>true</c> this menu acts as a checkable menu.</param>
 /// <param name="hideDisabled">if set to <c>true</c> this menu is not visible when disabled.</param>
 /// <param name="container">The container.</param>
 public SaveAsMenuItemViewModel(string header, int priority, IImageSource icon = null, ICommand command = null,
                                IKeyGesture gesture = null, bool isCheckable = false, bool hideDisabled = false)
     : base(header, priority, icon, command, gesture, isCheckable, hideDisabled)
 {
     VEFModule.EventAggregator.GetEvent <ActiveContentChangedEvent>().Subscribe(SaveAs);
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="imageSource">The image source.</param>
 protected ImageSourceViewModelBase(IImageSource imageSource)
 {
     _imageSource = imageSource ?? throw new ArgumentNullException(nameof(imageSource));
 }
Esempio n. 15
0
 public ImageController(IImageSource imageSource)
 {
     this.imageSource = imageSource;
 }
        protected virtual async Task InvokeResizeAsync(
            IImageSource source,
            IImageDestination destination,
            string queryString,
            string endpoint,
            CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            using var scope = Logger.BeginScope(Guid.NewGuid());
            Logger.LogDebug("Resize operation starting.");
            var uri = new UriBuilder(endpoint)
            {
                Query = queryString
            }.Uri;
            var context = await GetOperationContextAsync(source, destination, endpoint, cancellationToken).ConfigureAwait(false);

            Logger.LogDebug("Computed context for resize operation ({0}).", context.ContentType);
            try
            {
                IStreamConsumer consumer;
                if (context.Destination is null)
                {
                    // both source and destination are serializable
                    consumer = StreamConsumer.Create(async(input, cancellationToken) =>
                    {
                        using var request = new HttpRequestMessage(HttpMethod.Post, uri)
                              {
                                  Content = new JsonStreamContent(input)
                              };
                        using var client   = CreateHttpClient();
                        using var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
                        await CheckAsync(response, cancellationToken);
                    });
                }
                else
                {
                    // destination is not serializable, source does either support serialization or not..
                    var outputMime    = "application/octet-stream";
                    var finalConsumer = StreamConsumer.Delay(_ =>
                    {
                        Logger.LogDebug("Creating consumer for resize operation");
                        return(new ValueTask <IStreamConsumer>(context.Destination.CreateConsumer(new ContentInfo(outputMime))));
                    });
                    consumer = finalConsumer.Chain(StreamTransformation.Create(async(input, output, cancellationToken) =>
                    {
                        Logger.LogDebug("Sending resize request.");
                        using var request = new HttpRequestMessage(HttpMethod.Post, uri)
                              {
                                  Content = new TypedStreamContent(input, context.ContentType)
                              };
                        using var client   = CreateHttpClient();
                        using var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
                        Logger.LogDebug("Received response of the resize request.");
                        await CheckAsync(response, cancellationToken).ConfigureAwait(false);
                        outputMime       = response.Content.Headers.ContentType.MediaType ?? "application/octet-stream";
                        using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
                        await stream.CopyToAsync(output, 16 * 1024, cancellationToken).ConfigureAwait(false);
                        Logger.LogDebug("Done processing response of the resize request.");
                    }));
                }
                Logger.LogDebug("Initializing resize operation.");
                await context.Producer.ConsumeAsync(consumer, cancellationToken).ConfigureAwait(false);

                Logger.LogDebug("Resize operation completed.");
            }
            catch (Exception exn) when(!(exn is ImageException))
            {
                if (IsSocketRelated(exn, out var socketExn))
                {
                    if (IsBrokenPipe(socketExn) && source.Reusable)
                    {
                        Logger.LogWarning(exn, "Failed to perform operation due to connection error, retrying...");
                        await InvokeResizeAsync(source, destination, queryString, endpoint, cancellationToken).ConfigureAwait(false);

                        return;
                    }
                    throw new RemoteImageConnectivityException(endpoint, socketExn.SocketErrorCode, "Network related error has occured while performing operation.", exn);
                }
                throw new RemoteImageException(endpoint, ErrorCodes.GenericError, "Error has occurred while performing operation.", exn);
            }
        }
 public override Task <IImageSourceServiceResult <Image>?> GetImageAsync(IImageSource imageSource, Image image, CancellationToken cancellationToken = default) =>
 GetImageAsync((IStreamImageSource)imageSource, image, cancellationToken);
 public static Dimensions GetLODDimensions(this IImageSource imageSource, int lodLevel)
 {
     return(imageSource.Dimensions.AtLODLevel(imageSource.LOD, lodLevel));
 }
Esempio n. 19
0
 public abstract Task <IImageSourceServiceResult <Android.Graphics.Drawables.Drawable>?> GetDrawableAsync(
     IImageSource imageSource,
     Android.Content.Context context,
     CancellationToken cancellationToken = default);
 /**
  * Instantiate a new TextureSource.
  * @param imageSource The IImageSource providing a bitmap every frame.
  */
 public TextureSource(IImageSource imageSource)
 {
     UltrasoundDebug.Assert(null != imageSource, "Null ImageSource used in constructor", this, true);
     this.imageSource = imageSource;
 }
Esempio n. 21
0
 public CachingImageSource(IImageSource source, ICache cache)
 {
     this.source = source;
     this.cache = cache;
 }
 public RoundRobinImageSource(List<IImageSource> imageSources, IImageSource fallbackImageSource)
 {
     this.imageSources = imageSources;
     this.fallbackImageSource = fallbackImageSource;
 }
 private void sources_ElementRemoved(ImageSourceCollection source, IImageSource element)
 {
     element.ImageProduced -= dlgImageProduced;
 }
Esempio n. 24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ToolbarViewModel"/> class.
 /// </summary>
 /// <param name="header">The header.</param>
 /// <param name="priority">The priority.</param>
 /// <param name="icon">The icon.</param>
 /// <param name="command">The command.</param>
 /// <param name="isCheckable">if set to <c>true</c> does nothing in the case of toolbar - default value is false.</param>
 /// <param name="container">The container.</param>
 /// <exception cref="System.ArgumentException">Header cannot be SEP for a Toolbar</exception>
 public ToolbarViewModel(string header, int priority, IImageSource icon = null, ICommand command = null, bool isCheckable = false)
     : base(header, priority, icon, command, isCheckable)
 {
 }
Esempio n. 25
0
 public void SelectPixel(IImageSource imageSource, Point pixelPosition)
 {
     this.taggerController.SelectPixel(imageSource, pixelPosition);
 }
Esempio n. 26
0
 public SimpleImageData(IImageSource<IImageData> source, Image<Bgr, byte> image)
 {
     Source = source;
     OriginalImage = image.Clone();
     Image = image;
 }
Esempio n. 27
0
 public ImageSourcePluginAdapter(IImageSource <TSettings> source, ITypedSettingsConverter typedSettingsConverter)
 {
     _source = source;
     _typedSettingsConverter = typedSettingsConverter;
 }
Esempio n. 28
0
 public override Task <IImageSourceServiceResult <Drawable>?> GetDrawableAsync(IImageSource imageSource, Context context, CancellationToken cancellationToken = default) =>
 GetDrawableAsync((IUriImageSource)imageSource, context, cancellationToken);
Esempio n. 29
0
 public static XImage FromImageSource(IImageSource imageSouce)
 {
     return(new XImage(imageSouce));
 }
            public override Task <IImageSourceServiceResult <Drawable> > GetDrawableAsync(IImageSource imageSource, Context context, CancellationToken cancellationToken = default)
            {
                if (imageSource is not ICustomImageSourceStub imageSourceStub)
                {
                    return(Task.FromResult <IImageSourceServiceResult <Drawable> >(null));
                }

                var color = imageSourceStub.Color;

                var drawable = _cache.Get(color);

                var result = new ImageSourceServiceResult(drawable, () => _cache.Return(color));

                return(Task.FromResult <IImageSourceServiceResult <Drawable> >(result));
            }
Esempio n. 31
0
 public override Task <IImageSourceServiceResult <UIImage>?> GetImageAsync(IImageSource imageSource, float scale = 1, CancellationToken cancellationToken = default) =>
 GetImageAsync((IFileImageSource)imageSource, scale, cancellationToken);
Esempio n. 32
0
 public unsafe static ImageRef AsImageRef(this IImageSource source)
 {
     return(new ImageRef(source.Pixels, source.Width, source.Height));
 }
Esempio n. 33
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="imageSource">Source of images. Normally an NPK reader, but could be also be a source that reads from
 /// an extraction or a mock source.</param>
 /// <param name="disposeImageSource">If true, Dispose() the image source when this object is disposed.</param>
 public GifMaker(IImageSource imageSource, bool disposeImageSource)
 {
     m_imageSource        = imageSource;
     m_disposeImageSource = disposeImageSource;
 }
Esempio n. 34
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="imageSource">Source of images. Normally an NPK reader, but could be also be a source that reads from
 /// an extraction or a mock source.</param>
 /// <param name="disposeImageSource">If true, Dispose() the image source when this object is disposed.</param>
 public GifMaker(IImageSource imageSource, bool disposeImageSource)
 {
     m_imageSource = imageSource;
     m_disposeImageSource = disposeImageSource;
 }
Esempio n. 35
0
 public void SelectPixel(IImageSource imageSource, Point pixelPosition)
 {
 }
Esempio n. 36
0
 public Image(string id, IImageSource source)
 {
     ImageId = id;
     Source  = source;
 }
Esempio n. 37
0
 /// <summary>
 /// Adds a new Image to the text frame.
 /// </summary>
 public Image AddImage(IImageSource imageSource)
 {
     return(this.Elements.AddImage(imageSource));
 }
Esempio n. 38
0
        public override Task <IImageSourceServiceResult <Drawable>?> GetDrawableAsync(IImageSource imageSource, Context context, CancellationToken cancellationToken = default)
        {
            var uriImageSource = (IUriImageSource)imageSource;

            if (!uriImageSource.IsEmpty)
            {
                try
                {
                    var drawableCallback = new ImageLoaderResultCallback();

                    PlatformInterop.LoadImageFromUri(context, uriImageSource.Uri.OriginalString, new Java.Lang.Boolean(uriImageSource.CachingEnabled), drawableCallback);

                    return(drawableCallback.Result);
                }
                catch (Exception ex)
                {
                    Logger?.LogWarning(ex, "Unable to load image uri '{Uri}'.", uriImageSource.Uri.OriginalString);
                    throw;
                }
            }

            return(Task.FromResult <IImageSourceServiceResult <Drawable>?>(null));
        }
Esempio n. 39
0
 public abstract Task <IImageSourceServiceResult <Tizen.UIExtensions.ElmSharp.Image>?> GetImageAsync(
     IImageSource imageSource,
     Tizen.UIExtensions.ElmSharp.Image image,
     CancellationToken cancellationToken = default);
Esempio n. 40
0
 public Task <IImageSourceServiceResult <UI.Xaml.Media.ImageSource> > GetImageSourceAsync(IImageSource imageSource, float scale = 1, CancellationToken cancellationToken = default) =>
 GetImageSourceAsync((ICountedImageSourceStub)imageSource, scale, cancellationToken);
Esempio n. 41
0
        public override void GetImages(GraphicsDevice graphicsDevice, List <IImageSource[]> textureSetListToAddTo, ref bool stop)
        {
            List <string> zipFilesToOpen           = new List <string>();
            string        debugInfoZipFileName     = "";
            string        debugInfoPictureFileName = "";

            try
            {
                string imageFolder = null;
                if (!string.IsNullOrWhiteSpace(_itemToOpen))
                {
                    if (Path.GetExtension(_itemToOpen) == ".zip")
                    {
                        zipFilesToOpen.Add(_itemToOpen);
                    }
                    else if (Directory.Exists(_itemToOpen))
                    {
                        imageFolder    = _itemToOpen;
                        zipFilesToOpen = Directory.EnumerateFiles(imageFolder, "*.zip").ToList();
                    }
                }
                else
                {
                    var runningFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                    imageFolder = ConfigurationManager.AppSettings[AppSettingsKey] ?? runningFolder;
                    if (Directory.Exists(imageFolder))
                    {
                        zipFilesToOpen = Directory.EnumerateFiles(imageFolder, "*.zip").ToList();
                    }
                }
                var tempTextures = new List <Texture2D[]>();

                for (int i = 0; i < zipFilesToOpen.Count(); i++)
                {
                    List <IImageSource> textures = new List <IImageSource>();
                    debugInfoZipFileName = zipFilesToOpen[i];
                    using (ZipArchive archive = ZipFile.OpenRead(zipFilesToOpen[i]))
                    {
                        foreach (var entry in archive.Entries)
                        {
                            if (stop)
                            {
                                return;
                            }
                            if (entry.Name.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase) ||
                                entry.Name.EndsWith(".gng", StringComparison.OrdinalIgnoreCase) ||
                                entry.Name.EndsWith(".gif", StringComparison.OrdinalIgnoreCase))
                            {
                                try
                                {
                                    debugInfoPictureFileName = entry.FullName;
                                    using (Stream fileStream = entry.Open())
                                    {
                                        IImageSource source = ImageSourceFactory.CreateSourceFromStream(fileStream, entry.FullName);
                                        textures.Add(source);
                                        OnTextureLoaded(source.CurrentTexture);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(string.Format("Error loading image '{0}' from file '{1}'. Error is: {2}", debugInfoPictureFileName, debugInfoZipFileName, ex.Message));
                                }
                            }
                        }
                    }
                    if (textures.Count > 0)
                    {
                        textureSetListToAddTo.Add(textures.ToArray());
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Error loading image '{0}' from file '{1}'. Error is: {2}", debugInfoPictureFileName, debugInfoZipFileName, ex.ToString()), ex);
            }
        }
Esempio n. 42
0
 public Task <IImageSourceServiceResult <Drawable> > GetDrawableAsync(IImageSource imageSource, Context context, CancellationToken cancellationToken = default) =>
 GetDrawableAsync((ICountedImageSourceStub)imageSource, context, cancellationToken);