void KisScanlineFill::fillSelection(KisPixelSelectionSP pixelSelection) { KisRandomConstAccessorSP it = m_d->device->createRandomConstAccessorNG(m_d->startPoint.x(), m_d->startPoint.y()); KoColor srcColor(it->rawDataConst(), m_d->device->colorSpace()); const int pixelSize = m_d->device->pixelSize(); if (pixelSize == 1) { SelectionPolicy<true, DifferencePolicyOptimized<quint8>, CopyToSelection> policy(m_d->device, srcColor, m_d->threshold); policy.setDestinationSelection(pixelSelection); runImpl(policy); } else if (pixelSize == 2) { SelectionPolicy<true, DifferencePolicyOptimized<quint16>, CopyToSelection> policy(m_d->device, srcColor, m_d->threshold); policy.setDestinationSelection(pixelSelection); runImpl(policy); } else if (pixelSize == 4) { SelectionPolicy<true, DifferencePolicyOptimized<quint32>, CopyToSelection> policy(m_d->device, srcColor, m_d->threshold); policy.setDestinationSelection(pixelSelection); runImpl(policy); } else if (pixelSize == 8) { SelectionPolicy<true, DifferencePolicyOptimized<quint64>, CopyToSelection> policy(m_d->device, srcColor, m_d->threshold); policy.setDestinationSelection(pixelSelection); runImpl(policy); } else { SelectionPolicy<true, DifferencePolicySlow, CopyToSelection> policy(m_d->device, srcColor, m_d->threshold); policy.setDestinationSelection(pixelSelection); runImpl(policy); } }
void KisScanlineFill::fillColor(const KoColor &fillColor) { KisRandomConstAccessorSP it = m_d->device->createRandomConstAccessorNG(m_d->startPoint.x(), m_d->startPoint.y()); KoColor srcColor(it->rawDataConst(), m_d->device->colorSpace()); const int pixelSize = m_d->device->pixelSize(); if (pixelSize == 1) { SelectionPolicy<false, DifferencePolicyOptimized<quint8>, FillWithColor> policy(m_d->device, srcColor, m_d->threshold); policy.setFillColor(fillColor); runImpl(policy); } else if (pixelSize == 2) { SelectionPolicy<false, DifferencePolicyOptimized<quint16>, FillWithColor> policy(m_d->device, srcColor, m_d->threshold); policy.setFillColor(fillColor); runImpl(policy); } else if (pixelSize == 4) { SelectionPolicy<false, DifferencePolicyOptimized<quint32>, FillWithColor> policy(m_d->device, srcColor, m_d->threshold); policy.setFillColor(fillColor); runImpl(policy); } else if (pixelSize == 8) { SelectionPolicy<false, DifferencePolicyOptimized<quint64>, FillWithColor> policy(m_d->device, srcColor, m_d->threshold); policy.setFillColor(fillColor); runImpl(policy); } else { SelectionPolicy<false, DifferencePolicySlow, FillWithColor> policy(m_d->device, srcColor, m_d->threshold); policy.setFillColor(fillColor); runImpl(policy); } }
void DAI4REID_ParsedInstance::nextFrame(QHashDataFrames &output) { // Read Color File QString instancePath = m_info.parent().getPath() + "/" + m_info.getFileName(DataFrame::Color); cv::Mat color_mat = cv::imread(instancePath.toStdString()); cv::cvtColor(color_mat, color_mat, CV_BGR2RGB); ColorFrame srcColor(color_mat.cols, color_mat.rows, (RGBColor*) color_mat.data); shared_ptr<ColorFrame> dstColor = make_shared<ColorFrame>(); *dstColor = srcColor; // Copy output.insert(DataFrame::Color, dstColor); // Read Depth File instancePath = m_info.parent().getPath() + "/" + m_info.getFileName(DataFrame::Depth); QFile depthFile(instancePath); depthFile.open(QIODevice::ReadOnly); QByteArray buffer = depthFile.readAll(); depthFile.close(); shared_ptr<DepthFrame> depthFrame = make_shared<DepthFrame>(); depthFrame->loadData(buffer); depthFrame->setDistanceUnits(dai::DISTANCE_MILIMETERS); depthFrame->setCameraIntrinsics(594.21434211923247, 320.0, -591.04053696870778, 240.0); output.insert(DataFrame::Depth, depthFrame); // Set color frame offset based on the depth bin that may contain it. dstColor->setOffset(depthFrame->offset()); /*instancePath = m_info.parent().getPath() + "/" + m_info.getFileName(DataFrame::Depth); cv::Mat depth_mat = cv::imread(instancePath.toStdString()); //, CV_LOAD_IMAGE_GRAYSCALE); qDebug() << depth_mat.type() << depth_mat.depth() << depth_mat.channels(); DepthFrame srcDepth(depth_mat.cols, depth_mat.rows, (uint16_t*) depth_mat.data, depth_mat.step); shared_ptr<DepthFrame> depthFrame = make_shared<DepthFrame>(); *depthFrame = srcDepth; // Copy depthFrame->setDistanceUnits(dai::MILIMETERS); output.insert(DataFrame::Depth, depthFrame);*/ // Read Mask File instancePath = m_info.parent().getPath() + "/" + m_info.getFileName(DataFrame::Mask); QFile maskFile(instancePath); maskFile.open(QIODevice::ReadOnly); buffer = maskFile.readAll(); maskFile.close(); shared_ptr<MaskFrame> maskFrame = make_shared<MaskFrame>(); maskFrame->loadData(buffer); output.insert(DataFrame::Mask, maskFrame); // Read Skeleton File instancePath = m_info.parent().getPath() + "/" + m_info.getFileName(DataFrame::Skeleton); QFile skeletonFile(instancePath); skeletonFile.open(QIODevice::ReadOnly); buffer = skeletonFile.readAll(); skeletonFile.close(); shared_ptr<Skeleton> skeleton = Skeleton::fromBinary(buffer); skeleton->setCameraIntrinsics(594.21434211923247, 320.0, -591.04053696870778, 240.0); shared_ptr<SkeletonFrame> skeletonFrame = make_shared<SkeletonFrame>(); skeletonFrame->setSkeleton(1, skeleton); output.insert(DataFrame::Skeleton, skeletonFrame); }
void KisScanlineFill::testingProcessLine(const KisFillInterval &processInterval) { KoColor srcColor(QColor(0,0,0,0), m_d->device->colorSpace()); KoColor fillColor(QColor(200,200,200,200), m_d->device->colorSpace()); SelectionPolicy<false, DifferencePolicyOptimized<quint32>, FillWithColor> policy(m_d->device, srcColor, m_d->threshold); policy.setFillColor(fillColor); processLine(processInterval, 1, policy); }
void IASLAB_RGBD_ID_Instance::nextFrame(QHashDataFrames &output) { // Read Color File QString instancePath = m_info.parent().getPath() + "/" + m_info.getFileName(DataFrame::Color); cv::Mat color_mat = cv::imread(instancePath.toStdString()); cv::cvtColor(color_mat, color_mat, CV_BGR2RGB); ColorFrame srcColor(color_mat.cols, color_mat.rows, (RGBColor*) color_mat.data); shared_ptr<ColorFrame> dstColor = make_shared<ColorFrame>(); *dstColor = srcColor; // Copy output.insert(DataFrame::Color, dstColor); // Read Depth File instancePath = m_info.parent().getPath() + "/" + m_info.getFileName(DataFrame::Depth); QFile depthFile(instancePath); depthFile.open(QIODevice::ReadOnly); QByteArray buffer = depthFile.readAll(); depthFile.close(); shared_ptr<DepthFrame> depthFrame_tmp = make_shared<DepthFrame>(640, 480, (uint16_t*) (buffer.data() + 16)); shared_ptr<DepthFrame> depthFrame = shared_ptr<DepthFrame>(new DepthFrame(*depthFrame_tmp)); // Clone! depthFrame->setDistanceUnits(dai::DISTANCE_MILIMETERS); // Set Depth intrinsics of the camera that generated this frame depthFrame->setCameraIntrinsics(fx_d, cx_d, fy_d, cy_d); output.insert(DataFrame::Depth, depthFrame); // Read Mask File instancePath = m_info.parent().getPath() + "/" + m_info.getFileName(DataFrame::Mask); QFile maskFile(instancePath); maskFile.open(QIODevice::ReadOnly); buffer = maskFile.readAll(); maskFile.close(); shared_ptr<MaskFrame> maskFrame_tmp = make_shared<MaskFrame>(640, 480, (uint8_t*) (buffer.data() + 14)); shared_ptr<MaskFrame> maskFrame = shared_ptr<MaskFrame>(new MaskFrame(*maskFrame_tmp)); // Clone! output.insert(DataFrame::Mask, maskFrame); // Read Skeleton txt file (line by line) /*For every frame, a skeleton file is available. For every joint, a row with the following information is written to the skeleton file: [id]: person ID, [x3D], [y3D], [z3D]: joint 3D position, [x2D], [y2D]: joint 2D position, [TrackingState]: 0 (not tracked), 1 (inferred) or 2 (tracked), [QualityFlag]: not implemented by NiTE, thus it is always 0, [OrientationStartJoint], [OrientationEndJoint]: indices of the extreme joints of a link, [Qx], [Qy], [Qz], [Qw]: quaternion expressing the orientation of the link identified by [OrientationStartJoint] and [OrientationEndJoint]. NiTE provides 15 joints, but these are remapped to the 20 joints that Microsoft Kinect SDK estimates, in order to have the same format (the joint positions missing in NiTE (wrists, ankles) are copied from other joints (hands, feet)). For more information, please visit http://msdn.microsoft.com/en-us/library/hh973074.aspx. You can also visualize the data with the "visualize_IASLab_RGBDID_dataset.m" Matlab script we provided.*/ instancePath = m_info.parent().getPath() + "/" + m_info.getFileName(DataFrame::Skeleton); QFile skeletonFile(instancePath); skeletonFile.open(QIODevice::ReadOnly); QTextStream in(&skeletonFile); shared_ptr<Skeleton> skeleton = make_shared<Skeleton>(); QList<int> ignore_lines = {1, 7, 11, 15, 19}; int lineCount = 0; while (!in.atEnd()) { QStringList columns = in.readLine().split(","); if (ignore_lines.contains(lineCount)) { lineCount++; continue; } SkeletonJoint joint(Point3f(columns[1].toFloat()*1000.0f, columns[2].toFloat()*1000.0f*-1, columns[3].toFloat()*1000.0f), _staticMap[lineCount]); int trackingState = columns[6].toInt(); if (trackingState == 0) joint.setPositionConfidence(0.0f); joint.setOrientation(Quaternion(columns[13].toFloat(), columns[10].toFloat(), columns[11].toFloat(), columns[12].toFloat())); //joint.setOrientationConfidence(niteJoint.getOrientationConfiden skeleton->setJoint(_staticMap[lineCount], joint); lineCount++; } skeletonFile.close(); // Set intrinsics of the camera that generated this frame (depth camera in this case) skeleton->setCameraIntrinsics(fx_d, cx_d, fy_d, cy_d); shared_ptr<SkeletonFrame> skeletonFrame = make_shared<SkeletonFrame>(); skeletonFrame->setSkeleton(1, skeleton); output.insert(DataFrame::Skeleton, skeletonFrame); // Register depth to color depth2color(depthFrame, maskFrame, skeleton); }