Skip to content

Commit

Permalink
Merge pull request #95 from visenze/bug/box_param
Browse files Browse the repository at this point in the history
[ONLINE-1082] fix box param bug
  • Loading branch information
thehung111 authored Dec 5, 2022
2 parents 72ee586 + 2757b59 commit d734e6b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
11 changes: 9 additions & 2 deletions doc/ProductSearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ With the release of ViSenze's Catalog system, ViSearch Android SDK will now incl
- Aggregate search results on a product level instead of image level
- Consistent data type in API response with Catalog’s schema

> Current stable version: 2.2.5
> Current stable version: 2.2.6
> Minimum Android SDK Version: API 9, Android 2.3
Expand Down Expand Up @@ -64,7 +64,7 @@ allprojects {
include the dependency in your project using gradle:
```gradle
implementation 'com.github.visenze:visenze-tracking-android:0.2.2'
implementation 'com.github.visenze:visearch-sdk-android:2.2.5'
implementation 'com.github.visenze:visearch-sdk-android:2.2.6'
```

### 1.3 Add User Permissions
Expand Down Expand Up @@ -116,6 +116,8 @@ ProductSearch productSearch = new ProductSearch
.build(context);
```

For searches in China, please change the endpoint to `https://search.visenze.com.cn`.

## 3. Solution APIs

There are two main APIs provided in this suite, one allows searching for products based on an image input, the other searches using a product's ID (Recommendations API). A product's ID can be retrieved from a [Search Result](#4-search-results).
Expand Down Expand Up @@ -528,6 +530,11 @@ ProductSeach productSearch = SearchAPI.getProductSearchInstance();
Tracker tracker = productSearch.newTracker();
```

For China, please change the tracker to:
```
Tracker tracker = productSearch.newTracker(true);
```

### 7.2 Send Events

Currently we support the following event actions: `click`, `view`, `product_click`, `product_view`, `add_to_cart`, and `transaction`. The `action` parameter can be an arbitrary string and custom events can be sent.
Expand Down
4 changes: 2 additions & 2 deletions doc/ViSearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ViSearch is an API that provides accurate, reliable and scalable image search. V

The ViSearch Android SDK is an open source software to provide easy integration of ViSearch Search API with your Android mobile applications. It provides three search methods based on the ViSearch Search API - pre-indexed search, color search and upload search. For source code and references, please visit the [Github Repository](https://github.com/visenze/visearch-sdk-android).

>Current stable version: 2.2.5
>Current stable version: 2.2.6
>Minimum Android SDK Version: API 9, Android 2.3
Expand Down Expand Up @@ -80,7 +80,7 @@ allprojects {
include the dependency in your project using gradle:
```gradle
implementation 'com.github.visenze:visenze-tracking-android:0.2.2'
implementation 'com.github.visenze:visearch-sdk-android:2.2.5'
implementation 'com.github.visenze:visearch-sdk-android:2.2.6'
```

### 1.3 Add User Permissions
Expand Down
4 changes: 2 additions & 2 deletions visearch-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ plugins {

def versionMajor = 2
def versionMinor = 2
def versionPatch = 5
version = '2.2.5'
def versionPatch = 6
version = '2.2.6'

android {
compileSdkVersion 29
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public Tracker newTracker() {
return newTracker(null, false);
}

public Tracker newTracker(boolean useCnEndpoint) {
return newTracker(null, useCnEndpoint);
}

public Tracker newTracker(String code) {
return newTracker(code, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class ProductSearchByImageParams extends BaseProductSearchParams {
@Expose(deserialize = false, serialize = false)
private Image image;

@SerializedName("box")
private int[] box;
// transient is to prevent serialization
private transient int[] box;

@SerializedName("detection")
private String detection;
Expand All @@ -31,6 +31,9 @@ public class ProductSearchByImageParams extends BaseProductSearchParams {
@SerializedName("search_all_object")
private Boolean searchAllObjects;

// internal serialization
@SerializedName("box")
private String boxParam;

public Boolean getSearchAllObjects() {
return searchAllObjects;
Expand Down Expand Up @@ -70,6 +73,7 @@ public int[] getBox() {

public void setBox(int x1, int y1, int x2, int y2) {
this.box = new int[] {x1, y1, x2, y2};
this.boxParam = String.format("%d,%d,%d,%d", x1, y1, x2, y2);
}

public String getDetection() {
Expand All @@ -96,6 +100,10 @@ public void setDetectionSensitivity(String detectionSensitivity) {
this.detectionSensitivity = detectionSensitivity;
}

public String getBoxParam() {
return boxParam;
}

public ProductSearchByImageParams() {
super();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public void testBaseSearchParams_parsing() {
customMap.put("debug", "true");
params.setCustomParams(customMap);

params.setBox(10,20,400,500);


RetrofitQueryMap map = params.getQueryMap();

Expand All @@ -61,6 +63,7 @@ public void testBaseSearchParams_parsing() {
assertEquals("testParamVal", map.get("testParam"));
assertEquals("testParamVal2", map.get("testParam2"));
assertEquals("1234555", map.get("im_id"));
assertEquals("10,20,400,500", map.get("box"));
}


Expand Down

0 comments on commit d734e6b

Please sign in to comment.