cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

How to get the camera picture with HoloLens?

Yoyo
9-Granite

How to get the camera picture with HoloLens?

Hi All,

I refer to this article. It can run successfully on mobile devices.

https://community.ptc.com/t5/Vuforia-Studio/Transferring-an-image-to-twx/m-p/703693

Now, I created a 3D Eyewear project and take picture to test it.
The preview can successfully save the picture, but it fails on HoloLens.

 

Below is my Experience Service log:

::ffff:192.168.2.102 - - [2021-04-09T01:27:41.470Z] "POST /Thingworx/Things/TestRepository/Services/SaveText HTTP/1.1" 401 0 "http://192.168.2.101:2019/ExperienceService/content/projects/test/index.html?expId=1" "Mozilla/5.0 (Windows NT 10.0; WebView/3.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17763" 4 ms 192.168.2.101:2019 441428 [2021-04-09T01:27:41.466Z] - ms - ms - ms - ms
::ffff:192.168.2.102 - - [2021-04-09T01:27:41.471Z] "POST /Thingworx/Things/TestRepository/Services/SaveImage HTTP/1.1" 401 0 "http://192.168.2.101:2019/ExperienceService/content/projects/test/index.html?expId=1" "Mozilla/5.0 (Windows NT 10.0; WebView/3.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17763" 10 ms 192.168.2.101:2019 441424 [2021-04-09T01:27:41.461Z] - ms - ms - ms - ms

 

How can I set permissions or other?

26E0A7F3-3921-4363-BF2D-E615F16C9AB4.png

10 REPLIES 10

for hololens

try

$scope.app.L = () => {
...
}
Yoyo
9-Granite
(To:dsgnrClarK)

I tried, it has the same problem.

Have you tried the solution mentioned in the post https://community.ptc.com/t5/Vuforia-Studio/Transferring-an-image-to-twx/m-p/703693 ?

 

In your attachment, there is only one funciton $scope.L .

 

Nevertheless in the solution, there are

$scope.app.runMyTWXService = function() {...}
$scope.SaveImageToTwxRepository = function(path, content) {...}
$scope.app.takePictureEvent= function() {...}

Which works with the Hololens I have.

 

Yoyo
9-Granite
(To:dsgnrClarK)

I using this JS. The preview works, but it does not work in HoloLens.

 

$scope.app.runMyTWXService = function() {
//sample setting of the parameters
var TWXmodelID = 'myTWXThing'; var serviceName = 'QueryNumberPropertyHistory';
var parameters = {'propertyName': 'Temp', 'maxItems': 10};

TWXmodelID =arguments[0];serviceName=arguments[1]; parameters= arguments[2]
console.log("$scope.app.runMyTWXService number of arguments ="+ arguments.length)
console.warn('twx.app.fn.triggerDataService('+TWXmodelID+','+serviceName+','+JSON.stringify(parameters)+');');
twx.app.fn.triggerDataService(TWXmodelID, serviceName, parameters);
};
//=================================================
$scope.SaveImageToTwxRepository = function(path, content) {
$scope.$applyAsync(function() {
$scope.app.runMyTWXService ('TestRepository','SaveImage',{"content": content, "path":path} )
} ,500 );
console.log( "Called -$scope.SaveImageToTwxRepository");
};
//=================================================
// will save the data to repository path /pictures/last.jpg
//----------------------------------------
$scope.app.takePictureEvent= function() {

console.log( "called $scope.SaveImageToTwxRepository!");
// will save the picture data into the imageUrl
$scope.setWidgetProp('3DImage-1', 'src', $scope.view.wdg['camera-1']['imageUrl']) ;
//alternative call
//$scope.view.wdg['3DImage-1']['src']=$scope.view.wdg['camera-1']['imageUrl'];
// will save the picture image data to the repository
$scope.SaveImageToTwxRepository('/pictures/last.jpg', $scope.view.wdg['camera-1']['image'] );
$scope.$applyAsync();}

Try modify var TWXmodelID = 'myTWXThing' to var TWXmodelID = 'TestRepository'

$scope.app.runMyTWXService = function(){
  //sample setting of the parameters
  var TWXmodelID = 'TestRepository';
  var serviceName = 'QueryNumberPropertyHistory';
  var parameters = {'propertyName': 'Temp', 'maxItems': 10};
  
  TWXmodelID = arguments[0]; serviceName = arguments[1]; parameters = arguments[2];
  
  console.log("$scope.app.runMyTWXService number of arguments ="+ arguments.length)
  console.warn('twx.app.fn.triggerDataService('+TWXmodelID+','+serviceName+','+JSON.stringify(parameters)+');');
  
  twx.app.fn.triggerDataService(TWXmodelID, serviceName, parameters);
};

 

Yoyo
9-Granite
(To:dsgnrClarK)

It has the same problem.

ytella
17-Peridot
(To:Yoyo)

@Yoyo Could you please add the below parameter in the configuration.json file.

 

"nohttp2":true

 

Also, please review if the "realm" value in the configuration.json file is equal to "ThingWorx". Save the file and restart the Experience Service. Please let us know if this helped to resolve the issue.

Yoyo
9-Granite
(To:ytella)

I had added "nohttp2": true in the configuration.json.

Yes, the realm value is equal to "ThingWorx".

It can not work for me.

Yoyo
9-Granite
(To:Yoyo)

I try to use Thingworx 9.1, but it failed.

ytella
17-Peridot
(To:Yoyo)

@Yoyo Please share the Experience Service log file, ThingWorx Application log and Vuforia log file to track the issue

Top Tags