Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Noway
Novice
800 Views

How to change the video source (through webcam) in Edge Insights for Retail via RESTful API

Jump to solution

Hi~Team

As we know that the demonstrate in website is doing very well , but I want to know how to change video source in webcam via RESTful API , I tried to modify the RESTful API into 

curl localhost:8080/pipelines/object_detection/2 -X POST -H 'Content-Type: application/json' -d '{ "source": { "v412src": "/dev/video0?raw=true", "type": "v412src" }}'
 
by following this step on website
Noway_0-1594689216321.png

 

 
but it didn't work , so how to change the video source and what kind of format that we can handle with it .
 
Many thanks!
 
Noway

0 Kudos
1 Solution
Tobias_M_Intel
Employee
495 Views

@Noway

Greetings,

Yes, when we use the -v parameter it replaces the content within the container (beneath "/home/video-analytics/pipelines"), so when you run docker exec -it container_id bash we should see object_detection/2/pipeline.json located there.

So let's confirm the contents of the folder beneath ~/dev/edge_insights_retail/pipelines on your host. If there is indeed an object_detection folder at this location it should show up within the container.

The "Connection refused" error indicates a bad launch of the service, likely due to problems loading the pipeline.  I notice the values used need to be adjusted.

replace:

v412src device=dev/video

with (lower case L and a leading slash):

v4l2src device=/dev/video0

 

When these two issues above are addressed the curl command should run successfully.

Some troubleshooting reminders that you may already be handling, but just in case:

1. First, please confirm no other video_analytics_serving_gstreamer containers are running (if so, stop and remove them)

docker ps

docker stop container_id

2. after running the container, view logs and available pipeline(s) using:

docker logs container_id

 

Best regards,
Tobias

View solution in original post

19 Replies
Nadia_J_Intel
Moderator
762 Views

Hi, 

We will look through it and get back to you soon. 

Thanks.

Noway
Novice
729 Views

Hi~Nadia_J

I'm looking forward to your reply

Many thanks

BR

Noway

Wayne_Feng
Employee
721 Views

After started service, you should be able to find API documents at http://localhost:8080/ui.

According to description of "DeviceSource", to use webcam device, assuming there is only one webcam in system, you need something like '{source: { "path": "/dev/video0", "type": "device" }'.

Noway
Novice
709 Views

Hi~Wayne

Thanks for your quickly reply.

I try the command by your suggestion , when I type 

curl localhost:8080/pipelines/object_detection/2 -X POST -H 'Content-Type: application/json' -d '{ "source": { "path": "/dev/video0", "type": "device" }}'

It will response "Unexpected error" in the terminal image.png

 

and I try to delete the space between "device" and " } " (shown as below in red square)  , the command execute but nothing happen (I just wait for it about 10 mins)

image.png

 I'm sure that webcam works by gst-launch-1.0 command

image.png

So , how do we trace the log to see what happen in it and Is there anything else I need to pay attention to ??

by the way , I using VMware 15 and Ubuntu 18.04.4 over testing

image.png

BR

Noway

Neelay_S_Intel
Employee
670 Views

@Noway  Can you provide the Video Analytics Serving log? 

 

Also you can set the LOG_LEVEL="DEBUG" environment variable and set GST_DEBUG=3 

Noway
Novice
665 Views

@Neelay_S_Intel 

Hi~

Where should I do those settings and in which files??

Many thanks 

BR

Noway

 

Neelay_S_Intel
Employee
656 Views

@Noway  I've requested some more information from our internal teams on the set up of VA Serving in Edge Software Hub and will get back to you with more details on the steps but probably will take a day or two. Sorry for the delay.

Also - just to double confirm - the samples using files is working correctly for you?

Noway
Novice
650 Views

@Neelay_S_Intel 

Ok , I got it , I'm looking forward to your reply.

"the samples using files is working correctly for you?"

=> Yes , the demonstration works very well by my side. 

Many thanks

BR

Noway

Noway
Novice
598 Views

@Neelay_S_Intel 

Good day 

After do more research , it might be the pipeline problem in the VAS docker.

When I issued the command as below 

Noway_3-1596011282648.png

 And check the pipeline.json inside VAS docker , then I saw that every single pipeline.json all began with 

"urisourcebin uri=\"{source[uri]}\" ........"  started , 

Noway_4-1596011575775.png

Noway_5-1596011710696.png

Noway_6-1596011756107.png

It might be the problem that we couldn't executed command properly.

BR

Noway

Wayne_Feng
Employee
590 Views

You have to create your own pipeline (or copy original one) which start with 'v4l2src'.

Noway
Novice
579 Views

@Wayne_Feng 

Hi~Wayne

The suggestion , It seen didn't work by my side.

first of all  , I copied the file (pipeline/gstreamer/object_detection/2/pipeline.json) from docker and outside to the host 

Noway_0-1596018110751.png

Noway_1-1596018168968.png

and modified it into v412src  device=\"{source[path]}\" , then copied it into the docker in 

pipeline/gstreamer/object_detection/4 path

Noway_2-1596018324689.png

Noway_3-1596018380579.png

and issued the curl command by following and we got "Invalid Pipeline or Version" response form terminal

Noway_4-1596018556329.png

Is there anything else I need to pay attention to ??

Many thanks

BR

Noway

 

 

Neelay_S_Intel
Employee
562 Views

@Noway 

Looks like great progress! Can you restart the service with the new pipeline in place?

VA Serving currently only loads pipelines at start up - so will not pick up a new pipeline added during execution. 

Can you zip and send us your pipelines directory? We can take a look at the pipelines and review them offline. 

Sorry for the delay in getting you started - we are working to improve the documentation and simplify certain aspects for VA Serving. You can find the latest https://github.com/intel/video-analytics-serving. 

 

Wayne_Feng
Employee
546 Views

I'm not sure copying pipeline files after VAS container started would work. Could you please try 'docker run' command with extra parameter '-v /path/to/your/pipelines:/home/video-analytics-serving/pipelines' so that VAServing loads your pipelines on startup.

Neelay_S_Intel
Employee
543 Views

@Wayne_Feng , @Noway 

 

This is correct - VA Serving will not reload pipelines at runtime - the pipelines need to be present when the container / image is started.

 

You can either add the pipeline into the image, or volume mount the pipelines folder as @Wayne_Feng described.

 

@Tobias_M_Intel 

 

From our conversation today - you may have a similar set up (virtual box / docker / va serving) - could you help review the steps required to modify a va serving pipeline within the context of the Edge Insights for Retail reference design?

 

Tobias_M_Intel
Employee
521 Views

@Neelay_S_Intel @Wayne_Feng 

@Noway Please try updating the pipeline to hardcode the webcam. Here are full instructions.

1. Launch container interactively:

sudo docker run -it --rm --privileged --net=host -v ~/.Xauthority:/root/.Xauthority -v /tmp/.X11-unix/:/tmp/.X11-unix/ -v /tmp:/tmp -e DISPLAY=$DISPLAY --entrypoint /bin/bash video_analytics_serving_gstreamer_edgex:0.2.2

2. Cat and copy pipeline content to clipboard:

cat pipelines/gstreamer/object_detection/2/pipeline.json

3. Store pipeline outside the image:

cd ~/dev/edge_insights_retail

mkdir -p ./pipelines/object_detection/2

sudo nano ./pipelines/object_detection/2/pipeline.json

4. Paste contents of original pipeline and update:

replace: "template": "urisourcebin uri=\"{source[uri]}\" !

with:       "template": "v4l2src device=/dev/video0 !

5. Now launch the container normally, but with volume mount to support your externally defined pipeline:

sudo docker run --rm -d --privileged --net=host -v ~/.Xauthority:/root/.Xauthority -v /tmp/.X11-unix/:/tmp/.X11-unix/ -v /tmp:/tmp -v ~/dev/edge_insights_retail/pipelines/gstreamer:/home/video-analytics/pipelines -e DISPLAY=$DISPLAY video_analytics_serving_gstreamer_edgex:0.2.2

6. Start the pipeline instance (source uri here will be ignored): 

curl localhost:8080/pipelines/object_detection/2 -X POST -H 'Content-Type: application/json' -d '{ "source": { "uri": "file:///nil", "type": "uri" }}'

7. Should result in webcam with person detected (when you are in view).

 

Neelay_S_Intel
Employee
516 Views
Noway
Novice
500 Views

@Tobias_M_Intel 

Hi~Tobias

Good day 

Following the steps , we got the error response as below

Noway_0-1596175800589.png

 

So , I wrote down the detail for more information as followings

1. launched the VAS command as normally , and checked the demonstration worked or not 

Noway_2-1596176315144.png

2. Into the docker and copied pipelin.josn content to ~/dev/edge_insights_retail/pipeline/object_detection/2/pipeline.json

Noway_3-1596176594469.png

 

Noway_5-1596176784160.png

 

3. Stop the previous docker and launched a new one by following command then check pineline.josn content was what we wanted 

sudo docker run --rm -d --privileged --net=host -v ~/.Xauthority:/root/.Xauthority -v /tmp/.X11-unix/:/tmp/.X11-unix/ -v /tmp:/tmp -v ~/dev/edge_insights_retail/pipelines:/home/video-analytics/pipelines -e DISPLAY=$DISPLAY video_analytics_serving_gstreamer_edgex:0.2.2

image.png

(the sample might be wrong with ~/dev/edge_insights_retail/pipelines/gstreamer path , when I launched the docker with this path , we can't saw pipeline.josn in it , graph shown as below)

image.png

4. launched curl command and we got the error response 

image.png

Should I catch some logs for more detail ?

If yes , please tell me how to do it .

Many thanks

BR

Noway

 

 

 

 

 

 

 

 

 

Tobias_M_Intel
Employee
496 Views

@Noway

Greetings,

Yes, when we use the -v parameter it replaces the content within the container (beneath "/home/video-analytics/pipelines"), so when you run docker exec -it container_id bash we should see object_detection/2/pipeline.json located there.

So let's confirm the contents of the folder beneath ~/dev/edge_insights_retail/pipelines on your host. If there is indeed an object_detection folder at this location it should show up within the container.

The "Connection refused" error indicates a bad launch of the service, likely due to problems loading the pipeline.  I notice the values used need to be adjusted.

replace:

v412src device=dev/video

with (lower case L and a leading slash):

v4l2src device=/dev/video0

 

When these two issues above are addressed the curl command should run successfully.

Some troubleshooting reminders that you may already be handling, but just in case:

1. First, please confirm no other video_analytics_serving_gstreamer containers are running (if so, stop and remove them)

docker ps

docker stop container_id

2. after running the container, view logs and available pipeline(s) using:

docker logs container_id

 

Best regards,
Tobias

View solution in original post

Noway
Novice
472 Views

Hi~Tobias

Yes , you were right.

I got the typo when I modified pipeline.json file.

And now , this question has been resolved  

Thanks for your strongly supported

BR

Noway

Reply