Log in or register to post comments

Image Recognition Query via VWS

August 19, 2016 - 5:07am #1

Hi,

I need any information about Image Recognition Query via VWS.

I tried to implement the way following this link: https://library.vuforia.com/articles/Solution/How-To-Perform-an-Image-Recognition-Query

But without success.

I just received a 404 error in my attempts.

I need to upload an image and get similar images target_ids.

Eternally grateful,

Hiago Takaki

Image Recognition Query via VWS

September 22, 2020 - 3:19am #30

I made the image recognition on the PHP

the example on the Python was very helpful

but in the documentation still has a mistake, here is described correct

https://library.vuforia.com/content/vuforia-library/en/articles/Solution/How-To-Use-the-Vuforia-Web-Services-API.html

"For performing an Image Recognition Query, you will need to use the Client Access Keys associated with your Cloud DB"

attached the script below

AttachmentSize
Package icon vuforia.zip5.15 KB

Image Recognition Query via VWS

September 16, 2020 - 8:23am #29

I have the same problem

I use PHP for integration with Vuforia

When I work with Vuforia Web Services API everything works fine

But when I have tried to implement the Image Recognition Query for each my request I get 401 Unauthorized

For signature, I use the same method as for Web Services API

Also, I'm a little bit confused because here

https://library.vuforia.com/content/vuforia-library/en/articles/Solution/How-To-Use-the-Vuforia-Web-Services-API.html

"For performing an Image Recognition Query, you will need to use the Client Access Keys associated with your Cloud DB"

Client Access Keys?!

but here https://library.vuforia.com/articles/Solution/How-To-Perform-an-Image-Recognition-Query

everywhere in the examples server_access_key, server_secret_key

where is the truth?

dear developers, could you add an example for  Image Recognition Query to your example ZIP?

Thanks!

Image Recognition Query via VWS

January 31, 2018 - 12:43am #28

I received success result.

In sample

https://developer.vuforia.com/downloads/samples

Vuforia Web Services

Download for Python

vuforia-web-services-sample-code-python-2-0-0.zip (3.76 KB)

 

Notice

Line 49, CRLF = '\r\n'

Line 35, string_to_sign = "\n".join(components_to_sign)

 

Line 65, content_type = 'multipart/form-data; boundary=%s' % BOUNDARY

Line 86, content_type_bare = 'multipart/form-data'

 

Line 77, path = "/v1/query"

 

Line 89, authorization_header_for_request

 

Good Luck

AttachmentSize
Plain text icon cloud_query.txt5.01 KB

Image Recognition Query via VWS

December 19, 2017 - 1:15am #27

I use vb.net programming language to call the https://cloudreco.vuforia.com/v1/query this api (https://library.vuforia.com/articles/Solution/How-To-Perform-an-Image-Recognition-Query), but it return the "AuthenticationFailure", I use the same sign way  to call https://vws.vuforia.com/  this api, it return success.

I also notified that

  I try modify the Access Keys into Client Access Keys , buy now  it return {"transaction_id":"5b1f2cbe255a464ca34bfccb4d1f3aaf","result_code":"AuthenticationFailure"}  401 error.

Thanks!

Image Recognition Query via VWS

August 11, 2017 - 6:30am #26

Same problem here!

I don't know where is the problem. The response is only  "transaction_id":"718ab066c5b343289bdcb26e2c93eece","result_code":"AuthenticationFailure"

Is there some work example in java?

 

Thanks.

Image Recognition Query via VWS

June 30, 2017 - 6:21am #25

Hello,

 

I am also trying to work with Image Query API in java but it doesn't work it fails with Authentication failure. Can you please guide and provide the sample in java for Image query API which is not present in the VWS Sample java API and only present in Python sample  :-(. Any help will be greatly appreciated.

Thank you. 

Image Recognition Query via VWS

March 8, 2017 - 12:59pm #24

Here I translated the sample of Image Recognition Query found in https://developer.vuforia.com/downloads/samples, at the end of the page. The python sample is the only one that implements a query. The code works to authentication but it returns the error code 422 that is "bad image".

 

Image Recognition Query via VWS

February 23, 2017 - 9:50am #23

I have not had any solution to this problem and I am very disappointed.

My intention was to use Vuforia's services from the beginning, but I had to resort to other APIs because I could not implement Image Recognition Query.

I still want to use Vuforia, but is there an immediate solution to this problem?

Grateful!

 

hiagotakaki wrote:

Hi,

I've a problem with authorization using Image Recognition Query via VWS.

I'm using the same method applied to post a target with VWS API (that works), and tested with both access keys (client and server). But I keep getting the authentication error (e.g. {"transaction_id":"6f359f43aa2d4f8884d580537bfec82d","result_code":"AuthenticationFailure"}).

The only item I'm not sure that is correct is the Content-Type. This field is being filled according to my request body (e.g. multipart/form-data; boundary=----4560121156), so that the same value is used to generate the signature.

For the rest of the values, I believe that is correct because it is the same request process of VWS API, with the exception of endpoint + path that is "https://cloudreco.vuforia.com/v1/query".

My project is well overdue and I could already integrate with other API without difficulty, but I believe in the power of Vuforia, and he was chosen from planning.

Any help will be very appreciated.

 

No further,

Hiago Takaki

Image Recognition Query via VWS

February 13, 2017 - 7:45am #22

I am using Image Recognition Query via VWS in PHP but i am getting error  "Unexpected HTTP status: 415 Unsupported Media Type".

 

I am using following code for image.

I have Placed image on my server to test it.

$file = file_get_contents($this->imageLocation);

 

  if( $file ){

   $file = base64_encode( $file );

  }



  return $file;

 

Please help me on it.

Image Recognition Query via VWS

February 2, 2017 - 4:42am #21

Hi,

I am trying to achieve Cloud Recognition through Image Recognition Query of VWS, using unity and C#. I am using client keys instead of server keys as mentioned in different discussions in the forums. But irrespective of the keys being used, the request throws "401: unauthorized" error. I am re-using the code which works fine for uploading a target to cloud database. The code used is as below. Please help in resolving the issue.

 

    private string url = "https://cloudreco.vuforia.com/v1/query";

    private string targetName = "MyTarget" + System.DateTime.Now.ToString(); // must change when upload another Image Target, avoid same as exist Image on cloud

    void Start()

    {

        

        StartCoroutine(PostNewTarget());

    }

    [System.Serializable]

    public class PostNewTrackableRequest

    {

        public string name;

        public string image;

       

    }

    IEnumerator PostNewTarget()

    {

        

        string serviceURI = url ;

        string httpAction = "POST";

        string contentType = "multipart/form-data";

        string date = string.Format("{0:r}", System.DateTime.Now.ToUniversalTime());

        Debug.Log(date);

        // if your texture2d has RGb24 type, don't need to redraw new texture2d

        Texture2D tex = new Texture2D(texture.width, texture.height, TextureFormat.RGB24, false);

        tex.SetPixels(tex.GetPixels());

        tex.Apply();

        byte[] image = tex.EncodeToPNG();

        System.IO.File.AppendAllText(Application.persistentDataPath+"/Debug.txt","byte array of image : "+image+"\n");

        //PostNewTrackableRequest model = new PostNewTrackableRequest();

        //model.image = System.Convert.ToBase64String(image);

        //model.name = targetName;

        //model.width = 64.0f; // don't need same as width of texture

        //model.image = System.Convert.ToBase64String(image);

        string requestBody = JsonWriter.Serialize(System.Convert.ToBase64String(image));

        WWWForm form = new WWWForm();

        var headers = form.headers;

        byte[] rawData = form.data;

        headers["Host"] = url;

        headers["Date"] = date;

        headers["Content-Type"] = contentType;

        headers["Accept"] = "application/json";

        HttpWebRequest httpWReq = (HttpWebRequest)HttpWebRequest.Create(serviceURI);

        MD5 md5 = MD5.Create();

        var contentMD5bytes = md5.ComputeHash(System.Text.Encoding.ASCII.GetBytes(requestBody));

        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        for (int i = 0; i < contentMD5bytes.Length; i++)

        {

            sb.Append(contentMD5bytes[i].ToString("x2"));

        }

        string contentMD5 = sb.ToString();

        string stringToSign = string.Format("{0}\n{1}\n{2}\n{3}", httpAction, contentMD5, contentType, date);

        HMACSHA1 sha1 = new HMACSHA1(System.Text.Encoding.ASCII.GetBytes(secret_key));

        byte[] sha1Bytes = System.Text.Encoding.ASCII.GetBytes(stringToSign);

        MemoryStream stream = new MemoryStream(sha1Bytes);

        byte[] sha1Hash = sha1.ComputeHash(stream);

        string signature = System.Convert.ToBase64String(sha1Hash);

        headers["Authorization"] = string.Format("VWS {0}:{1}", access_key, signature); 

        WWW request = new WWW(serviceURI, System.Text.Encoding.UTF8.GetBytes(JsonWriter.Serialize(System.Convert.ToBase64String(image))), headers);

        yield return request;

        

        if (request.error != null)

        {

            status.text = request.error;

            Debug.Log("request error: " + request.error);

        }

        else

        {

            status.text = "Success";

            Debug.Log("request success");

            Debug.Log("returned data" + request.text);

        }

    }

}

Image Recognition Query via VWS

November 23, 2016 - 7:06am #20

Any update on this?  I can work post targets/delete targets etc. just fine; however, I can't seem to get past this a 401 status with "result_code":"AuthenticationFailure".

 

Any help or a link to code that is working would be greatly appreciated.

Image Recognition Query via VWS

November 17, 2016 - 12:33am #19

Hello!

I have the same problem. And I'm using the client access keys when attempting to access the Vuforia Web Query API, but without success.

Please, look: is there a different method in authentication to Vuforia Web Query API?

Image Recognition Query via VWS

November 9, 2016 - 5:55am #18

any update on this one?

 

how do we get rid of the authorization error?

Image Recognition Query via VWS

October 25, 2016 - 5:25am #17

Hi,

Iam Using This Image Recognition Query via VWS for getting the All targets.But Iam not able to get it and Iam getting the Response as follows:

{

  "result_code": "Fail",

  "transaction_id": "e4f9274b600c428980464071f420ef5f"

}

Even I have followed the Same Steps that you have mentioned in this Article.But One Thing I'am not sure about the Request Path, Content type and Content-MD5. I'am Using the Following as my String to Sign variable:

String stringToSign="GET"+"d41d8cd98f00b204e9800998ecf8427e"+"application/form-data"+"Tue, 25 Oct 2016 11:50:37 GMT"+"/targets"

As I'am Using the API for getting AllTargets, I'am using the Request Path as "/targets" and 

 Http-Verb as 'GET'  and content -MD5 as Default String(i.e. "d41d8cd98f00b204e9800998ecf8427e") since no request body and content-type as "application/form-data".

One More thing is I have created the New Cloud Database to generate the Access key and Secret Keys and I'am using the same keys in the generation of Signature.

Please find the code below that i have created to generate the signature:

public class GenerateSignature {

public static void main(String[] args) {

  String stringTosign="GET"+"d41d8cd98f00b204e9800998ecf8427e"+"application/form-data"+"Tue, 25 Oct 2016 11:50:37 GMT"+"/targets";



  System.out.println("HMAC-SHA1:-"+hmacSha1(stringTosign, "af4901e3e85b14533bcfd14fac5b3a646a8fc95f"));



  System.out.println(DateUtils.formatDate(new Date()).replaceFirst("[+]00:00$", ""));

}

public static String hmacSha1(String value, String key) {

        try {

            // Get an hmac_sha1 key from the raw key bytes

            byte[] keyBytes = key.getBytes();          

            SecretKeySpec signingKey = new SecretKeySpec(keyBytes, "HmacSHA1");

            // Get an hmac_sha1 Mac instance and initialize with the signing key

            Mac mac = Mac.getInstance("HmacSHA1");

            mac.init(signingKey);

            // Compute the hmac on input data bytes

            byte[] rawHmac = mac.doFinal(value.getBytes());

            byte[] hexBytes = new Hex().encode(rawHmac);

            //  Covert array of Hex bytes to a String

            String hexBytesStr = new String(hexBytes, "UTF-8");

          

            //  Covert array of Hex bytes to a String

          //  String hexBytesStr = new String(hexBytes, "UTF-8");

           

           //Base64

          byte[] encodedBytes = Base64.encodeBase64(hexBytesStr.getBytes());

            return new String(encodedBytes, "UTF-8");

        } catch (Exception e) {

            throw new RuntimeException(e);

        }

    }

}

 

Still I'am facing the issue.Please help me out on this and Correct me If I did any wrong.

 

Thanks,

Sudheshna

 

Image Recognition Query via VWS

October 24, 2016 - 8:47am #16

I have the same problem. 

Image Recognition Query via VWS

September 30, 2016 - 8:22am #15

In my exploration of the problem, I found the following information accessing https://developer.vuforia.com/targetmanager/vuforiaUtil/getLoggedInUser :

{
    "eguid": "4228312",
    "cloudRecoStatus": "USER_NOT_AUTHORISED", // NOTE IT
    "email": (...),
    "userstatus": null,
    "companyName": "None",
    "firstName": "Hiago",
    "lastName": "Takaki",
    "cloudDBCount": 0,
    "cloudProjectQueryCount": null,
    "cloudProjectRecoCount": null,
    "cloudProjectQueryRecoRatio": null,
    "formattedCloudAppliedDate": null,
    "projectLastRecoDate": null,
    "cloudTargetCount": 0,
    "cloudRecoHistoryCount": 0,
    "cloudTermsAcceptedVersion": 0,
    "loggedInIpAddress": (...),
    "lastLoggedInTIme": 1475244801,
    "cachedKey": "0e16b1104a5f975dccb0983dcd0d7a1f",
    "browserInUse": "windows-chrome",
    "country": null,
    "cloudOps": false,
    "accountAdmin": false,
    "contentAdmin": false,
    "legalAdmin": false,
    "reportingAdmin": false,
    "forumAdmin": false,
    "tmsSettingsAdmin": false,
    "billingAdmin": false,
    "accountReadOnly": false,
    "userWatchListed": false,
    "is_cloud_ops": false,
    "username": "hiagotakaki",
    "is_account_admin": false,
    "is_content_admin": false,
    "is_legal_admin": false,
    "is_reporting_admin": false,
    "is_forum_admin": false,
    "is_tms_settings_admin": false,
    "is_billing_admin": false,
    "is_account_read_only": false
}

Does this have something to do with the recognition problem?

If so, why my cloud recognition status is USER_NOT_AUTHORISED? How to reverse it?

I have a developer license. Later my client will retain a proper license to his needs, but the project must be fully operational.

Image Recognition Query via VWS

September 28, 2016 - 8:08am #14

Hello,

 

Yes, I'm using the client access keys when attempting to access the Vuforia Web Query API.

In fact, I tried to use both client and server access keys, but without success.

Please, look: is there a different method in authentication to Vuforia Web Query API?

I'm using the same method of Post Target (that works).

 

Thanks.

Image Recognition Query via VWS

September 27, 2016 - 5:47pm #13

Hello,

Please confirm that you're using the client access keys, and not the server access keys, when attempting to access the Vuforia Web Query API.

Thanks

Image Recognition Query via VWS

September 23, 2016 - 7:20am #12

Hi,

I've a problem with authorization using Image Recognition Query via VWS.

I'm using the same method applied to post a target with VWS API (that works), and tested with both access keys (client and server). But I keep getting the authentication error (e.g. {"transaction_id":"6f359f43aa2d4f8884d580537bfec82d","result_code":"AuthenticationFailure"}).

The only item I'm not sure that is correct is the Content-Type. This field is being filled according to my request body (e.g. multipart/form-data; boundary=----4560121156), so that the same value is used to generate the signature.

For the rest of the values, I believe that is correct because it is the same request process of VWS API, with the exception of endpoint + path that is "https://cloudreco.vuforia.com/v1/query".

My project is well overdue and I could already integrate with other API without difficulty, but I believe in the power of Vuforia, and he was chosen from planning.

Any help will be very appreciated.

 

No further,

Hiago Takaki

Image Recognition Query via VWS

September 9, 2016 - 1:16am #11

Hello,

  I fix the 403 error , but now it return the 400 error: [ api-status:400 , description:],responseData is [java.io.IOException: RESTEASY007550: Unable to get boundary for multipart], I pst the requestBody contentType is "multipart/form-data", and use the following code to post the requset param  "image" , This code if there is a problem ? can you help me to find out the bug ,  thanks !

public byte[] getImgBytes() throws SimpleImageException {

   WriteRender writer = null;

   try {

    this.toRGBColorModel();

    ByteArrayOutputStream out = new ByteArrayOutputStream();

    WriteParameter w = new WriteParameter();

    w.setDefaultQuality(0.65F);

    writer = new WriteRender(this.getImgWrapper(), out,

      ImageFormat.JPEG, w);

    writer.render();

    return out.toByteArray().toByteArray();

   } finally {

    if (writer != null) {

     writer.dispose();

    }

   }

  }

JSONObject object = new JSONObject();

   object.put("image", URLEncoder.encode(new String(imageBytes), CharEncoding.UTF_8));

   StringEntity requestEntity = new StringEntity(object.toString(),

     ContentType.MULTIPART_FORM_DATA);

   builder.setEntity(requestEntity);

Image Recognition Query via VWS

September 8, 2016 - 9:38am #10

Hello,

Progress! Now you need to make sure that the device/machine making the request is set to the correct date and time for your location. This error is indication that it is not set properly.

Thanks

Image Recognition Query via VWS

September 8, 2016 - 2:41am #9

Hello,

  I try modify the Access Keys into Client Access Keys , buy now  it return {"transaction_id":"a05aefde6eac449ba98a312e96a1f280","result_code":"RequestTimeTooSkewed"}  403 error,  if I request to much ? when or how  can  I request success .

thanks !

Image Recognition Query via VWS

September 7, 2016 - 1:21pm #8

Hello,

Perhaps the problem lies in the keys you're using as the two APIs use different keys:

  • Client Access Keys are used to make queries to the Cloud Reco Web API
  • Server Access Keys are used to make requests to the VWS API

Thanks

Image Recognition Query via VWS

September 5, 2016 - 1:58am #7

Hello, I use the following code  to call (https://cloudreco.vuforia.com/v1/query) this API, but it return "AuthenticationFailure". The method "createSignature" is the common mehtod of the official demo, I use the same method "createSignature" to call (https://vws.vuforia.com/),  it return succe , can you help me to find some wrong in the following code , I need some help, thanks !

protected ImageRecoQueryInfo doQueryImageRecognition(String imageBytes) {

  RequestBuilder builder = RequestBuilder.post();

  builder.setUri(vufHelper.getApiQueryImageRecoUrl());

  HttpEntity entity = null;

  try {

   JSONObject object = new JSONObject();

   object.put("image", URLEncoder.encode(imageBytes, "UTF-8"));

   StringEntity requestEntity = new StringEntity(object.toString(),

     ContentType.APPLICATION_JSON);

   builder.setEntity(requestEntity);

   vufHelper.setApiRequestHeader(builder);

   HttpUriRequest r = builder.build();

   CloseableHttpResponse response = httpClient.execute(r);

   entity = response.getEntity();

   vufHelper.extractExceptionFromResponse(response);

   logger.info("doQueryImageRecognition successfully ");

   String entityStr = EntityUtils.toString(entity);

   return JSONObject.parseObject(entityStr,ImageRecoQueryInfo.class);

  } catch (Exception e) {

   logger.error("doQueryImageRecognition failed: ", e);

   throw new CloudApiConnectException(e);

  } finally {

   EntityUtils.consumeQuietly(entity);

  }

}

public void setApiRequestHeader(RequestBuilder builder) {

  builder.addHeader(new BasicHeader("Date",

    getUTCFormatDateStr(new Date())));

  builder.addHeader(

    "Authorization",

    "VWS "

      + vuforiaAccountConfig.getAccessKey()

      + ":"

      + signatureBuilder.createSignature(builder,

        vuforiaAccountConfig.getSecretKey()));

}

Image Recognition Query via VWS

September 1, 2016 - 2:54pm #6

Hello,

The development team has confirmed that the two query APIs use the exact same method for authentication.

Thanks

Image Recognition Query via VWS

August 29, 2016 - 5:38pm #5

Hello,

We are looking into this.

Thanks.

Image Recognition Query via VWS

August 28, 2016 - 6:59pm #4

I use java programming language to call the https://cloudreco.vuforia.com/v1/query this api (https://library.vuforia.com/articles/Solution/How-To-Perform-an-Image-Recognition-Query), but it return the "AuthenticationFailure", I use the same sign way  to call https://vws.vuforia.com/  this api, it return success, why? The two api use the different Signature way?

Thanks!

Image Recognition Query via VWS

August 19, 2016 - 1:25pm #3

Hello,

There is an error in our documentation that we will address. Please use the following endpoint URL:

cloudreco.vuforia.com/v1/query

Apologies for any inconvenience.

Thanks

Image Recognition Query via VWS

August 19, 2016 - 9:44am #2

Hello,

We are looking into this.

Thanks.

Log in or register to post comments