Merge lp:~sylvain-pineau/checkbox/camera_test_cheese_introspection into lp:checkbox

Proposed by Sylvain Pineau
Status: Superseded
Proposed branch: lp:~sylvain-pineau/checkbox/camera_test_cheese_introspection
Merge into: lp:checkbox
Prerequisite: lp:~sylvain-pineau/checkbox/ppa-packaging-plainbox-provider-checkbox-fix-1568664
Diff against target: 233 lines (+90/-77)
2 files modified
providers/plainbox-provider-checkbox/bin/camera_test (+86/-77)
providers/plainbox-provider-checkbox/jobs/camera.txt.in (+4/-0)
To merge this branch: bzr merge lp:~sylvain-pineau/checkbox/camera_test_cheese_introspection
Reviewer Review Type Date Requested Status
Taihsiang Ho Approve
Pierre Equoy Approve
Sylvain Pineau (community) Needs Resubmitting
Review via email: mp+291499@code.launchpad.net

This proposal has been superseded by a proposal from 2016-04-13.

Description of the change

This MR removes all gstreamer pipelines from the camera_test script. This new version relies on libcheese as creating a camera bin is not something we want to maintain in the checkbox provider.

WARNING:

DO not merge without the packaging branch update first.

To post a comment you must log in.
Revision history for this message
Taihsiang Ho (tai271828) wrote :

"./camera still"
works well on dino2 (CID 201508-18005) besides one small inline comment (please see below)

-------------

"./camera display"
crashed. The error message is:

http://paste.ubuntu.com/15760725/

./camera_test:570: PyGIWarning: Cheese was imported without specifying a version first. Use gi.require_version('Cheese', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import Cheese
Traceback (most recent call last):
  File "./camera_test", line 575, in <module>
    sys.exit(getattr(camera, args.test)())
  File "./camera_test", line 248, in display
    camera.set_device_by_device_node(self.args.device)
AttributeError: 'Camera' object has no attribute 'set_device_by_device_node'

review: Needs Fixing
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Thnaks for the review Tai. I made a few changes to support Xenial, resubmitting for review

review: Needs Resubmitting
Revision history for this message
Taihsiang Ho (tai271828) wrote :

on dino2 (CID 201508-18005)

* "./camera still" works well
* "./camera display" pops up a window and there is nothing (all white panel) in the window together with the following message in the console:

ubuntu@201508-18805:~/camera_test_cheese_introspection/providers/plainbox-provider-checkbox/bin$ ./camera_test display

(python3:2218): cheese-WARNING **: Internal GStreamer error: code not implemented. Please file a bug at http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer.: gstvideofilter.c(292): gst_video_filter_transform (): /GstCameraBin:camerabin/GstViewfinderBin:vf-bin/GstVideoConvert:vfbin-csp:
invalid video buffer received

(python3:2218): cheese-WARNING **: Internal GStreamer error: code not implemented. Please file a bug at http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer.: gstvideofilter.c(292): gst_video_filter_transform (): /GstCameraBin:camerabin/GstViewfinderBin:vf-bin/GstVideoConvert:vfbin-csp:
invalid video buffer received

Revision history for this message
Taihsiang Ho (tai271828) wrote :

test on another XPS (CID 201309-14238)

both of still and display works.

Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Another xenial api change... the camera constructor expects a Clutter.Actor instead of a Clutter.Texture. I changed the code to handle both cases. Tested the daily build it works for me. Could you do another round with the dino hw please?

review: Needs Resubmitting
Revision history for this message
Pierre Equoy (pieq) wrote :

Tested successfully on:

- One Dino 2 device with Trusty
- One Dino 2 device with Xenial
- One Chiclet 15 device with Xenial

In all cases, I got the expected results for camera/detect, camera/still, camera/display and camera/multiple=resolution-images tests (from the Certification Test Plan).

review: Approve
Revision history for this message
Taihsiang Ho (tai271828) wrote :

more info:

my above test on a XPS (CID 201309-14238) was tested on Trusty. Sorry for unclear statement.

https://code.launchpad.net/~sylvain-pineau/checkbox/camera_test_cheese_introspection/+merge/291499/comments/747099

Revision history for this message
Taihsiang Ho (tai271828) wrote :

tested on a XPS (CID 201309-14238) with Xenial daily build (built on Apr. 7th)
both of camera still and display looks good.

review: Approve
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'providers/plainbox-provider-checkbox/bin/camera_test'
--- providers/plainbox-provider-checkbox/bin/camera_test 2016-02-13 13:21:18 +0000
+++ providers/plainbox-provider-checkbox/bin/camera_test 2016-04-12 13:49:29 +0000
@@ -164,13 +164,10 @@
164 """164 """
165 A simple class that displays a test image via GStreamer.165 A simple class that displays a test image via GStreamer.
166 """166 """
167 def __init__(self, args, gst_plugin=None, gst_video_type=None):167 def __init__(self, args):
168 self.args = args168 self.args = args
169 self._mainloop = GObject.MainLoop()
170 self._width = 640169 self._width = 640
171 self._height = 480170 self._height = 480
172 self._gst_plugin = gst_plugin
173 self._gst_video_type = gst_video_type
174171
175 def detect(self):172 def detect(self):
176 """173 """
@@ -204,51 +201,62 @@
204 else '',201 else '',
205 ' ]', sep="")202 ' ]', sep="")
206203
207 resolutions = self._get_supported_resolutions(device)204 resolutions = self._supported_resolutions_to_string(
208 print(' ',205 self._get_supported_resolutions(device))
209 self._supported_resolutions_to_string(resolutions).replace(206 resolutions = resolutions.replace(
210 "\n", " "),207 "Resolutions:", " Resolutions:")
211 sep="")208 resolutions = resolutions.replace("Format:", " Format:")
209 print(resolutions)
212210
213 if cp.capabilities & V4L2_CAP_VIDEO_CAPTURE:211 if cp.capabilities & V4L2_CAP_VIDEO_CAPTURE:
214 cap_status = 0212 cap_status = 0
215 return dev_status | cap_status213 return dev_status | cap_status
216214
215 def _on_destroy(self, *args):
216 Clutter.main_quit()
217
218 def _take_photo(self, *args):
219 Cheese.Camera.take_photo(self.camera, self.filename)
220
217 def led(self):221 def led(self):
218 """222 """
219 Activate camera (switch on led), but don't display any output223 Activate camera (switch on led), but don't display any output
220 """224 """
221 pipespec = ("v4l2src device=%(device)s "225 Clutter.threads_add_timeout(0, 3000, self._on_destroy, None, None)
222 "! %(type)s "226 video_texture = Clutter.Actor()
223 "! %(plugin)s "227 try:
224 "! testsink"228 camera = Cheese.Camera.new(
225 % {'device': self.args.device,229 video_texture, self.args.device, self._width, self._height)
226 'type': self._gst_video_type,230 except TypeError: # libcheese < 3.18 still use Clutter.Texture
227 'plugin': self._gst_plugin})231 video_texture = Clutter.Texture()
228 logging.debug("LED test with pipeline %s", pipespec)232 camera = Cheese.Camera.new(
229 self._pipeline = Gst.parse_launch(pipespec)233 video_texture, self.args.device, self._width, self._height)
230 self._pipeline.set_state(Gst.State.PLAYING)234 Cheese.Camera.setup(camera, None)
231 time.sleep(3)235 Cheese.Camera.play(camera)
232 self._pipeline.set_state(Gst.State.NULL)236 Clutter.main()
233237
234 def display(self):238 def display(self):
235 """239 """
236 Displays the preview window240 Displays the preview window
237 """241 """
238 pipespec = ("v4l2src device=%(device)s "242 stage = Clutter.Stage()
239 "! %(type)s,width=%(width)d,height=%(height)d "243 stage.set_title('Camera test')
240 "! %(plugin)s "244 stage.set_size(self._width, self._height)
241 "! autovideosink"245 stage.connect('destroy', self._on_destroy)
242 % {'device': self.args.device,246 Clutter.threads_add_timeout(0, 10000, self._on_destroy, None, None)
243 'type': self._gst_video_type,247 video_texture = Clutter.Actor()
244 'width': self._width,248 try:
245 'height': self._height,249 camera = Cheese.Camera.new(
246 'plugin': self._gst_plugin})250 video_texture, self.args.device, self._width, self._height)
247 logging.debug("display test with pipeline %s", pipespec)251 except TypeError: # libcheese < 3.18 still use Clutter.Texture
248 self._pipeline = Gst.parse_launch(pipespec)252 video_texture = Clutter.Texture()
249 self._pipeline.set_state(Gst.State.PLAYING)253 camera = Cheese.Camera.new(
250 time.sleep(10)254 video_texture, self.args.device, self._width, self._height)
251 self._pipeline.set_state(Gst.State.NULL)255 stage.add_actor(video_texture)
256 Cheese.Camera.setup(camera, None)
257 Cheese.Camera.play(camera)
258 stage.show()
259 Clutter.main()
252260
253 def still(self):261 def still(self):
254 """262 """
@@ -272,7 +280,7 @@
272 "-d", self.args.device,280 "-d", self.args.device,
273 "-r", "%dx%d"281 "-r", "%dx%d"
274 % (width, height), filename]282 % (width, height), filename]
275 use_gstreamer = False283 use_cheese = False
276 if pixelformat:284 if pixelformat:
277 if 'MJPG' == pixelformat: # special tweak for fswebcam285 if 'MJPG' == pixelformat: # special tweak for fswebcam
278 pixelformat = 'MJPEG'286 pixelformat = 'MJPEG'
@@ -281,40 +289,37 @@
281 try:289 try:
282 check_call(command, stdout=open(os.devnull, 'w'), stderr=STDOUT)290 check_call(command, stdout=open(os.devnull, 'w'), stderr=STDOUT)
283 except (CalledProcessError, OSError):291 except (CalledProcessError, OSError):
284 use_gstreamer = True292 use_cheese = True
285293
286 if use_gstreamer:294 if use_cheese:
287 pipespec = ("v4l2src device=%(device)s "295 stage = Clutter.Stage()
288 "! %(type)s,width=%(width)d,height=%(height)d "296 stage.connect('destroy', self._on_destroy)
289 "! %(plugin)s "297 video_texture = Clutter.Actor()
290 "! jpegenc "298 try:
291 "! filesink location=%(filename)s"299 self.camera = Cheese.Camera.new(
292 % {'device': self.args.device,300 video_texture, self.args.device, self._width, self._height)
293 'type': self._gst_video_type,301 except TypeError: # libcheese < 3.18 still use Clutter.Texture
294 'width': width,302 video_texture = Clutter.Texture()
295 'height': height,303 self.camera = Cheese.Camera.new(
296 'plugin': self._gst_plugin,304 video_texture, self.args.device, self._width, self._height)
297 'filename': filename})305 Cheese.Camera.setup(self.camera, None)
298 logging.debug("still test with gstreamer and "306 Cheese.Camera.play(self.camera)
299 "pipeline %s", pipespec)307 self.filename = filename
300 self._pipeline = Gst.parse_launch(pipespec)308 Clutter.threads_add_timeout(0, 3000, self._take_photo , None, None)
301 self._pipeline.set_state(Gst.State.PLAYING)309 Clutter.threads_add_timeout(0, 4000, self._on_destroy, None, None)
302 time.sleep(3)310 Clutter.main()
303 self._pipeline.set_state(Gst.State.NULL)311 Cheese.Camera.stop(self.camera)
304312
305 if not quiet:313 if not quiet:
306 import imghdr314 stage = Clutter.Stage()
307 image_type = imghdr.what(filename)315 stage.set_title('Camera still picture test')
308 pipespec = ("filesrc location=%(filename)s ! "316 stage.set_size(width, height)
309 "%(type)sdec ! "317 stage.connect('destroy', self._on_destroy)
310 "videoscale ! "318 Clutter.threads_add_timeout(0, 10000, self._on_destroy, None, None)
311 "imagefreeze ! autovideosink"319 still_texture = Clutter.Texture.new_from_file(filename)
312 % {'filename': filename,320 stage.add_actor(still_texture)
313 'type': image_type})321 stage.show()
314 self._pipeline = Gst.parse_launch(pipespec)322 Clutter.main()
315 self._pipeline.set_state(Gst.State.PLAYING)
316 time.sleep(10)
317 self._pipeline.set_state(Gst.State.NULL)
318323
319 def _supported_resolutions_to_string(self, supported_resolutions):324 def _supported_resolutions_to_string(self, supported_resolutions):
320 """325 """
@@ -563,16 +568,20 @@
563568
564 # Import Gst only for the test cases that will need it569 # Import Gst only for the test cases that will need it
565 if args.test in ['display', 'still', 'led', 'resolutions']:570 if args.test in ['display', 'still', 'led', 'resolutions']:
571 import contextlib
572 # Workaround to avoid "cluttervideosink missing"
573 # See https://bugzilla.gnome.org/show_bug.cgi?id=721277
574 with contextlib.suppress(FileNotFoundError):
575 gst_registry = '~/.cache/gstreamer-1.0/registry.x86_64.bin'
576 os.remove(os.path.expanduser(gst_registry))
577 import gi
578 gi.require_version('Gst', '1.0')
566 from gi.repository import Gst579 from gi.repository import Gst
567 if Gst.version()[0] > 0:580 gi.require_version('Cheese', '3.0')
568 gst_plugin = 'videoconvert'581 from gi.repository import Cheese
569 gst_video_type = 'video/x-raw'582 gi.require_version('Clutter', '1.0')
570 else:583 from gi.repository import Clutter
571 gst_plugin = 'ffmpegcolorspace'
572 gst_video_type = 'video/x-raw-yuv'
573 Gst.init(None)584 Gst.init(None)
574 camera = CameraTest(args, gst_plugin, gst_video_type)585 Clutter.init()
575 else:586 camera = CameraTest(args)
576 camera = CameraTest(args)
577
578 sys.exit(getattr(camera, args.test)())587 sys.exit(getattr(camera, args.test)())
579588
=== modified file 'providers/plainbox-provider-checkbox/jobs/camera.txt.in'
--- providers/plainbox-provider-checkbox/jobs/camera.txt.in 2015-09-08 22:04:46 +0000
+++ providers/plainbox-provider-checkbox/jobs/camera.txt.in 2016-04-12 13:49:29 +0000
@@ -1,3 +1,7 @@
1unit: packaging meta-data
2os-id: debian
3Depends: gir1.2-cheese-3.0
4
1plugin: shell5plugin: shell
2category_id: 2013.com.canonical.plainbox::camera6category_id: 2013.com.canonical.plainbox::camera
3id: camera/detect7id: camera/detect

Subscribers

People subscribed via source and target branches