Forum Libraries, Components, and Plugins

Apply just captured image now in Window.Storage.CameraRoll to create a material

would like to execute code something like this:

var imagePath = Windows.Storage.KnownFolders.CameraRoll + "nameOfFile.jpg";
Material material = Material.FromImagePath(imagePath));

or

var child = Scene.CreateChild();
var myComponent = child.CreateComponent();
myComponent.SetImage(imagePath);

where PictureFrame is a new component that displays the image.

Currently only find a way to do this when the image is already in the resources cache.

Posts

  • utekaiutekai USMember ✭✭✭
    edited October 2016

    Another approach would be to create a Resource and then store using
    ResourceCache.AddManualResource(theResourceJustCreatedFromTheImageFile);

    I've tried to do this, but it fails silently somewhere/somehow. Never get the resource, but not sure if it's being created properly.

    Resource myRes = new Resource(Scene.Context);
    myRes.Name = "pic" + new Random().Next(0, 20000) + ".jpg";
    if (!ResourceCache.AddManualResource(myRes)) await TextToSpeech("Manual Resource did not add");

    Perhaps it is being created, because the AddManualResource always returns true.
    But then attempting to use it as in 'Material.FromImage(myRes.Name)' doesn't create a useable material.

    Perhaps going about this wrong.

    But I have an image stored in the CameraRoll directory and just want to display it ... really, how hard can it be?

  • EgorBoEgorBo BYXamarin Team ✭✭✭
    edited October 2016

    @utekai
    I've updated the 07_CognitiveService so now it displays previews (it creates textures via recently added MemoryBuffer)
    CameraRoll folder can be added via:
    new ApplicationOptions(KnownFolder.CameraRoll.Path)
    but unfortunately Urho for HoloLens won't re-index new photos in that directory so you won't access photos made after you initialized an app.

  • utekaiutekai USMember ✭✭✭
    edited October 2016

    Thanks, that helped a lot and worked fine. Still wondering about why I can't take a video like you did, that allows the photo capture/analysis without halting the video. I added some text to the preview pic to show some of the other analysis done in addition to the description. But just like always my video recording stops at the first 'describe'. When I update the sample to the most recent .NetCore framework for UWP (from 5.0 to 5.2.2.2) there's a new API available and it shows my hololens can't share the picture and video steam (MediaCaptureSettings.ConcurrentRecordAndPhotoSupported)). Even the microsoft forum mods seem confused by your video of the cognitive services sample where you record and do the picture analysis simultaneously. https://forums.hololens.com/discussion/comment/10143#Comment_10143

    According to this page, sharing mode can be enabled: https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.capture.mediacaptureinitializationsettings.sharingmode.aspx

    Remarks include: Multiple apps can simultaneously acquire frames from the same MediaFrameSource, but only a single app can acquire exclusive control of and modify the settings for the frame source. Set SharingMode to ExclusiveControl if you need to adjust the configuration of any of the frame sources included the requested SourceGroup. However, this means that the call to InitializeAsync will fail if another app already has exclusive control of one of the frame sources in the group. If you only need to acquire frames without modifying the configuration, set SharingMode to SharedReadOnly.


    Tried this modification (after updating .NetCore and changing target on project settings to windows anniversary edition):
    await mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings() { SharingMode = MediaCaptureSharingMode.SharedReadOnly });

    But it didn't change anything, recording still stops at first 'describe'.

  • utekaiutekai USMember ✭✭✭

    Tried numerous time to respond here ... giving up. This forum comment editor is awful.

    Now I get error: You have posted 2 times within 240 seconds. A spam block is now in effect on your account. You must wait at least 300 seconds before attempting to post again.

    Where are my posts if I've posted twice?

    Now add in the minimum 12 char password. FT!

  • utekaiutekai USMember ✭✭✭

    Oh now one of the comments that mysteriously disappeared now has magically appeared in the edit window ...

    I'd made a rather lengthy comment here and then it just disappeared after an edit ... here's some bits ...

    Thanks, the demo works fine and can capture the image, and those memory images can be reused as needed, but if a lot then it consume a lot of memory.

    In regards to video recording while taking pictures, I updated .NetCore to 5.2.2, and put project to WIndows Anniversary Edition, in order to bring in new APIs, which allows this change:

    await mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings() { SharingMode = MediaCaptureSharingMode.SharedReadOnly });

    But it helped nothing. Video stops at first 'describe'.

  • utekaiutekai USMember ✭✭✭

    Oh, one of them now appeared!

    I'd made a rather lengthy comment here and then it just disappeared after an edit ... here's some bits ...

    Thanks, the demo works fine and can capture the image, and those memory images can be reused as needed, but if a lot then it consume a lot of memory.

    In regards to video recording while taking pictures, I updated .NetCore to 5.2.2, and put project to WIndows Anniversary Edition, in order to bring in new APIs, which allows this change:

    await mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings() { SharingMode = MediaCaptureSharingMode.SharedReadOnly });

    But it helped nothing. Video stops at first 'describe'.

  • EgorBoEgorBo BYXamarin Team ✭✭✭
    edited November 2016

    @utekai
    Sorry I cheated with that video - it used "mock" data. But that "mock" data was recorded using real Services but without the recording, I am sorry I didn't mention it. I also spent some time trying to figure out why it stops :disappointed:

  • utekaiutekai USMember ✭✭✭

    When using most recent api's the sharing possiblity for video and picture taking is exposed.

    When checking this on my hololens, it always returns false:

    mediaCapture.MediaCaptureSettings.ConcurrentRecordAndPhotoSupported

Sign In or Register to comment.