(self, task)
| 48 | } |
| 49 | |
| 50 | def process(self, task): |
| 51 | |
| 52 | # get input and output packet queue |
| 53 | input_queue = task.get_inputs()[0] |
| 54 | output_queue = task.get_outputs()[0] |
| 55 | |
| 56 | # add all input frames into frame cache |
| 57 | while not input_queue.empty(): |
| 58 | in_pkt = input_queue.get() |
| 59 | |
| 60 | if in_pkt.timestamp == Timestamp.EOF: |
| 61 | # we should done all frames processing in following loop |
| 62 | self.eof_received_ = True |
| 63 | continue |
| 64 | |
| 65 | in_frame = in_pkt.get(VideoFrame) |
| 66 | # pdb.set_trace() |
| 67 | if (in_frame.frame().device() == hmp.Device('cpu')): |
| 68 | in_frame = in_frame.cuda() |
| 69 | tensor_list = in_frame.frame().data() |
| 70 | # frame_out = hmp.Frame(self.w, self.h, in_frame.frame().pix_info(), device='cuda') |
| 71 | videoframe_out = VideoFrame(self.w, |
| 72 | self.h, |
| 73 | in_frame.frame().pix_info(), |
| 74 | device='cuda') |
| 75 | frame_out = videoframe_out.frame() |
| 76 | |
| 77 | out_list = frame_out.data() |
| 78 | stream = hmp.current_stream(hmp.kCUDA) |
| 79 | cvstream = cvcuda.cuda.as_stream(stream.handle()) |
| 80 | |
| 81 | # deal with nv12 special case |
| 82 | if (in_frame.frame().format() == hmp.PixelFormat.kPF_NV12 or |
| 83 | in_frame.frame().format() == hmp.PixelFormat.kPF_P010LE): |
| 84 | cvimg_batch = cvcuda.ImageBatchVarShape(3) |
| 85 | cvimg_batch_out = cvcuda.ImageBatchVarShape(3) |
| 86 | |
| 87 | in_420 = hmp.Frame(in_frame.width, |
| 88 | in_frame.height, |
| 89 | self.pinfo_map[in_frame.frame().format()], |
| 90 | device='cuda') |
| 91 | out_420 = hmp.Frame(self.w, |
| 92 | self.h, |
| 93 | self.pinfo_map[in_frame.frame().format()], |
| 94 | device='cuda') |
| 95 | hmp.img.yuv_to_yuv(in_420.data(), |
| 96 | in_frame.frame().data(), |
| 97 | self.pinfo_map[in_frame.frame().format()], |
| 98 | in_frame.frame().pix_info()) |
| 99 | in_list = in_420.data() |
| 100 | out_list = out_420.data() |
| 101 | cvimg_batch.pushback([cvcuda.as_image(x) for x in in_list]) |
| 102 | cvimg_batch_out.pushback( |
| 103 | [cvcuda.as_image(x) for x in out_list]) |
| 104 | |
| 105 | cvcuda.resize_into(cvimg_batch_out, |
| 106 | cvimg_batch, |
| 107 | self.algo, |
nothing calls this directly
no test coverage detected